Add TimeOuts to new threading tests, in case there's a underlying deadlock
This commit is contained in:
parent
fde9824765
commit
846e0c11bc
|
|
@ -16,6 +16,8 @@ import java.util.*;
|
||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
public class NanoSchedulerUnitTest extends BaseTest {
|
public class NanoSchedulerUnitTest extends BaseTest {
|
||||||
|
public static final int NANO_SCHEDULE_MAX_RUNTIME = 10000;
|
||||||
|
|
||||||
private class Map2x implements MapFunction<Integer, Integer> {
|
private class Map2x implements MapFunction<Integer, Integer> {
|
||||||
@Override public Integer apply(Integer input) { return input * 2; }
|
@Override public Integer apply(Integer input) { return input * 2; }
|
||||||
}
|
}
|
||||||
|
|
@ -83,14 +85,14 @@ public class NanoSchedulerUnitTest extends BaseTest {
|
||||||
return NanoSchedulerBasicTest.getTests(NanoSchedulerBasicTest.class);
|
return NanoSchedulerBasicTest.getTests(NanoSchedulerBasicTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest")
|
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest", timeOut = NANO_SCHEDULE_MAX_RUNTIME)
|
||||||
public void testSingleThreadedNanoScheduler(final NanoSchedulerBasicTest test) throws InterruptedException {
|
public void testSingleThreadedNanoScheduler(final NanoSchedulerBasicTest test) throws InterruptedException {
|
||||||
logger.warn("Running " + test);
|
logger.warn("Running " + test);
|
||||||
if ( test.nThreads == 1 )
|
if ( test.nThreads == 1 )
|
||||||
testNanoScheduler(test);
|
testNanoScheduler(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest", timeOut = 10000, dependsOnMethods = "testSingleThreadedNanoScheduler")
|
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest", timeOut = NANO_SCHEDULE_MAX_RUNTIME, dependsOnMethods = "testSingleThreadedNanoScheduler")
|
||||||
public void testMultiThreadedNanoScheduler(final NanoSchedulerBasicTest test) throws InterruptedException {
|
public void testMultiThreadedNanoScheduler(final NanoSchedulerBasicTest test) throws InterruptedException {
|
||||||
logger.warn("Running " + test);
|
logger.warn("Running " + test);
|
||||||
if ( test.nThreads >= 1 )
|
if ( test.nThreads >= 1 )
|
||||||
|
|
@ -111,7 +113,7 @@ public class NanoSchedulerUnitTest extends BaseTest {
|
||||||
nanoScheduler.shutdown();
|
nanoScheduler.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest", dependsOnMethods = "testMultiThreadedNanoScheduler")
|
@Test(enabled = true, dataProvider = "NanoSchedulerBasicTest", dependsOnMethods = "testMultiThreadedNanoScheduler", timeOut = NANO_SCHEDULE_MAX_RUNTIME)
|
||||||
public void testNanoSchedulerInLoop(final NanoSchedulerBasicTest test) throws InterruptedException {
|
public void testNanoSchedulerInLoop(final NanoSchedulerBasicTest test) throws InterruptedException {
|
||||||
if ( test.bufferSize > 1 && (test.mapGroupSize > 1 || test.mapGroupSize == -1)) {
|
if ( test.bufferSize > 1 && (test.mapGroupSize > 1 || test.mapGroupSize == -1)) {
|
||||||
logger.warn("Running " + test);
|
logger.warn("Running " + test);
|
||||||
|
|
@ -130,7 +132,7 @@ public class NanoSchedulerUnitTest extends BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test(timeOut = NANO_SCHEDULE_MAX_RUNTIME)
|
||||||
public void testShutdown() throws InterruptedException {
|
public void testShutdown() throws InterruptedException {
|
||||||
final NanoScheduler<Integer, Integer, Integer> nanoScheduler = new NanoScheduler<Integer, Integer, Integer>(1, 1, 2);
|
final NanoScheduler<Integer, Integer, Integer> nanoScheduler = new NanoScheduler<Integer, Integer, Integer>(1, 1, 2);
|
||||||
Assert.assertFalse(nanoScheduler.isShutdown(), "scheduler should be alive");
|
Assert.assertFalse(nanoScheduler.isShutdown(), "scheduler should be alive");
|
||||||
|
|
@ -138,7 +140,7 @@ public class NanoSchedulerUnitTest extends BaseTest {
|
||||||
Assert.assertTrue(nanoScheduler.isShutdown(), "scheduler should be dead");
|
Assert.assertTrue(nanoScheduler.isShutdown(), "scheduler should be dead");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class)
|
@Test(expectedExceptions = IllegalStateException.class, timeOut = NANO_SCHEDULE_MAX_RUNTIME)
|
||||||
public void testShutdownExecuteFailure() throws InterruptedException {
|
public void testShutdownExecuteFailure() throws InterruptedException {
|
||||||
final NanoScheduler<Integer, Integer, Integer> nanoScheduler = new NanoScheduler<Integer, Integer, Integer>(1, 1, 2);
|
final NanoScheduler<Integer, Integer, Integer> nanoScheduler = new NanoScheduler<Integer, Integer, Integer>(1, 1, 2);
|
||||||
nanoScheduler.shutdown();
|
nanoScheduler.shutdown();
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import java.util.concurrent.*;
|
||||||
public class EfficiencyMonitoringThreadFactoryUnitTest extends BaseTest {
|
public class EfficiencyMonitoringThreadFactoryUnitTest extends BaseTest {
|
||||||
// the duration of the tests -- 100 ms is tolerable given the number of tests we are doing
|
// the duration of the tests -- 100 ms is tolerable given the number of tests we are doing
|
||||||
private final static long THREAD_TARGET_DURATION_IN_MILLISECOND = 1000;
|
private final static long THREAD_TARGET_DURATION_IN_MILLISECOND = 1000;
|
||||||
|
private final static int MAX_THREADS = 4;
|
||||||
final static Object GLOBAL_LOCK = new Object();
|
final static Object GLOBAL_LOCK = new Object();
|
||||||
|
|
||||||
private class StateTest extends TestDataProvider {
|
private class StateTest extends TestDataProvider {
|
||||||
|
|
@ -126,7 +127,7 @@ public class EfficiencyMonitoringThreadFactoryUnitTest extends BaseTest {
|
||||||
return StateTest.getTests(StateTest.class);
|
return StateTest.getTests(StateTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dataProvider = "StateTest")
|
@Test(enabled = true, dataProvider = "StateTest", timeOut = MAX_THREADS * THREAD_TARGET_DURATION_IN_MILLISECOND)
|
||||||
public void testStateTest(final StateTest test) throws InterruptedException {
|
public void testStateTest(final StateTest test) throws InterruptedException {
|
||||||
// allows us to test blocking
|
// allows us to test blocking
|
||||||
final EfficiencyMonitoringThreadFactory factory = new EfficiencyMonitoringThreadFactory(test.getNStates());
|
final EfficiencyMonitoringThreadFactory factory = new EfficiencyMonitoringThreadFactory(test.getNStates());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue