You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2018/03/16 22:13:50 UTC
[geode] 04/08: GEODE-4789: add VM count constructor to
ClusterStartupRule
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 71d1d8a29a90f98f1017cb3714151b8acc22b8c6
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Wed Mar 14 14:49:59 2018 -0700
GEODE-4789: add VM count constructor to ClusterStartupRule
Any DUnit test that uses more than 4 VMs should always specify
the total VM count via the ClusterStartupRule constructor so
that "bundled" Rules such as DistributedRestoreSystemProperties
which has a before that needs to know about all the VMs can
be setup properly.
---
.../geode/test/dunit/rules/ClusterStartupRule.java | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ClusterStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ClusterStartupRule.java
index cf27041..31cd483 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ClusterStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ClusterStartupRule.java
@@ -13,12 +13,12 @@
* the License.
*
*/
-
package org.apache.geode.test.dunit.rules;
import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIENT_AUTH_INIT;
import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.standalone.DUnitLauncher.NUM_VMS;
import java.io.File;
import java.io.Serializable;
@@ -38,6 +38,7 @@ import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.security.templates.UserPasswordAuthInit;
+import org.apache.geode.test.dunit.Host;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.standalone.DUnitLauncher;
import org.apache.geode.test.dunit.standalone.VersionManager;
@@ -50,12 +51,15 @@ import org.apache.geode.test.junit.rules.Server;
import org.apache.geode.test.junit.rules.ServerStarterRule;
import org.apache.geode.test.junit.rules.VMProvider;
-
/**
* A rule to help you start locators and servers inside of a
* <a href="https://cwiki.apache.org/confluence/display/GEODE/Distributed-Unit-Tests">DUnit
* test</a>. This rule will start Servers and Locators inside of the four remote {@link VM}s created
* by the DUnit framework.
+ *
+ * <p>
+ * If you use this Rule in any test that uses more than the default of 4 VMs in DUnit, then
+ * you must specify the total number of VMs via the {@link #ClusterStartupRule(int)} constructor.
*/
public class ClusterStartupRule extends ExternalResource implements Serializable {
/**
@@ -76,7 +80,9 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return ((ServerStarterRule) memberStarter).getServer();
}
- private DistributedRestoreSystemProperties restoreSystemProperties =
+ private final int vmCount;
+
+ private final DistributedRestoreSystemProperties restoreSystemProperties =
new DistributedRestoreSystemProperties();
private Map<Integer, VMProvider> occupiedVMs;
@@ -84,6 +90,11 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
private boolean logFile = false;
public ClusterStartupRule() {
+ this(NUM_VMS);
+ }
+
+ public ClusterStartupRule(final int vmCount) {
+ this.vmCount = vmCount;
DUnitLauncher.launchIfNeeded();
}
@@ -101,6 +112,9 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
@Override
protected void before() throws Throwable {
+ for (int i = 0; i < vmCount; i++) {
+ Host.getHost(0).getVM(i);
+ }
restoreSystemProperties.before();
occupiedVMs = new HashMap<>();
}
--
To stop receiving notification emails like this one, please contact
klund@apache.org.