@Test public void testInessentialChildrenFailureDoesNotAbortSecondaryOrFailPrimary() { Task<String> t1 = monitorableTask(null, "1", new FailCallable()); TaskTags.markInessential(t1); Task<String> t = Tasks.<String>builder() .dynamic(true) .body(monitorableJob("main")) .add(t1) .add(monitorableTask("2")) .build(); ec.submit(t); releaseAndWaitForMonitorableJob("1"); Assert.assertFalse(t.blockUntilEnded(TINY_TIME)); releaseAndWaitForMonitorableJob("2"); Assert.assertFalse(t.blockUntilEnded(TINY_TIME)); releaseMonitorableJob("main"); Assert.assertTrue(t.blockUntilEnded(TIMEOUT)); Assert.assertEquals(messages, MutableList.of("1", "2", "main")); Assert.assertTrue( stopwatch.elapsed(TimeUnit.MILLISECONDS) < TIMEOUT.toMilliseconds(), "took too long: " + stopwatch); Assert.assertFalse(t.isError()); Assert.assertTrue(t1.isError()); }
@Test public void testCanCallEffector() { entity = new ExampleJavaEntity(app); app.manage(entity); entity.effector1("val1"); assertEquals(entity.effectorInvocations, ImmutableList.of("val1")); Task<Void> task = entity.invoke(ExampleJavaEntity.EFFECTOR1, ImmutableMap.of("arg0", "val2")); task.blockUntilEnded(); assertEquals(entity.effectorInvocations, ImmutableList.of("val1", "val2")); }
@Test public void testChildrenRunConcurrentlyWithPrimary() { Task<String> t = Tasks.<String>builder() .dynamic(true) .body(monitorableJob("main")) .add(monitorableTask("1")) .add(monitorableTask("2")) .build(); ec.submit(t); releaseAndWaitForMonitorableJob("1"); releaseAndWaitForMonitorableJob("main"); Assert.assertFalse(t.blockUntilEnded(TINY_TIME)); releaseMonitorableJob("2"); Assert.assertTrue(t.blockUntilEnded(TIMEOUT)); Assert.assertEquals(messages, MutableList.of("1", "main", "2")); Assert.assertTrue( stopwatch.elapsed(TimeUnit.MILLISECONDS) < TIMEOUT.toMilliseconds(), "took too long: " + stopwatch); Assert.assertFalse(t.isError()); }