You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by pr...@apache.org on 2018/01/10 20:05:59 UTC
[geode] branch develop updated: GEODE-4225: Extend
ClusterStartupRule to specify member / client version.
This is an automated email from the ASF dual-hosted git repository.
prhomberg 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 7d7e1da GEODE-4225: Extend ClusterStartupRule to specify member / client version.
7d7e1da is described below
commit 7d7e1dad589fc21716b5f952cb0167af89a2af30
Author: Patrick Rhomberg <Pu...@users.noreply.github.com>
AuthorDate: Wed Jan 10 12:05:55 2018 -0800
GEODE-4225: Extend ClusterStartupRule to specify member / client version.
* GEODE-4225: Extend ClusterStartupRule to specify member / client version.
* Correct typo: "Embeded" -> "Embedded"
* Reorder class to resemble call heirarchy
---
.../commands/ExportLogsOnServerManagerDUnit.java | 2 +-
.../geode/test/dunit/rules/ClusterStartupRule.java | 171 +++++++++++++--------
...tartupRuleCanSpecifyOlderVersionsDUnitTest.java | 101 ++++++++++++
.../cli/commands/ExportConfigCommandDUnitTest.java | 2 +-
4 files changed, 210 insertions(+), 66 deletions(-)
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index 6a6901e..626909f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -61,7 +61,7 @@ public class ExportLogsOnServerManagerDUnit {
@Test
public void testExportWithPeerLocator() throws Exception {
- MemberVM server0 = lsRule.startServerAsEmbededLocator(0);
+ MemberVM server0 = lsRule.startServerAsEmbeddedLocator(0);
lsRule.startServerVM(1, server0.getEmbeddedLocatorPort());
gfshConnector.connect(server0.getEmbeddedLocatorPort(), GfshCommandRule.PortType.locator);
gfshConnector.executeAndAssertThat("export logs").statusIsSuccess();
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 89029c6..dc79bea 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
@@ -45,6 +45,7 @@ import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.security.templates.UserPasswordAuthInit;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.standalone.DUnitLauncher;
+import org.apache.geode.test.dunit.standalone.VersionManager;
import org.apache.geode.test.junit.rules.ClientCacheRule;
import org.apache.geode.test.junit.rules.Locator;
import org.apache.geode.test.junit.rules.LocatorStarterRule;
@@ -140,7 +141,7 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
MemberStarterRule.disconnectDSIfAny();
// stop all the clientsVM before stop all the memberVM
- occupiedVMs.values().stream().forEach(x -> x.stopVM(true));
+ occupiedVMs.values().forEach(x -> x.stopVM(true));
if (useTempWorkingDir()) {
tempWorkingDir.delete();
@@ -149,25 +150,14 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
}
}
- public MemberVM startLocatorVM(int index) throws Exception {
- return startLocatorVM(index, new Properties());
- }
-
- public MemberVM startLocatorVM(int index, int... locatorPort) throws Exception {
- Properties properties = new Properties();
- String locators = Arrays.stream(locatorPort).mapToObj(i -> "localhost[" + i + "]")
- .collect(Collectors.joining(","));
- properties.setProperty(LOCATORS, locators);
- return startLocatorVM(index, properties);
- }
-
/**
* Starts a locator instance with the given configuration properties inside
* {@code getHost(0).getVM(index)}.
*
* @return VM locator vm
*/
- public MemberVM startLocatorVM(int index, Properties specifiedProperties) throws Exception {
+ public MemberVM startLocatorVM(int index, Properties specifiedProperties, String version)
+ throws Exception {
Properties properties = new Properties();
properties.putAll(specifiedProperties);
@@ -175,7 +165,7 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
properties.putIfAbsent(NAME, defaultName);
String name = properties.getProperty(NAME);
- VM locatorVM = getVM(index);
+ VM locatorVM = getVM(index, version);
Locator locator = locatorVM.invoke(() -> {
memberStarter = new LocatorStarterRule();
LocatorStarterRule locatorStarter = (LocatorStarterRule) memberStarter;
@@ -195,29 +185,27 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return memberVM;
}
- public MemberVM startServerVM(int index) throws IOException {
- return startServerVM(index, new Properties(), -1);
- }
-
- public MemberVM startServerVM(int index, int locatorPort) throws IOException {
- return startServerVM(index, new Properties(), locatorPort);
+ public MemberVM startLocatorVM(int index, Properties specifiedProperties) throws Exception {
+ return startLocatorVM(index, specifiedProperties, VersionManager.CURRENT_VERSION);
}
- public MemberVM startServerVM(int index, String group, int locatorPort) throws IOException {
+ public MemberVM startLocatorVM(int index, int... locatorPort) throws Exception {
Properties properties = new Properties();
- properties.put(GROUPS, group);
- return startServerVM(index, properties, locatorPort);
+ String locators = Arrays.stream(locatorPort).mapToObj(i -> "localhost[" + i + "]")
+ .collect(Collectors.joining(","));
+ properties.setProperty(LOCATORS, locators);
+ return startLocatorVM(index, properties);
}
- public MemberVM startServerVM(int index, Properties properties) throws IOException {
- return startServerVM(index, properties, -1);
+ public MemberVM startLocatorVM(int index) throws Exception {
+ return startLocatorVM(index, new Properties());
}
/**
* Starts a cache server with given properties
*/
- public MemberVM startServerVM(int index, Properties specifiedProperties, int locatorPort)
- throws IOException {
+ public MemberVM startServerVM(int index, Properties specifiedProperties, int locatorPort,
+ String version) throws IOException {
Properties properties = new Properties();
properties.putAll(specifiedProperties);
@@ -225,7 +213,7 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
properties.putIfAbsent(NAME, defaultName);
String name = properties.getProperty(NAME);
- VM serverVM = getVM(index);
+ VM serverVM = getVM(index, version);
Server server = serverVM.invoke(() -> {
memberStarter = new ServerStarterRule();
ServerStarterRule serverStarter = (ServerStarterRule) memberStarter;
@@ -246,23 +234,55 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return memberVM;
}
- public MemberVM startServerAsJmxManager(int index) throws IOException {
- return startServerAsJmxManager(index, new Properties());
+ public MemberVM startServerVM(int index, Properties specifiedProperties, int locatorPort)
+ throws IOException {
+ return startServerVM(index, specifiedProperties, locatorPort, VersionManager.CURRENT_VERSION);
}
+ public MemberVM startServerVM(int index, String group, int locatorPort) throws IOException {
+ Properties properties = new Properties();
+ properties.put(GROUPS, group);
+ return startServerVM(index, properties, locatorPort);
+ }
+
+ public MemberVM startServerVM(int index, int locatorPort) throws IOException {
+ return startServerVM(index, new Properties(), locatorPort);
+ }
+
+ public MemberVM startServerVM(int index, Properties properties) throws IOException {
+ return startServerVM(index, properties, -1);
+ }
+
+ public MemberVM startServerVM(int index) throws IOException {
+ return startServerVM(index, new Properties(), -1);
+ }
+
+ /**
+ * Starts a cache server with given properties, plus an available port for a JMX manager
+ */
public MemberVM startServerAsJmxManager(int index, Properties properties) throws IOException {
properties.setProperty(JMX_MANAGER_PORT, AvailablePortHelper.getRandomAvailableTCPPort() + "");
return startServerVM(index, properties, -1);
}
- public MemberVM startServerAsEmbededLocator(int index) throws IOException {
- return startServerAsEmbededLocator(index, new Properties());
+ public MemberVM startServerAsJmxManager(int index) throws IOException {
+ return startServerAsJmxManager(index, new Properties());
}
- public MemberVM startServerAsEmbededLocator(int index, Properties properties) throws IOException {
- String name = "server-" + index;
+ /**
+ * Starts a cache server with given properties. Additionally, start the server with a JMX manager
+ * and embedded locator.
+ */
+ public MemberVM startServerAsEmbeddedLocator(int index, Properties specifiedProperties,
+ String version) throws IOException {
+ Properties properties = new Properties();
+ properties.putAll(specifiedProperties);
- VM serverVM = getVM(index);
+ String defaultName = "server-" + index;
+ properties.putIfAbsent(NAME, defaultName);
+ String name = properties.getProperty(NAME);
+
+ VM serverVM = getVM(index, version);
Server server = serverVM.invoke(() -> {
memberStarter = new ServerStarterRule();
ServerStarterRule serverStarter = (ServerStarterRule) memberStarter;
@@ -284,17 +304,43 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return memberVM;
}
- public void stopVM(int index) {
- stopVM(index, true);
+ public MemberVM startServerAsEmbeddedLocator(int index, Properties properties)
+ throws IOException {
+ return startServerAsEmbeddedLocator(index, properties, VersionManager.CURRENT_VERSION);
}
- public void stopVM(int index, boolean cleanWorkingDir) {
- VMProvider member = occupiedVMs.get(index);
+ public MemberVM startServerAsEmbeddedLocator(int index) throws IOException {
+ return startServerAsEmbeddedLocator(index, new Properties());
+ }
- if (member == null)
- return;
+ /**
+ * Starts a client with the given properties, configuring the cacheFactory with the provided
+ * Consumer
+ */
+ public ClientVM startClientVM(int index, Properties properties,
+ Consumer<ClientCacheFactory> cacheFactorySetup, String clientVersion) throws Exception {
+ VM client = getVM(index, clientVersion);
+ Exception error = client.invoke(() -> {
+ clientCacheRule =
+ new ClientCacheRule().withProperties(properties).withCacheSetup(cacheFactorySetup);
+ try {
+ clientCacheRule.before();
+ return null;
+ } catch (Exception e) {
+ return e;
+ }
+ });
+ if (error != null) {
+ throw error;
+ }
+ ClientVM clientVM = new ClientVM(client);
+ occupiedVMs.put(index, clientVM);
+ return clientVM;
+ }
- member.stopVM(cleanWorkingDir);
+ public ClientVM startClientVM(int index, Properties properties,
+ Consumer<ClientCacheFactory> cacheFactorySetup) throws Exception {
+ return startClientVM(index, properties, cacheFactorySetup, VersionManager.CURRENT_VERSION);
}
public ClientVM startClientVM(int index, String username, String password,
@@ -314,26 +360,6 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return startClientVM(index, props, consumer);
}
- public ClientVM startClientVM(int index, Properties properties,
- Consumer<ClientCacheFactory> cacheFactorySetup) throws Exception {
- VM client = getVM(index);
- Exception error = client.invoke(() -> {
- clientCacheRule =
- new ClientCacheRule().withProperties(properties).withCacheSetup(cacheFactorySetup);
- try {
- clientCacheRule.before();
- return null;
- } catch (Exception e) {
- return e;
- }
- });
- if (error != null) {
- throw error;
- }
- ClientVM clientVM = new ClientVM(client);
- occupiedVMs.put(index, clientVM);
- return clientVM;
- }
/**
* Returns the {@link Member} running inside the VM with the specified {@code index}
@@ -342,8 +368,25 @@ public class ClusterStartupRule extends ExternalResource implements Serializable
return (MemberVM) occupiedVMs.get(index);
}
+ public VM getVM(int index, String version) {
+ return getHost(0).getVM(version, index);
+ }
+
public VM getVM(int index) {
- return getHost(0).getVM(index);
+ return getVM(index, VersionManager.CURRENT_VERSION);
+ }
+
+ public void stopVM(int index) {
+ stopVM(index, true);
+ }
+
+ public void stopVM(int index, boolean cleanWorkingDir) {
+ VMProvider member = occupiedVMs.get(index);
+
+ if (member == null)
+ return;
+
+ member.stopVM(cleanWorkingDir);
}
public TemporaryFolder getTempWorkingDir() {
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/tests/ClusterStartupRuleCanSpecifyOlderVersionsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/tests/ClusterStartupRuleCanSpecifyOlderVersionsDUnitTest.java
new file mode 100644
index 0000000..2354aa7
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/tests/ClusterStartupRuleCanSpecifyOlderVersionsDUnitTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.geode.test.dunit.rules.tests;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Properties;
+import java.util.function.Consumer;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.client.ClientCacheFactory;
+import org.apache.geode.internal.GemFireVersion;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.dunit.standalone.VersionManager;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+
+@Category(DistributedTest.class)
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class ClusterStartupRuleCanSpecifyOlderVersionsDUnitTest {
+ @Parameterized.Parameter
+ public String version;
+
+ @Parameterized.Parameters(name = "version={0}")
+ public static List<String> versions() {
+ return VersionManager.getInstance().getVersionsWithoutCurrent();
+ }
+
+ @Rule
+ public ClusterStartupRule csRule = new ClusterStartupRule();
+
+ @Test
+ public void locatorVersioningTest() throws Exception {
+ MemberVM locator = csRule.startLocatorVM(0, new Properties(), version);
+ String locatorVMVersion = locator.getVM().getVersion();
+ String locatorActualVersion = locator.invoke(GemFireVersion::getGemFireVersion);
+ assertThat(locatorVMVersion).isEqualTo(version);
+ assertThat(locatorActualVersion).isEqualTo(getDottedVersionString(version));
+ }
+
+ @Test
+ public void serverVersioningTest() throws Exception {
+ MemberVM locator = csRule.startLocatorVM(0, new Properties(), version);
+ String locatorVMVersion = locator.getVM().getVersion();
+ String locatorActualVersion = locator.invoke(GemFireVersion::getGemFireVersion);
+ assertThat(locatorVMVersion).isEqualTo(version);
+ assertThat(locatorActualVersion).isEqualTo(getDottedVersionString(version));
+ }
+
+ @Test
+ public void serverWithEmbeddedLocatorVersioningTest() throws Exception {
+ MemberVM locator = csRule.startServerAsEmbeddedLocator(0, new Properties(), version);
+ String locatorVMVersion = locator.getVM().getVersion();
+ String locatorActualVersion = locator.invoke(GemFireVersion::getGemFireVersion);
+ assertThat(locatorVMVersion).isEqualTo(version);
+ assertThat(locatorActualVersion).isEqualTo(getDottedVersionString(version));
+ }
+
+ @Test
+ public void clientVersioningTest() throws Exception {
+ Consumer<ClientCacheFactory> consumer = (Serializable & Consumer<ClientCacheFactory>) cf -> {
+ };
+ ClientVM locator = csRule.startClientVM(0, new Properties(), consumer, version);
+ String locatorVMVersion = locator.getVM().getVersion();
+ String locatorActualVersion = locator.invoke(GemFireVersion::getGemFireVersion);
+ assertThat(locatorVMVersion).isEqualTo(version);
+ assertThat(locatorActualVersion).isEqualTo(getDottedVersionString(version));
+ }
+
+ private static String getDottedVersionString(String vmVersionShorthand) throws Exception {
+ if (vmVersionShorthand.equals("100")) {
+ return "1.0.0-incubating";
+ } else {
+ return vmVersionShorthand.charAt(0) + "." + vmVersionShorthand.charAt(1) + "."
+ + vmVersionShorthand.charAt(2);
+ }
+ }
+}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
index 7db2faf..8196241 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
@@ -56,7 +56,7 @@ public class ExportConfigCommandDUnitTest {
Properties props = new Properties();
props.setProperty(GROUPS, "Group1");
- MemberVM server0 = startupRule.startServerAsEmbededLocator(0, props);
+ MemberVM server0 = startupRule.startServerAsEmbeddedLocator(0, props);
if (connectOverHttp) {
gfsh.connectAndVerify(server0.getHttpPort(), GfshCommandRule.PortType.http);
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].