Skip to content

Commit

Permalink
skip ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchunqiang committed Jan 9, 2019
1 parent ad45c3e commit af98147
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 36 deletions.
13 changes: 5 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ jobs:
JVM_OPTS: -Xmx1024m
steps:
- checkout

- run:
name: test
command : |
mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
- run:
name: run unit tests
command: |
Expand Down Expand Up @@ -215,7 +210,9 @@ jobs:
version=2.10.0
sdkversion="aws-android-sdk-$version"
echo "sdkversion=$sdkversion" >> $BASH_ENV
git checkout resource aws-android-sdk
git checkout resources
git checkout master
git checkout resources aws-android-sdk
mv aws-android-sdk "$sdkversion"
- run:
name: copy libs
Expand All @@ -232,12 +229,12 @@ jobs:
cp -R docs/reference/* "$sdkversion/documentation/javadoc"
- run:
name: zip sdk folder
command: |
zip -r "$sdkversion.zip" "$sdkversion"
- run:
name: install aws cli
command: |
sudo pip install awscli
- run:
name: upload to s3
command: |
Expand Down Expand Up @@ -291,7 +288,7 @@ workflows:

- release_javadoc:
requires:
- release_maven
- release_tag
filters:
branches:
ignore: /.*/
Expand Down
28 changes: 14 additions & 14 deletions CircleciScripts/copylibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
root = sys.argv[1]
dest = sys.argv[2]
if not os.path.exists(dest):
os.makedirs(dest)
os.makedirs(dest)
modules = getmodules(root)
print(modules)
for module in modules:
print(module)
jarfile = os.path.join(root,module,"build/libs/{0}.jar".format(module))
if os.path.isfile(jarfile) :
destfile = os.path.join(dest, "{0}.jar".format(module))
copyfile(jarfile, destfile)
else:
aarfile = os.path.join(root,module,"build/outputs/aar/{0}-release.aar".format(module))
if os.path.isfile(aarfile) :
destfile = os.path.join(dest, "{0}.aar".format(module))
copyfile(aarfile, destfile)
else:
print("Did not find build result for {0}".format(module))
exit(1)
print(module)
jarfile = os.path.join(root,module,"build/libs/{0}.jar".format(module))
if os.path.isfile(jarfile) :
destfile = os.path.join(dest, "{0}.jar".format(module))
copyfile(jarfile, destfile)
else:
aarfile = os.path.join(root,module,"build/outputs/aar/{0}-release.aar".format(module))
if os.path.isfile(aarfile) :
destfile = os.path.join(dest, "{0}.aar".format(module))
copyfile(aarfile, destfile)
else:
print("Did not find build result for {0}".format(module))
exit(1)

25 changes: 11 additions & 14 deletions CircleciScripts/run_unittest.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
from functions import runcommand
from functions import runtest
from functions import TestTypes
from functions import getmodules
import sys
import re
import os

with open("settings.gradle") as f:
lines = f.readlines()
# you may also want to remove whitespace characters like `\n` at the end of each line
testmodules = []
for line in lines:
m = re.match(".*':(.*).*'", line)
if m is not None:
testmodules.append(m.group(1))
else:
print(line)
test_results = sys.argv[1]
root = sys.argv[2]
print(root)
testmodules = getmodules(root)


# testmodules = [
Expand All @@ -29,9 +24,11 @@
# ]


test_results = sys.argv[1]

runcommand("rm -rf {0}".format(test_results))
runcommand("mkdir {0}".format(test_results))
for module in testmodules:
if runtest(module, TestTypes.UnitTest, test_results) != 0 :
exit(1)
testfolder = os.path.join(root, module, "src/test")
if (os.path.isdir(testfolder)):
if runtest(module, TestTypes.UnitTest, test_results) != 0 :
exit(1)
70 changes: 70 additions & 0 deletions CircleciScripts/untitled.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

@Test
public void testWhenWritingTooManyConcurrentRecords() throws
InterruptedException, IOException {
File recordsDirectory = null;
File recordsFile = null;
FileManager fileManager = new FileManager(TEST_DIRECTORY);
final FileRecordStore recordStore = new FileRecordStore(TEST_DIRECTORY,
RECORDER_FILE_NAME, MAX_STORAGE_SIZE);

recordsDirectory = fileManager.getDirectory(Constants.RECORDS_DIRECTORY);
recordsFile = new File(recordsDirectory, Constants.RECORDS_FILE_NAME);

SecureRandom random = new SecureRandom();

// first fill the disk
String tempRecordStr = "";
for (int i = 0; i < 10000; i++) {
tempRecordStr = tempRecordStr + new BigInteger(130, random).toString(32);
}

final String recordStr = tempRecordStr;

for (int i = 0; i < 30; i++) {
recordStore.put(recordStr);
}

long initialSize = recordsFile.length();
assertTrue(recordsFile.length() <= MAX_STORAGE_SIZE);

final CountDownLatch latch = new CountDownLatch(1);
ExecutorService threadPool = Executors.newFixedThreadPool(1);
threadPool.execute(new Runnable() {
@Override
public void run() {
try {
for (int i = 0; i < 100; i++) {
RecordIterator itr = recordStore.iterator();
if (itr.hasNext()) {
String next = itr.next();
assertEquals(next.length(), recordStr.length());
itr.removeReadRecords();
}
Thread.sleep(1);
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
latch.countDown();
}
}
});

for (int i = 0; i < 10000; i++) {
recordStore.put(recordStr);
assertTrue(recordsFile.length() <= initialSize);
recordStore.put(recordStr);
assertTrue(recordsFile.length() <= initialSize);
recordStore.put(recordStr);
assertTrue(recordsFile.length() <= initialSize);
Thread.sleep(1);
}

latch.await();
assertEquals(recordsFile.length(), initialSize);
assertTrue(recordsFile.length() < MAX_STORAGE_SIZE);

}

0 comments on commit af98147

Please sign in to comment.