You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nn...@apache.org on 2017/08/29 21:54:48 UTC
geode git commit: GEODE-3502: Added awaitility clauses.
Repository: geode
Updated Branches:
refs/heads/develop 77a0b9f8e -> dd7c45b43
GEODE-3502: Added awaitility clauses.
* Added awaitility clauses while waiting for the stat comparison checks
* Replaced the deprecated Wait Criterion with Awaitility clause with increased timeout
* Replaced the invokeAsync with invoke to make the test identical to the one in ClientHealthStatsDUnitTest
* Removed the commented out flaky tag
This closes #749
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/dd7c45b4
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/dd7c45b4
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/dd7c45b4
Branch: refs/heads/develop
Commit: dd7c45b438eede230ac78d2fe4f0bca88200dec7
Parents: 77a0b9f
Author: nabarun <nn...@pivotal.io>
Authored: Tue Aug 29 11:05:28 2017 -0700
Committer: nabarun <nn...@pivotal.io>
Committed: Tue Aug 29 14:47:00 2017 -0700
----------------------------------------------------------------------
.../internal/cache/ha/Bug48571DUnitTest.java | 72 ++++++++++----------
1 file changed, 35 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/dd7c45b4/geode-core/src/test/java/org/apache/geode/internal/cache/ha/Bug48571DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/Bug48571DUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/Bug48571DUnitTest.java
index 516275a..00ce44b 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ha/Bug48571DUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ha/Bug48571DUnitTest.java
@@ -49,12 +49,15 @@ import org.apache.geode.test.dunit.WaitCriterion;
import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
import org.apache.geode.test.junit.categories.DistributedTest;
+
+import org.awaitility.Awaitility;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
@Category({DistributedTest.class, ClientSubscriptionTest.class})
public class Bug48571DUnitTest extends JUnit4DistributedTestCase {
@@ -95,32 +98,24 @@ public class Bug48571DUnitTest extends JUnit4DistributedTestCase {
}
private static void verifyProxyHasBeenPaused() {
- WaitCriterion criterion = new WaitCriterion() {
- @Override
- public boolean done() {
- CacheClientNotifier ccn = CacheClientNotifier.getInstance();
- Collection<CacheClientProxy> ccProxies = ccn.getClientProxies();
-
- Iterator<CacheClientProxy> itr = ccProxies.iterator();
-
- while (itr.hasNext()) {
- CacheClientProxy ccp = itr.next();
- System.out.println("proxy status " + ccp.getState());
- if (ccp.isPaused())
- return true;
+ Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+ CacheClientNotifier ccn = CacheClientNotifier.getInstance();
+ Collection<CacheClientProxy> ccProxies = ccn.getClientProxies();
+ boolean pausedFlag = false;
+ Iterator<CacheClientProxy> itr = ccProxies.iterator();
+
+ while (itr.hasNext()) {
+ CacheClientProxy ccp = itr.next();
+ System.out.println("proxy status " + ccp.getState());
+ if (ccp.isPaused()) {
+ pausedFlag = true;
+ break;
}
- return false;
- }
-
- @Override
- public String description() {
- return "Proxy has not paused yet";
}
- };
- Wait.waitForCriterion(criterion, 15 * 1000, 200, true);
+ assertEquals("Proxy has not been paused in 1 minute", true, pausedFlag);
+ });
}
- // @Category(FlakyTest.class) // GEODE-510
@Test
public void testStatsMatchWithSize() throws Exception {
IgnoredException.addIgnoredException("Unexpected IOException||Connection reset");
@@ -135,7 +130,7 @@ public class Bug48571DUnitTest extends JUnit4DistributedTestCase {
server.invoke("verifyProxyHasBeenPaused", () -> verifyProxyHasBeenPaused());
// resume puts on server, add another 100.
- server.invokeAsync(() -> Bug48571DUnitTest.resumePuts()); // TODO: join or await result
+ server.invoke(() -> Bug48571DUnitTest.resumePuts());
// start durable client
client.invoke(() -> Bug48571DUnitTest.createClientCache(client.getHost(), port));
// wait for full queue dispatch
@@ -283,19 +278,22 @@ public class Bug48571DUnitTest extends JUnit4DistributedTestCase {
}
public static void verifyStats() throws Exception {
- CacheClientNotifier ccn = CacheClientNotifier.getInstance();
- CacheClientProxy ccp = ccn.getClientProxies().iterator().next();
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getQueueSize() " + ccp.getQueueSize());
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
- "getQueueSizeStat() " + ccp.getQueueSizeStat());
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
- "getEventsEnqued() " + ccp.getHARegionQueue().getStatistics().getEventsEnqued());
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
- "getEventsDispatched() " + ccp.getHARegionQueue().getStatistics().getEventsDispatched());
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
- "getEventsRemoved() " + ccp.getHARegionQueue().getStatistics().getEventsRemoved());
- cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
- "getNumVoidRemovals() " + ccp.getHARegionQueue().getStatistics().getNumVoidRemovals());
- assertEquals(ccp.getQueueSize(), ccp.getQueueSizeStat());
+ Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+ CacheClientNotifier ccn = CacheClientNotifier.getInstance();
+ CacheClientProxy ccp = ccn.getClientProxies().iterator().next();
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getQueueSize() " + ccp.getQueueSize());
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
+ "getQueueSizeStat() " + ccp.getQueueSizeStat());
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
+ "getEventsEnqued() " + ccp.getHARegionQueue().getStatistics().getEventsEnqued());
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
+ "getEventsDispatched() " + ccp.getHARegionQueue().getStatistics().getEventsDispatched());
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
+ "getEventsRemoved() " + ccp.getHARegionQueue().getStatistics().getEventsRemoved());
+ cache.getLoggerI18n().info(LocalizedStrings.DEBUG,
+ "getNumVoidRemovals() " + ccp.getHARegionQueue().getStatistics().getNumVoidRemovals());
+ assertEquals("The queue size did not match the stat value", ccp.getQueueSize(),
+ ccp.getQueueSizeStat());
+ });
}
}