Skip to content

Commit

Permalink
Fix tests to pass on CICD under heavy load
Browse files Browse the repository at this point in the history
Some tests were done by assuming too much the CICD host was not used
by other CICD workloads. Unfortunately those tests, while valid in
real condition, were assuming too short times to pass.
The tests are adapted a bit to be more tolerant on CPU usage.

Also update dependencies.
  • Loading branch information
fredericBregier committed Oct 14, 2021
1 parent df4981e commit 068b0e7
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ProcessesTest {

public boolean waitForPidDone(int pid) {
int i;
for (i = 0; i < 10; i++) {
for (i = 0; i < 50; i++) {
try {
Thread.sleep(TIMEMS);
} catch (InterruptedException ignored) {//NOSONAR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ public void test6_RecvUsingTrafficShaping() throws IOException {
totestBig.delete();
}

private void test_Spooled(final SpooledThread spooledThread, final int factor)
private void test_Spooled(final SpooledThread spooledThread)
throws IOException, InterruptedException {
final int size = 200;
Configuration.configuration.changeNetworkLimit(0, 0, 0, 0, 1000);
Expand All @@ -912,25 +912,51 @@ private void test_Spooled(final SpooledThread spooledThread, final int factor)
spooledThread.future = future;
spooledThread.start();
Thread.sleep(200);
int cpt = 0;
logger.warn("1rst file");
final File totestBig = generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("1rst file delete");
totestBig.delete();
Thread.sleep(2000);
logger.warn("Second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
logger.warn("Third file");
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("Third file modifying second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size + 1,
"abcdefghij");
Thread.sleep(4000 / factor);
if (spooledThread.ignoreAlreadyUsed) {
Thread.sleep(2000);
} else {
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
}
logger.warn("Third file deleted");
totestBig.delete();
Thread.sleep(2000 / factor);
Thread.sleep(1000);
generateOutFile(stop.getAbsolutePath(), 10);
future.awaitOrInterruptible();
assertTrue(future.isSuccess());
Expand All @@ -948,7 +974,7 @@ public void test70_Spooled() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -959,7 +985,7 @@ public void test70_SpooledSubmit() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -970,7 +996,7 @@ public void test70_SpooledIgnore() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -982,7 +1008,7 @@ public void test70_SpooledSubmitIgnore()
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ public void test6_RecvUsingTrafficShapingNoCompress() throws IOException {
totestBig.delete();
}

private void test_Spooled(final SpooledThread spooledThread, final int factor)
private void test_Spooled(final SpooledThread spooledThread)
throws IOException, InterruptedException {
final int size = 200;
Configuration.configuration.changeNetworkLimit(0, 0, 0, 0, 1000);
Expand All @@ -1120,25 +1120,51 @@ private void test_Spooled(final SpooledThread spooledThread, final int factor)
spooledThread.future = future;
spooledThread.start();
Thread.sleep(200);
int cpt = 0;
logger.warn("1rst file");
final File totestBig = generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("1rst file delete");
totestBig.delete();
Thread.sleep(2000);
logger.warn("Second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
logger.warn("Third file");
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("Third file modifying second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size + 1,
"abcdefghij");
Thread.sleep(4000 / factor);
if (spooledThread.ignoreAlreadyUsed) {
Thread.sleep(2000);
} else {
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
}
logger.warn("Third file deleted");
totestBig.delete();
Thread.sleep(2000 / factor);
Thread.sleep(1000);
generateOutFile(stop.getAbsolutePath(), 10);
future.awaitOrInterruptible();
assertTrue(future.isSuccess());
Expand All @@ -1156,7 +1182,7 @@ public void test70_Spooled() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1167,7 +1193,7 @@ public void test70_SpooledSubmit() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1178,7 +1204,7 @@ public void test70_SpooledIgnore() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1190,7 +1216,7 @@ public void test70_SpooledSubmitIgnore()
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public void test6_RecvUsingTrafficShaping() throws IOException {
totestBig.delete();
}

private void test_Spooled(final SpooledThread spooledThread, final int factor)
private void test_Spooled(final SpooledThread spooledThread)
throws IOException, InterruptedException {
final int size = 200;
Configuration.configuration.changeNetworkLimit(0, 0, 0, 0, 1000);
Expand All @@ -1037,25 +1037,51 @@ private void test_Spooled(final SpooledThread spooledThread, final int factor)
spooledThread.future = future;
spooledThread.start();
Thread.sleep(200);
int cpt = 0;
logger.warn("1rst file");
final File totestBig = generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("1rst file delete");
totestBig.delete();
Thread.sleep(2000);
logger.warn("Second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size);
Thread.sleep(4000 / factor);
logger.warn("Third file");
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
logger.warn("Third file modifying second file");
generateOutFile(
SpooledThread.TMP_R_66_TEST_OUT_EXAMPLE + "/testTaskBig.txt", size + 1,
"abcdefghij");
Thread.sleep(4000 / factor);
if (spooledThread.ignoreAlreadyUsed) {
Thread.sleep(2000);
} else {
cpt++;
for (int i = 0; i < 100; i++) {
if (spooledThread.spooledDirectoryTransfer.getSent() != cpt) {
Thread.sleep(200);
} else {
break;
}
}
}
logger.warn("Third file deleted");
totestBig.delete();
Thread.sleep(2000 / factor);
Thread.sleep(1000);
generateOutFile(stop.getAbsolutePath(), 10);
future.awaitOrInterruptible();
assertTrue(future.isSuccess());
Expand All @@ -1073,7 +1099,7 @@ public void test70_Spooled() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1084,7 +1110,7 @@ public void test70_SpooledSubmit() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = false;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(3, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1095,7 +1121,7 @@ public void test70_SpooledIgnore() throws IOException, InterruptedException {
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = false;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand All @@ -1107,7 +1133,7 @@ public void test70_SpooledSubmitIgnore()
SpooledThread spooledThread = new SpooledThread();
spooledThread.ignoreAlreadyUsed = true;
spooledThread.submit = true;
test_Spooled(spooledThread, 2);
test_Spooled(spooledThread);
assertEquals(2, spooledThread.spooledDirectoryTransfer.getSent());
assertEquals(0, spooledThread.spooledDirectoryTransfer.getError());
}
Expand Down
Loading

0 comments on commit 068b0e7

Please sign in to comment.