This is an automated email from the ASF dual-hosted git repository.
geomacy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new c33bb2f Fix race in
testUnsubmittedTaskWithExecutionContextTimesOutWhenImmediate
new b26173f Merge pull request #1129 from
grkvlt/value-resolver-test-race-fix
c33bb2f is described below
commit c33bb2fc0fde84322c5afbcaee7024c58076029b
Author: Andrew Donald Kennedy <[email protected]>
AuthorDate: Mon Nov 30 15:10:52 2020 +0000
Fix race in testUnsubmittedTaskWithExecutionContextTimesOutWhenImmediate
Wait until the result is present before continuing with test.
Signed-off-by: Andrew Donald Kennedy <[email protected]>
---
.../apache/brooklyn/util/core/task/ValueResolverTest.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git
a/core/src/test/java/org/apache/brooklyn/util/core/task/ValueResolverTest.java
b/core/src/test/java/org/apache/brooklyn/util/core/task/ValueResolverTest.java
index 108c6d4..4703e88 100644
---
a/core/src/test/java/org/apache/brooklyn/util/core/task/ValueResolverTest.java
+++
b/core/src/test/java/org/apache/brooklyn/util/core/task/ValueResolverTest.java
@@ -154,10 +154,12 @@ public class ValueResolverTest extends
BrooklynAppUnitTestSupport {
// Below, we call ValueResolver.getMaybe() in app's execution context.
Therefore it will execute the task
Maybe<Maybe<String>> result = app.getExecutionContext()
- .getImmediately(new BasicTask<>( () ->
Tasks.resolving(t).as(String.class).timeout(Asserts.DEFAULT_LONG_TIMEOUT).getMaybe()
));
+ .getImmediately(new BasicTask<>(() ->
Tasks.resolving(t).as(String.class).timeout(Asserts.DEFAULT_LONG_TIMEOUT).getMaybe()));
+ // Stupid race condition on slow machines; wait until result is
present first
+ Asserts.eventually(() -> result, r -> r.isPresent());
+
// However, the resubmission will not be waited upon
- Assert.assertTrue(result.isPresent(), "result="+result);
Assert.assertTrue(result.get().isAbsent(), "result="+result);
Exception exception = Maybe.getException(result.get());
@@ -169,9 +171,9 @@ public class ValueResolverTest extends
BrooklynAppUnitTestSupport {
Asserts.assertThat(t, (tt) -> Objects.equals(tt.getUnchecked(),
"foo"));
// And subsequent get _is_ immediate
- result = app.getExecutionContext()
- .getImmediately(new BasicTask<>( () ->
Tasks.resolving(t).as(String.class).timeout(Asserts.DEFAULT_LONG_TIMEOUT).getMaybe()
));
- Assert.assertEquals(result.get().get(), "foo");
+ Maybe<Maybe<String>> subsequent = app.getExecutionContext()
+ .getImmediately(new BasicTask<>(() ->
Tasks.resolving(t).as(String.class).timeout(Asserts.DEFAULT_LONG_TIMEOUT).getMaybe()));
+ Assert.assertEquals(subsequent.get().get(), "foo");
}
public void
testUnsubmittedTaskWithExecutionContextExecutesAndTimesOutImmediate() {
@@ -594,3 +596,4 @@ public class ValueResolverTest extends
BrooklynAppUnitTestSupport {
}
}
+