Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/213#discussion_r18506545
--- Diff:
core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
---
@@ -131,9 +133,19 @@ protected void forceGc() {
return
Tasks.builder().name(name).dynamic(false).body(Callables.returning(null));
}
- protected static void assertTaskCountForEntity(Entity entity, int
expectedCount) {
- Collection<Task<?>> tasks =
BrooklynTaskTags.getTasksInEntityContext(((EntityInternal)entity).getManagementContext().getExecutionManager(),
entity);
- Assert.assertEquals(tasks.size(), expectedCount, "Tasks were
"+tasks);
+ protected void assertTaskCountForEntitySoon(final Entity entity, final
int expectedCount) {
+ // Dead task (and initialization task) should have been GC'd on
completion.
+ // However, the GC'ing happens in a listener, executed in a
different thread - the task.get()
+ // doesn't block for it. Therefore can't always guarantee it will
be GC'ed by now.
+ Repeater.create().backoff(Duration.millis(10), 2,
Duration.millis(500)).limitTimeTo(Duration.TEN_SECONDS).until(new
Callable<Boolean>() {
--- End diff --
I prefer `succeedsEventually`. It is more consistent with how our other
tests are written, and more concise. The other parameters to the repeater are
just noise. This test should not care what the repeat interval or duration is.
Asserts.succeedsEventually(new Runnable() {
public void run() {
forceGc();
ExecutionManager execManager =
((EntityInternal)entity).getManagementContext().getExecutionManager();
Collection<Task<?>> tasks =
BrooklynTaskTags.getTasksInEntityContext(execManager, entity);
assertEquals(tasks.size(), expectedCount, "Tasks were "+tasks);
}});
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---