This is an automated email from the ASF dual-hosted git repository.
heybales pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 58eccef GEODE-5704: use untilAsserted to avoid early failure (#2438)
58eccef is described below
commit 58eccef89f245a3b40d062408792eb5b22f66255
Author: Helena Bales <[email protected]>
AuthorDate: Fri Sep 7 16:29:53 2018 -0700
GEODE-5704: use untilAsserted to avoid early failure (#2438)
* GEODE-5704: use untilAsserted to avoid early failure
There was an awaitility that intended to loop until data was consistent
but instead failed on the first pass if any keys weren't consistent.
Signed-off-by: [email protected]
---
.../geode/cache30/MultiVMRegionTestCase.java | 68 ++++++++++------------
1 file changed, 32 insertions(+), 36 deletions(-)
diff --git
a/geode-dunit/src/main/java/org/apache/geode/cache30/MultiVMRegionTestCase.java
b/geode-dunit/src/main/java/org/apache/geode/cache30/MultiVMRegionTestCase.java
index 206c47e..983118d 100644
---
a/geode-dunit/src/main/java/org/apache/geode/cache30/MultiVMRegionTestCase.java
+++
b/geode-dunit/src/main/java/org/apache/geode/cache30/MultiVMRegionTestCase.java
@@ -8284,45 +8284,41 @@ public abstract class MultiVMRegionTestCase extends
RegionTestCase {
fail("neither member saw event conflation - check stats for " + name);
}
- // Wait for the members to eventually be consistent
// For no-ack regions, messages may still be in flight between replicas at
this point
- waitAtMost(5, MINUTES).until(() -> {
-
- // check consistency of the regions
- Map r1Contents = vm1.invoke(MultiVMRegionTestCase::getCCRegionContents);
- Map r2Contents = vm2.invoke(MultiVMRegionTestCase::getCCRegionContents);
- Map r3Contents = vm3.invoke(MultiVMRegionTestCase::getCCRegionContents);
-
- try {
- for (int i = 0; i < 10; i++) {
- String key = "cckey" + i;
- assertThat(r2Contents.get(key)).describedAs(
- "1 region contents are not consistent for i " +
key).isEqualTo(r1Contents.get(key));
- assertThat(r3Contents.get(key)).describedAs(
- "2 region contents are not consistent for i " +
key).isEqualTo(r2Contents.get(key));
- for (int subi = 1; subi < 3; subi++) {
- String subkey = key + "-" + subi;
- if (r1Contents.containsKey(subkey)) {
- assertThat(r2Contents.get(subkey)).describedAs(
- "3 region contents are not consistent for " +
subkey).isEqualTo(
- r1Contents.get(subkey));
- assertThat(r3Contents.get(subkey)).describedAs(
- "4 region contents are not consistent for " +
subkey).isEqualTo(
- r2Contents.get(subkey));
- } else {
- boolean condition1 = !r2Contents.containsKey(subkey);
- assertThat(condition1).describedAs("5 r2contents").isTrue();
- boolean condition = !r3Contents.containsKey(subkey);
- assertThat(condition).describedAs("6 r3contents").isTrue();
+ await("Wait for the members to eventually be consistent").atMost(5,
MINUTES)
+ .untilAsserted(() -> {
+
+ // check consistency of the regions
+ Map r1Contents =
vm1.invoke(MultiVMRegionTestCase::getCCRegionContents);
+ Map r2Contents =
vm2.invoke(MultiVMRegionTestCase::getCCRegionContents);
+ Map r3Contents =
vm3.invoke(MultiVMRegionTestCase::getCCRegionContents);
+
+ for (int i = 0; i < 10; i++) {
+ String key = "cckey" + i;
+ assertThat(r2Contents.get(key)).describedAs(
+ "r2 contents are not consistent with r1 for " + key)
+ .isEqualTo(r1Contents.get(key));
+ assertThat(r3Contents.get(key)).describedAs(
+ "r3 contents are not consistent with r2 for " + key)
+ .isEqualTo(r2Contents.get(key));
+ for (int subi = 1; subi < 3; subi++) {
+ String subkey = key + "-" + subi;
+ if (r1Contents.containsKey(subkey)) {
+ assertThat(r2Contents.get(subkey)).describedAs(
+ "r2 contents are not consistent with r1 for subkey " +
subkey).isEqualTo(
+ r1Contents.get(subkey));
+ assertThat(r3Contents.get(subkey)).describedAs(
+ "r3 contents are not consistent with r2 for subkey " +
subkey).isEqualTo(
+ r2Contents.get(subkey));
+ } else {
+ assertThat(r2Contents.containsKey(subkey))
+ .describedAs("r2 contains subkey " + subkey + " that r1
does not").isFalse();
+ assertThat(r3Contents.containsKey(subkey))
+ .describedAs("r3 contains subkey " + subkey + " that r1
does not").isFalse();
+ }
}
}
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw (e);
- }
- return true;
- });
+ });
}