You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2018/08/31 22:14:42 UTC
[geode] branch develop updated: GEODE-5481: Extended wait duration
in security tests
This is an automated email from the ASF dual-hosted git repository.
upthewaterspout 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 b9fdce8 GEODE-5481: Extended wait duration in security tests
b9fdce8 is described below
commit b9fdce814fb02d46b876a44d6a321ed3d6599a16
Author: Dan Smith <up...@apache.org>
AuthorDate: Fri Aug 31 10:30:09 2018 -0700
GEODE-5481: Extended wait duration in security tests
CLientAUthorizationDUnitTest was only waiting 7 seconds for an event to
occur. Switching to Awaitility and waiting for 5 minutes.
Co-authored-by: Dale Emery <de...@pivotal.io>
---
.../security/ClientAuthorizationTestCase.java | 16 ++++++----
.../apache/geode/security/SecurityTestUtils.java | 34 ++++------------------
2 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/geode-dunit/src/main/java/org/apache/geode/security/ClientAuthorizationTestCase.java b/geode-dunit/src/main/java/org/apache/geode/security/ClientAuthorizationTestCase.java
index 2bfae24..6117d55 100644
--- a/geode-dunit/src/main/java/org/apache/geode/security/ClientAuthorizationTestCase.java
+++ b/geode-dunit/src/main/java/org/apache/geode/security/ClientAuthorizationTestCase.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.security;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_ACCESSOR;
import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_ACCESSOR_PP;
import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTHENTICATOR;
@@ -29,7 +31,6 @@ import static org.apache.geode.security.SecurityTestUtils.concatProperties;
import static org.apache.geode.security.SecurityTestUtils.getCache;
import static org.apache.geode.security.SecurityTestUtils.getLocalValue;
import static org.apache.geode.security.SecurityTestUtils.registerExpectedExceptions;
-import static org.apache.geode.security.SecurityTestUtils.waitForCondition;
import static org.apache.geode.test.dunit.Assert.assertEquals;
import static org.apache.geode.test.dunit.Assert.assertFalse;
import static org.apache.geode.test.dunit.Assert.assertNotNull;
@@ -38,6 +39,7 @@ import static org.apache.geode.test.dunit.Assert.assertTrue;
import static org.apache.geode.test.dunit.Assert.fail;
import static org.apache.geode.test.dunit.Host.getHost;
import static org.apache.geode.test.dunit.Wait.waitForCriterion;
+import static org.awaitility.Awaitility.waitAtMost;
import java.util.ArrayList;
import java.util.Arrays;
@@ -282,14 +284,16 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
if ((flags & OpFlags.NO_CREATE_SUBREGION) > 0) {
if ((flags & OpFlags.CHECK_NOREGION) > 0) {
// Wait for some time for DRF update to come
- waitForCondition(() -> getSubregion() == null);
+ waitAtMost(5, MINUTES).pollInterval(200, MILLISECONDS)
+ .until(() -> getSubregion() == null);
subregion = getSubregion();
assertNull(subregion);
return;
} else {
// Wait for some time for DRF update to come
- waitForCondition(() -> getSubregion() != null);
+ waitAtMost(5, MINUTES).pollInterval(200, MILLISECONDS)
+ .until(() -> getSubregion() != null);
subregion = getSubregion();
assertNotNull(subregion);
}
@@ -303,7 +307,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
} else if ((flags & OpFlags.CHECK_NOREGION) > 0) {
// Wait for some time for region destroy update to come
- waitForCondition(() -> getRegion() == null);
+ waitAtMost(5, MINUTES).pollInterval(200, MILLISECONDS)
+ .until(() -> getRegion() == null);
region = getRegion();
assertNull(region);
return;
@@ -403,7 +408,8 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
return this;
}
}.init(region);
- waitForCondition(condition);
+ waitAtMost(5, MINUTES).pollInterval(200, MILLISECONDS)
+ .until(condition);
value = getLocalValue(region, key);
diff --git a/geode-dunit/src/main/java/org/apache/geode/security/SecurityTestUtils.java b/geode-dunit/src/main/java/org/apache/geode/security/SecurityTestUtils.java
index 0f5e0fa..d8ceeb3 100644
--- a/geode-dunit/src/main/java/org/apache/geode/security/SecurityTestUtils.java
+++ b/geode-dunit/src/main/java/org/apache/geode/security/SecurityTestUtils.java
@@ -14,6 +14,8 @@
*/
package org.apache.geode.security;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.geode.cache30.ClientServerTestCase.configureConnectionPoolWithNameAndFactory;
import static org.apache.geode.cache30.ClientServerTestCase.disconnectFromDS;
import static org.apache.geode.distributed.ConfigurationProperties.DURABLE_CLIENT_ID;
@@ -33,7 +35,7 @@ import static org.apache.geode.test.dunit.Assert.fail;
import static org.apache.geode.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
import static org.apache.geode.test.dunit.NetworkUtils.getIPLiteral;
-import static org.apache.geode.test.dunit.Wait.waitForCriterion;
+import static org.awaitility.Awaitility.waitAtMost;
import java.io.File;
import java.io.FileOutputStream;
@@ -49,7 +51,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.Callable;
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
@@ -95,7 +96,6 @@ import org.apache.geode.pdx.PdxReader;
import org.apache.geode.pdx.PdxSerializable;
import org.apache.geode.pdx.PdxWriter;
import org.apache.geode.security.templates.UsernamePrincipal;
-import org.apache.geode.test.dunit.WaitCriterion;
import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
/**
@@ -600,31 +600,6 @@ public class SecurityTestUtils {
return cache;
}
- protected static void waitForCondition(final Callable<Boolean> condition) {
- waitForCondition(condition, 100, 120);
- }
-
- protected static void waitForCondition(final Callable<Boolean> condition, final int sleepMillis,
- final int numTries) {
- WaitCriterion ev = new WaitCriterion() {
- @Override
- public boolean done() {
- try {
- return condition.call();
- } catch (Exception e) {
- fail("Unexpected exception", e);
- }
- return false; // NOTREACHED
- }
-
- @Override
- public String description() {
- return null;
- }
- };
- waitForCriterion(ev, sleepMillis * numTries, 200, true);
- }
-
protected static Object getLocalValue(final Region region, final Object key) {
Region.Entry entry = region.getEntry(key);
if (entry != null) {
@@ -1645,7 +1620,8 @@ public class SecurityTestUtils {
for (int index = 0; index < num; ++index) {
final String key = KEYS[index];
final String expectedVal = vals[index];
- waitForCondition(() -> expectedVal.equals(getLocalValue(region, key)), 1000, 30 / num);
+ waitAtMost(5, MINUTES).pollInterval(200, MILLISECONDS)
+ .until(() -> expectedVal.equals(getLocalValue(region, key)));
}
for (int index = 0; index < num; ++index) {