Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-2026 [created] d4262fb50
GEODE-2026: fix flaky test The test was initializing a value to a String, then starting an async thread that would keep changing it to an int, it slept for 100ms and then assummed that the async thread had changed the value to an Integer. In rare cases the thread never was able to to its first put so the value was still a String. The test now waits for the async thread to change the value to an Integer instead of doing a 100ms sleep. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d4262fb5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d4262fb5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d4262fb5 Branch: refs/heads/feature/GEODE-2026 Commit: d4262fb5013eabf0ef433cf8a6a9bd67dba1805d Parents: 7742981 Author: Darrel Schneider <[email protected]> Authored: Mon Oct 24 16:15:04 2016 -0700 Committer: Darrel Schneider <[email protected]> Committed: Mon Oct 24 16:15:04 2016 -0700 ---------------------------------------------------------------------- .../PersistentPartitionedRegionDUnitTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d4262fb5/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDUnitTest.java index 5ca3d01..c4358fc 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PersistentPartitionedRegionDUnitTest.java @@ -1628,7 +1628,19 @@ public class PersistentPartitionedRegionDUnitTest extends PersistentPartitionedR AsyncInvocation asyncCreate = vm0.invokeAsync(createData); - Thread.sleep(100); + SerializableCallable waitForIntValue = new SerializableCallable() { + public Object call() throws InterruptedException { + Cache cache = getCache(); + Region region = cache.getRegion(PR_REGION_NAME); + // The value is initialized as a String so wait + // for it to be changed to an Integer. + await().atMost(30, SECONDS).until(() -> { + return region.get(0) instanceof Integer; + }); + return region.get(0); + } + }; + vm0.invoke(waitForIntValue); AsyncInvocation close0 = closeCacheAsync(vm0); AsyncInvocation close1 = closeCacheAsync(vm1);
