You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2017/04/27 18:47:49 UTC
[14/40] geode git commit: GEODE-1228:
ClientAuthzObjectModDUnitTest.testAllOpsObjectModWithFailover
GEODE-1228: ClientAuthzObjectModDUnitTest.testAllOpsObjectModWithFailover
This test was getting periodic BindExceptions starting a cache server with
ports from AvailablePortHelper. I've modified it to use wildcard binds
in the servers and have the clients use the DUnit locator to find the
servers.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/53f5c960
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/53f5c960
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/53f5c960
Branch: refs/heads/feature/GEM-1299
Commit: 53f5c960149150d65f776a46f92cd4f97cc27803
Parents: 23658cb
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Tue Apr 25 09:06:48 2017 -0700
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Tue Apr 25 09:09:11 2017 -0700
----------------------------------------------------------------------
.../org/apache/geode/cache30/ClientServerTestCase.java | 9 +++++++--
.../geode/security/ClientAuthorizationTestCase.java | 6 +++---
.../java/org/apache/geode/security/SecurityTestUtils.java | 8 ++++++++
.../geode/security/ClientAuthzObjectModDUnitTest.java | 10 +++++-----
4 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/53f5c960/geode-core/src/test/java/org/apache/geode/cache30/ClientServerTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/ClientServerTestCase.java b/geode-core/src/test/java/org/apache/geode/cache30/ClientServerTestCase.java
index b972522..4f61880 100644
--- a/geode-core/src/test/java/org/apache/geode/cache30/ClientServerTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/cache30/ClientServerTestCase.java
@@ -188,12 +188,17 @@ public abstract class ClientServerTestCase extends JUnit4CacheTestCase {
connectionsPerServer, serverGroup, poolName, pf, -1, -1, false, -2, -1);
}
+ /**
+ * this method creates a client connection pool and configures it. If the ports array is not empty
+ * it is used to configure the client pool. Otherwise the pool is configured to use the dunit
+ * locator.
+ */
public static Pool configureConnectionPoolWithNameAndFactory(AttributesFactory factory,
String host, int[] ports, boolean establish, int redundancy, int connectionsPerServer,
String serverGroup, String poolName, PoolFactory pf, int pingInterval, int idleTimeout,
boolean threadLocalCnxs, int lifetimeTimeout, int statisticInterval) {
- if (AUTO_LOAD_BALANCE) {
+ if (AUTO_LOAD_BALANCE || ports.length == 0) {
pf.addLocator(host, DistributedTestUtils.getDUnitLocatorPort());
} else {
for (int z = 0; z < ports.length; z++) {
@@ -202,7 +207,7 @@ public abstract class ClientServerTestCase extends JUnit4CacheTestCase {
}
// TODO - probably should pass in minConnections rather than connecions per server
- if (connectionsPerServer != -1) {
+ if (connectionsPerServer != -1 && ports != null) {
pf.setMinConnections(connectionsPerServer * ports.length);
}
if (threadLocalCnxs) {
http://git-wip-us.apache.org/repos/asf/geode/blob/53f5c960/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java
index 6e4c3be..b76c4fd 100644
--- a/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/security/ClientAuthorizationTestCase.java
@@ -767,12 +767,12 @@ public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestC
boolean setupDynamicRegionFactory = (opFlags & OpFlags.ENABLE_DRF) > 0;
if (useThisVM) {
- SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps,
- new int[] {port1, port2}, 0, setupDynamicRegionFactory, NO_EXCEPTION);
+ SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, 0,
+ setupDynamicRegionFactory, NO_EXCEPTION);
} else {
clientVM.invoke("SecurityTestUtils.createCacheClientWithDynamicRegion",
() -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps,
- javaProps, new int[] {port1, port2}, 0, setupDynamicRegionFactory, NO_EXCEPTION));
+ javaProps, 0, setupDynamicRegionFactory, NO_EXCEPTION));
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/53f5c960/geode-core/src/test/java/org/apache/geode/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityTestUtils.java b/geode-core/src/test/java/org/apache/geode/security/SecurityTestUtils.java
index d420163..f6febb3 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityTestUtils.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityTestUtils.java
@@ -320,6 +320,14 @@ public final class SecurityTestUtils {
setupDynamicRegionFactory, false, expectedResult);
}
+ /** create a client cache using the dunit locator to find servers */
+ protected static void createCacheClientWithDynamicRegion(final String authInitModule,
+ final Properties authProps, final Properties javaProps, final int numConnections,
+ final boolean setupDynamicRegionFactory, final int expectedResult) {
+ createCacheClient(authInitModule, authProps, javaProps, new int[0], numConnections,
+ setupDynamicRegionFactory, false, expectedResult);
+ }
+
// 4
protected static void createCacheClient(final String authInitModule, final Properties authProps,
final Properties javaProps, final int[] ports, final int numConnections,
http://git-wip-us.apache.org/repos/asf/geode/blob/53f5c960/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
old mode 100644
new mode 100755
index 3be6dde..dd50467
--- a/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/security/ClientAuthzObjectModDUnitTest.java
@@ -98,7 +98,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
// Get ports for the servers
int[] portsList = AvailablePortHelper.getRandomAvailableTCPPorts(2);
- int port1 = portsList[0];
+ int port1 = 0; // portsList[0];
int port2 = portsList[1];
// Perform all the ops on the clients
@@ -113,14 +113,14 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
// End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
- server1.invoke("createCacheServer",
- () -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps));
+ port1 = server1.invoke("createCacheServer",
+ () -> createCacheServer(getLocatorPort(), 0, serverProps, javaProps));
server2.invoke("closeCache", () -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
- server2.invoke("createCacheServer",
- () -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps));
+ port2 = server2.invoke("createCacheServer",
+ () -> createCacheServer(getLocatorPort(), 0, serverProps, javaProps));
server1.invoke("closeCache", () -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
}