This is an automated email from the ASF dual-hosted git repository.
jinmeiliao 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 42485b6 GEODE-4625: rework name collision check logic and add more
tests (#1505)
42485b6 is described below
commit 42485b6faf204c621f7a31aa100c19ed4e0c2d10
Author: jinmeiliao <[email protected]>
AuthorDate: Wed Feb 28 08:20:35 2018 -0800
GEODE-4625: rework name collision check logic and add more tests (#1505)
* GEODE-4625: rework name collision check logic and add more tests
---
.../geode/management/DistributedRegionMXBean.java | 4 -
.../internal/cli/commands/CreateRegionCommand.java | 57 +++++++------
.../management/internal/cli/i18n/CliStrings.java | 5 +-
.../geode/redis/internal/RegionProvider.java | 8 +-
.../cli/commands/CreateRegionCommandDUnitTest.java | 96 ++++++++++++++++++++--
.../CreateRegionCommandIntegrationTest.java | 4 +-
.../cli/commands/CreateRegionCommandTest.java | 1 +
...est.java => CreateRegionSecurityDUnitTest.java} | 31 +++++--
.../commands/DestroyRegionCommandDUnitTest.java | 13 +--
9 files changed, 156 insertions(+), 63 deletions(-)
diff --git
a/geode-core/src/main/java/org/apache/geode/management/DistributedRegionMXBean.java
b/geode-core/src/main/java/org/apache/geode/management/DistributedRegionMXBean.java
index 7a934e4..f1afbcb 100644
---
a/geode-core/src/main/java/org/apache/geode/management/DistributedRegionMXBean.java
+++
b/geode-core/src/main/java/org/apache/geode/management/DistributedRegionMXBean.java
@@ -40,20 +40,17 @@ public interface DistributedRegionMXBean {
/**
* Returns the number of members hosting/using the Region.
*/
- @ResourceOperation()
int getMemberCount();
/**
* Returns a list of names/IDs of the members hosting the Region.
*/
- @ResourceOperation()
String[] getMembers();
/**
* Returns the type (data policy) of the Region.
* CreateRegionCommand will use this attribute
*/
- @ResourceOperation()
String getRegionType();
/**
@@ -301,6 +298,5 @@ public interface DistributedRegionMXBean {
/**
* Returns the number of members whose entry count is 0.
*/
- @ResourceOperation()
int getEmptyNodes();
}
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
index a20488c..300b271 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
@@ -87,11 +87,8 @@ public class CreateRegionCommand implements GfshCommand {
@CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
optionContext = ConverterHint.MEMBERGROUP,
help = CliStrings.CREATE_REGION__GROUP__HELP) String[] groups,
- @CliOption(key = CliStrings.CREATE_REGION__SKIPIFEXISTS,
specifiedDefaultValue = "true",
- unspecifiedDefaultValue = "false",
- help = CliStrings.CREATE_REGION__SKIPIFEXISTS__HELP) boolean
skipIfExists,
- @CliOption(key = CliStrings.IFNOTEXISTS, specifiedDefaultValue = "true",
- unspecifiedDefaultValue = "false",
+ @CliOption(key = {CliStrings.IFNOTEXISTS,
CliStrings.CREATE_REGION__SKIPIFEXISTS},
+ specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
help = CliStrings.CREATE_REGION__IFNOTEXISTS__HELP) boolean
ifNotExists,
// the following should all be in alphabetical order according to
@@ -198,41 +195,49 @@ public class CreateRegionCommand implements GfshCommand {
InternalCache cache = getCache();
- // adding name collision check for regions created with regionShortcut only
+ /*
+ * Adding name collision check for regions created with regionShortcut
only.
+ * Regions can be categories as Proxy(replicate/partition),
replicate/partition, and local
+ * For concise purpose: we call existing region (E) and region to be
created (C)
+ */
DistributedRegionMXBean regionBean =
getManagementService().getDistributedRegionMXBean(regionPath);
if (regionBean != null && regionShortcut != null) {
- // when creating a non-proxy region and there is already a non empty node
- if (!regionShortcut.isProxy() && regionBean.getMemberCount() >
regionBean.getEmptyNodes()) {
+ String existingDataPolicy = regionBean.getRegionType();
+ // either C is local, or E is local or E and C are both non-proxy
regions. this is to make
+ // sure local, replicate or partition regions have unique names across
the entire cluster
+ if (regionShortcut.isLocal() || existingDataPolicy.equals("NORMAL")
+ || !regionShortcut.isProxy()
+ && (regionBean.getMemberCount() > regionBean.getEmptyNodes())) {
throw new EntityExistsException(
String.format("Region %s already exists on the cluster.",
regionPath), ifNotExists);
}
- // proxy regions can only be created on members not having this
regionName already defined
- if (regionShortcut.isProxy()) {
- Set<String> membersWithThisRegion =
- Arrays.stream(regionBean.getMembers()).collect(Collectors.toSet());
- Set<String> membersWithinGroup = findMembers(groups, null).stream()
- .map(DistributedMember::getName).collect(Collectors.toSet());
- if (!Collections.disjoint(membersWithinGroup, membersWithThisRegion)) {
- throw new EntityExistsException(String.format(
- "Region %s already exists on these members: %s. You can only
create "
- + "proxy regions with the same name on other members.",
- regionPath, StringUtils.join(membersWithThisRegion, ",")),
ifNotExists);
- }
- }
+ // after this, one of E and C is proxy region or both are proxy regions.
- // then check if the existing region's data policy is compatible
- if (regionShortcut.isPartition() &&
!regionBean.getRegionType().contains("PARTITION")) {
+ // we first make sure E and C have the compatible data policy
+ if (regionShortcut.isPartition() &&
!existingDataPolicy.contains("PARTITION")) {
throw new EntityExistsException("The existing region is not a
partitioned region",
ifNotExists);
}
- if (regionShortcut.isReplicate() &&
!(regionBean.getRegionType().equals("EMPTY")
- || regionBean.getRegionType().contains("REPLICATE"))) {
+ if (regionShortcut.isReplicate()
+ && !(existingDataPolicy.equals("EMPTY") ||
existingDataPolicy.contains("REPLICATE")
+ || existingDataPolicy.contains("PRELOADED"))) {
throw new EntityExistsException("The existing region is not a
replicate region",
ifNotExists);
}
+ // then we make sure E and C are on different members
+ Set<String> membersWithThisRegion =
+ Arrays.stream(regionBean.getMembers()).collect(Collectors.toSet());
+ Set<String> membersWithinGroup = findMembers(groups, null).stream()
+ .map(DistributedMember::getName).collect(Collectors.toSet());
+ if (!Collections.disjoint(membersWithinGroup, membersWithThisRegion)) {
+ throw new EntityExistsException(
+ String.format("Region %s already exists on these members: %s.",
regionPath,
+ StringUtils.join(membersWithThisRegion, ",")),
+ ifNotExists);
+ }
}
// validating the parent region
@@ -249,7 +254,7 @@ public class CreateRegionCommand implements GfshCommand {
// creating the RegionFunctionArgs
RegionFunctionArgs functionArgs = new RegionFunctionArgs();
functionArgs.setRegionPath(regionPath);
- functionArgs.setIfNotExists(ifNotExists || skipIfExists);
+ functionArgs.setIfNotExists(ifNotExists);
functionArgs.setStatisticsEnabled(statisticsEnabled);
functionArgs.setEntryExpirationIdleTime(entryExpirationIdleTime,
entryExpirationIdleTimeAction);
functionArgs.setEntryExpirationTTL(entryExpirationTTL,
entryExpirationTTLAction);
diff --git
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 4dd045a..fe8650c 100644
---
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -829,11 +829,8 @@ public class CliStrings {
public static final String CREATE_REGION__USEATTRIBUTESFROM__HELP =
"Name/Path of the region whose attributes should be duplicated when
creating this region. Deprecated: Since Geode 1.5, regions should be created
explicitly so that undesirable attributes are not copied inadvertently.";
public static final String CREATE_REGION__SKIPIFEXISTS = "skip-if-exists";
- public static final String CREATE_REGION__SKIPIFEXISTS__HELP =
- "Skip region creation if the region already exists. Deprecated: Since
Geode 1.5. Use --if-not-exists instead.";
- public static final String CREATE_REGION__IFNOTEXISTS = "if-not-exists";
public static final String CREATE_REGION__IFNOTEXISTS__HELP =
- "By default, an attempt to create a duplicate region is reported as an
error. If this option is specified without a value or is specified with a value
of true, then gfsh displays a \"Skipping...\" acknowledgement, but does not
throw an error.";
+ "By default, an attempt to create a duplicate region is reported as an
error. If this option is specified without a value or is specified with a value
of true, then gfsh displays a \"Skipping...\" acknowledgement, but does not
throw an error. Deprecated: the alias --skip-if-exists is deprecated since
Geode 1.5.";
public static final String CREATE_REGION__KEYCONSTRAINT = "key-constraint";
public static final String CREATE_REGION__KEYCONSTRAINT__HELP =
"Fully qualified class name of the objects allowed as region keys.
Ensures that keys for region entries are all of the same class.";
diff --git
a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
index 511a1c9..6e19e92 100644
---
a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
+++
b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
@@ -399,10 +399,10 @@ public class RegionProvider implements Closeable {
if (r != null)
return r;
do {
- Result result = createRegionCmd.createRegion(key, defaultRegionType,
null, null, true, true,
- null, null, null, null, null, null, null, null, false, false, true,
false, false, false,
- true, null, null, null, null, null, null, null, null, null, null,
null, null, null, false,
- null, null, null, null, null, null, null, null, null, null, null);
+ Result result = createRegionCmd.createRegion(key, defaultRegionType,
null, null, true, null,
+ null, null, null, null, null, null, null, false, false, true, false,
false, false, true,
+ null, null, null, null, null, null, null, null, null, null, null,
null, null, false, null,
+ null, null, null, null, null, null, null, null, null, null);
r = cache.getRegion(key);
if (result.getStatus() == Status.ERROR && r == null) {
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
index 9f0b18f..0778eed 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
@@ -332,7 +332,7 @@ public class CreateRegionCommandDUnitTest {
gfsh.executeAndAssertThat(
"create region --type=PARTITION_PROXY --group=group2 --name=" +
regionName).statusIsError()
- .containsOutput("You can only create proxy regions with the same name
on other members");
+ .containsOutput("The existing region is not a partitioned region");
}
@Test
@@ -350,7 +350,7 @@ public class CreateRegionCommandDUnitTest {
.statusIsError().containsOutput("Region /" + regionName + " already
exists on the cluster");
gfsh.executeAndAssertThat(
"create region --type=PARTITION_PROXY --group=group2 --name=" +
regionName).statusIsError()
- .containsOutput("You can only create proxy regions with the same name
on other members");
+ .containsOutput("The existing region is not a partitioned region");
}
@Test
@@ -361,16 +361,89 @@ public class CreateRegionCommandDUnitTest {
.statusIsSuccess().tableHasRowWithValues("Member", "server-1");
gfsh.executeAndAssertThat("create region --type=PARTITION --group=group2
--name=" + regionName)
.statusIsError().containsOutput("The existing region is not a
partitioned region");
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION_PROXY --group=group2 --name=" +
regionName).statusIsError()
+ .containsOutput("The existing region is not a partitioned region");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError();
+ }
+
+ @Test
+ public void startWithPartitionProxyThenReplicate() {
+ String regionName = testName.getMethodName();
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION_PROXY --group=group1 --name=" +
regionName)
+ .statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("The existing region is not a
replicate region");
+ gfsh.executeAndAssertThat(
+ "create region --type=REPLICATE_PROXY --group=group2 --name=" +
regionName).statusIsError()
+ .containsOutput("The existing region is not a replicate region");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError();
+ }
+
+ @Test
+ public void startWithLocalPersistent() {
+ String regionName = testName.getMethodName();
+ gfsh.executeAndAssertThat(
+ "create region --type=LOCAL_PERSISTENT --group=group1 --name=" +
regionName)
+ .statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --group=group2
--name=" + regionName)
+ .statusIsError()
+ .containsOutput("Region /startWithLocalPersistent already exists on
the cluster");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError()
+ .containsOutput("Region /startWithLocalPersistent already exists on
the cluster");
}
@Test
- public void startWithPartitionThenReplicateProxy() {
+ public void startWithReplicateHeapLRU() {
+ String regionName = testName.getMethodName();
+ gfsh.executeAndAssertThat(
+ "create region --type=REPLICATE_HEAP_LRU --group=group1 --name=" +
regionName)
+ .statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
+ gfsh.executeAndAssertThat(
+ "create region --type=REPLICATE_PROXY --group=group2 --name=" +
regionName)
+ .statusIsSuccess();
+ }
+
+ @Test
+ public void startWithReplicateThenPartition() {
+ String regionName = testName.getMethodName();
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --group=group1
--name=" + regionName)
+ .statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION_PROXY --group=group2 --name=" +
regionName).statusIsError()
+ .containsOutput("The existing region is not a partitioned region");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
+ gfsh.executeAndAssertThat(
+ "create region --type=REPLICATE_PROXY --group=group1 --name=" +
regionName).statusIsError()
+ .containsOutput("already exists on these members: server-1");
+ }
+
+ @Test
+ public void startWithPartitionThenReplicate() {
String regionName = testName.getMethodName();
gfsh.executeAndAssertThat("create region --type=PARTITION --group=group1
--name=" + regionName)
.statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
gfsh.executeAndAssertThat(
"create region --type=REPLICATE_PROXY --group=group2 --name=" +
regionName).statusIsError()
.containsOutput("The existing region is not a replicate region");
+ gfsh.executeAndAssertThat("create region --type=LOCAL --group=group2
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on the cluster");
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION_PROXY --group=group1 --name=" +
regionName).statusIsError()
+ .containsOutput("already exists on these members: server-1");
}
@Test
@@ -379,16 +452,20 @@ public class CreateRegionCommandDUnitTest {
gfsh.executeAndAssertThat(
"create region --type=PARTITION_PROXY --group=group1 --name=" +
regionName)
.statusIsSuccess().tableHasRowWithValues("Member", "server-1");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --group=group1
--name=" + regionName)
+ .statusIsError().containsOutput("already exists on these members:
server-1");
gfsh.executeAndAssertThat("create region --type=PARTITION --group=group2
--name=" + regionName)
.statusIsSuccess().tableHasRowWithValues("Member", "server-2");
locator.waitTillRegionsAreReadyOnServers("/" + regionName, 2);
- // the following two should fail with name check on locator, not on server
gfsh.executeAndAssertThat("create region --type=PARTITION --group=group2
--name=" + regionName)
.statusIsError().containsOutput("Region /" + regionName + " already
exists on the cluster");
gfsh.executeAndAssertThat(
"create region --type=REPLICATE_PROXY --group=group2 --name=" +
regionName).statusIsError()
- .containsOutput("You can only create proxy regions with the same name
on other members");
+ .containsOutput("The existing region is not a replicate region");
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION_PROXY --group=group1 --name=" +
regionName).statusIsError()
+ .containsOutput("already exists on these members: server-1");
}
@Test
@@ -396,13 +473,14 @@ public class CreateRegionCommandDUnitTest {
String regionName = testName.getMethodName();
gfsh.executeAndAssertThat("create region --type=LOCAL --group=group1
--name=" + regionName)
.statusIsSuccess();
- gfsh.executeAndAssertThat("create region --type=REPLICATE --name=" +
regionName)
- .statusIsError();
+ gfsh.executeAndAssertThat("create region --type=REPLICATE --name=" +
regionName).statusIsError()
+ .containsOutput("Region /startWithLocalRegion already exists on the
cluster.");
gfsh.executeAndAssertThat("create region --type=PARTITION --group=group2
--name=" + regionName)
- .statusIsError();
+ .statusIsError()
+ .containsOutput("Region /startWithLocalRegion already exists on the
cluster.");
gfsh.executeAndAssertThat(
"create region --type=PARTITION_PROXY --group=group2 --name=" +
regionName).statusIsError()
- .containsOutput("The existing region is not a partitioned region");
+ .containsOutput("Region /startWithLocalRegion already exists on the
cluster");
}
private String getUniversalClassCode(String classname) {
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
index 9b8bf91..c423488 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
@@ -168,11 +168,11 @@ public class CreateRegionCommandIntegrationTest {
gfsh.executeAndAssertThat(
"create region --skip-if-exists --type=PARTITION --name=/FOO
--local-max-memory=0")
- .statusIsSuccess().containsOutput("Region \"/FOO\" already exists.");
+ .statusIsSuccess().containsOutput("Region /FOO already exists on these
members: server.");
gfsh.executeAndAssertThat(
"create region --if-not-exists --type=PARTITION --name=/FOO
--local-max-memory=0")
- .statusIsSuccess().containsOutput("Region \"/FOO\" already exists.");
+ .statusIsSuccess().containsOutput("Region /FOO already exists on these
members: server.");
gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
index 48f3859..6bb511f 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
@@ -387,6 +387,7 @@ public class CreateRegionCommandTest {
public void nameCollisionCheck() {
when(regionMXBean.getMemberCount()).thenReturn(2);
when(regionMXBean.getEmptyNodes()).thenReturn(1);
+ when(regionMXBean.getRegionType()).thenReturn("REPLICATE");
parser.executeAndAssertThat(command, COMMAND).statusIsError()
.containsOutput("Region /region already exists on the cluster");
parser.executeAndAssertThat(command, COMMAND + "
--if-not-exists").statusIsSuccess()
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityDUnitTest.java
similarity index 70%
rename from
geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityTest.java
rename to
geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityDUnitTest.java
index 8171f75..a426719 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionSecurityDUnitTest.java
@@ -19,27 +19,42 @@ package org.apache.geode.management.internal.cli.commands;
import static
org.apache.geode.test.junit.rules.GfshCommandRule.PortType.jmxManager;
+import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
+import org.apache.geode.security.AuthInitialize;
import org.apache.geode.security.SimpleTestSecurityManager;
-import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.ConnectionConfiguration;
import org.apache.geode.test.junit.rules.GfshCommandRule;
-import org.apache.geode.test.junit.rules.ServerStarterRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
-@Category(IntegrationTest.class)
-public class CreateRegionSecurityTest {
+@Category(DistributedTest.class)
+public class CreateRegionSecurityDUnitTest {
@ClassRule
- public static ServerStarterRule server = new ServerStarterRule()
-
.withSecurityManager(SimpleTestSecurityManager.class).withJMXManager().withAutoStart();
+ public static ClusterStartupRule cluster = new ClusterStartupRule();
+
+ private static MemberVM locator;
+
+ @BeforeClass
+ public static void beforeClass() {
+ locator =
+ cluster.startLocatorVM(0, x ->
x.withSecurityManager(SimpleTestSecurityManager.class));
+ int locatorPort = locator.getPort();
+ cluster.startServerVM(1,
+ x -> x.withProperty(AuthInitialize.SECURITY_USERNAME, "cluster")
+ .withProperty(AuthInitialize.SECURITY_PASSWORD, "cluster")
+ .withConnectionToLocator(locatorPort));
+ }
@Rule
- public GfshCommandRule gfsh = new GfshCommandRule(server::getJmxPort,
jmxManager);
+ public GfshCommandRule gfsh = new GfshCommandRule(locator::getJmxPort,
jmxManager);
@Rule
public TestName testName = new SerializableTestName();
@@ -66,6 +81,6 @@ public class CreateRegionSecurityTest {
gfsh.executeAndAssertThat("create region --type=REPLICATE_PROXY --name=" +
regionName)
.statusIsError()
- .containsOutput("You can only create proxy regions with the same name
on other members");
+ .containsOutput("Region /dataManageAuthorized already exists on these
members");
}
}
diff --git
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
index 98aa82f..99dcefb 100644
---
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
+++
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
@@ -51,8 +51,8 @@ public class DestroyRegionCommandDUnitTest {
public static void beforeClass() throws Exception {
locator = lsRule.startLocatorVM(0);
server1 = lsRule.startServerVM(1, "group1", locator.getPort());
- server2 = lsRule.startServerVM(2, locator.getPort());
- server3 = lsRule.startServerVM(3, locator.getPort());
+ server2 = lsRule.startServerVM(2, "group2", locator.getPort());
+ server3 = lsRule.startServerVM(3, "group2", locator.getPort());
}
@Before
@@ -103,10 +103,11 @@ public class DestroyRegionCommandDUnitTest {
}
@Test
- public void testDestroyLocalAndDistributedRegions() {
+ public void testDestroyDistributedRegions() {
gfsh.executeAndAssertThat("create region --name=region1
--type=REPLICATE_PROXY --group=group1")
.statusIsSuccess();
- gfsh.executeAndAssertThat("create region --name=region1
--type=REPLICATE").statusIsSuccess();
+ gfsh.executeAndAssertThat("create region --name=region1 --type=REPLICATE
--group=group2")
+ .statusIsSuccess();
locator.waitTillRegionsAreReadyOnServers("/region1", 3);
@@ -117,7 +118,7 @@ public class DestroyRegionCommandDUnitTest {
assertThat(group1Config.getCacheXmlContent()).contains("<region
name=\"region1\">\n"
+ " <region-attributes data-policy=\"empty\"
scope=\"distributed-ack\"/>");
- Configuration clusterConfig = service.getConfiguration("cluster");
+ Configuration clusterConfig = service.getConfiguration("group2");
assertThat(clusterConfig.getCacheXmlContent()).contains("<region
name=\"region1\">\n"
+ " <region-attributes data-policy=\"replicate\"
scope=\"distributed-ack\"/>");
});
@@ -132,7 +133,7 @@ public class DestroyRegionCommandDUnitTest {
Configuration group1Config = service.getConfiguration("group1");
assertThat(group1Config.getCacheXmlContent()).doesNotContain("region1");
- Configuration clusterConfig = service.getConfiguration("cluster");
+ Configuration clusterConfig = service.getConfiguration("group2");
assertThat(clusterConfig.getCacheXmlContent()).doesNotContain("region1");
});
--
To stop receiving notification emails like this one, please contact
[email protected].