You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2017/04/05 01:22:26 UTC
geode git commit: GEM-1351: Move a test to the open side and fix the
other tests
Repository: geode
Updated Branches:
refs/heads/develop 99e61ffa0 -> 82034c902
GEM-1351: Move a test to the open side and fix the other tests
* move ImportClusterConfigDistributedTest to open side
* remove @Ignore from other two tests.
Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/82034c90
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/82034c90
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/82034c90
Branch: refs/heads/develop
Commit: 82034c902b542478826a9ac01b8a97301144c73d
Parents: 99e61ff
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Mon Apr 3 14:40:07 2017 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Tue Apr 4 18:19:45 2017 -0700
----------------------------------------------------------------------
.../ImportClusterConfigDistributedTest.java | 110 +++++++++++++++++++
.../dunit/rules/GfshShellConnectionRule.java | 4 +-
.../dunit/rules/LocatorServerStartupRule.java | 5 +
3 files changed, 117 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geode/blob/82034c90/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
new file mode 100644
index 0000000..4274d67
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.management.internal.configuration;
+
+import static org.apache.geode.cache.DataPolicy.PARTITION;
+import static org.apache.geode.cache.DataPolicy.REPLICATE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
+import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+@Category(DistributedTest.class)
+public class ImportClusterConfigDistributedTest {
+
+ private static final String EXPORTED_CLUSTER_CONFIG_ZIP_NAME = "clusterConfiguration.zip";
+
+ private File exportedClusterConfig;
+ private MemberVM locator, server;
+
+ @Rule
+ public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
+
+ @Rule
+ public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+
+ @Before
+ public void exportClusterConfig() throws Exception {
+ locator = lsRule.startLocatorVM(0);
+ server = lsRule.startServerVM(1, locator.getPort());
+
+ gfsh.connectAndVerify(locator);
+
+ gfsh.executeAndVerifyCommand("create region --name=replicateRegion --type=REPLICATE");
+ gfsh.executeAndVerifyCommand("create region --name=partitionRegion --type=PARTITION");
+
+
+ server.invoke(ImportClusterConfigDistributedTest::validateServerIsUsingClusterConfig);
+
+ this.exportedClusterConfig =
+ new File(lsRule.getTempFolder().getRoot(), EXPORTED_CLUSTER_CONFIG_ZIP_NAME);
+
+
+ gfsh.executeAndVerifyCommand(
+ "export cluster-configuration --zip-file-name=" + exportedClusterConfig.getCanonicalPath());
+
+ lsRule.stopMember(0);
+
+ lsRule.stopMember(1);
+
+ assertThat(this.exportedClusterConfig).exists();
+ assertThat(this.exportedClusterConfig.length()).isGreaterThan(100);
+ }
+
+
+ private static void validateServerIsUsingClusterConfig() {
+ Cache cache = CacheFactory.getAnyInstance();
+ assertThat(cache).isNotNull();
+
+ Region replicateRegion = cache.getRegion("replicateRegion");
+ assertThat(replicateRegion).isNotNull();
+ assertThat(replicateRegion.getAttributes().getDataPolicy()).isEqualTo(REPLICATE);
+
+ Region partitionRegion = cache.getRegion("partitionRegion");
+ assertThat(partitionRegion).isNotNull();
+
+ assertThat(partitionRegion.getAttributes().getDataPolicy()).isEqualTo(PARTITION);
+ }
+
+
+ /**
+ * Start locator, import previously exported cluster-configuration and then start server.
+ */
+ @Test
+ public void startLocatorAndImportOldClusterConfigZip() throws Exception {
+ locator = lsRule.startLocatorVM(0);
+
+ gfsh.connectAndVerify(locator);
+ gfsh.executeAndVerifyCommand("import cluster-configuration --zip-file-name="
+ + this.exportedClusterConfig.getCanonicalPath());
+
+ server = lsRule.startServerVM(1, locator.getPort());
+
+ server.invoke(ImportClusterConfigDistributedTest::validateServerIsUsingClusterConfig);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/geode/blob/82034c90/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index d061859..bfb77e7 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -61,8 +61,6 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
public GfshShellConnectionRule() {
try {
temporaryFolder.create();
- this.gfsh = new HeadlessGfsh(getClass().getName(), 30,
- temporaryFolder.newFolder("gfsh_files").getAbsolutePath());
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
@@ -76,6 +74,8 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
@Override
protected void before(Description description) throws Throwable {
+ this.gfsh = new HeadlessGfsh(getClass().getName(), 30,
+ temporaryFolder.newFolder("gfsh_files").getAbsolutePath());
// do not auto connect if no port initialized
if (port < 0) {
return;
http://git-wip-us.apache.org/repos/asf/geode/blob/82034c90/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index 2d648bd..7350241 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -132,6 +132,11 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
return members[index];
}
+ public void stopMember(int index) {
+ MemberVM member = members[index];
+ member.invoke(this::cleanupVm);
+ }
+
/**
* Starts a cache server with given properties
*/