use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigDeployJarDUnitTest method testDeployToMultipleLocators.
@Test
public void testDeployToMultipleLocators() throws Exception {
MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
MemberVM locator2 = lsRule.startLocatorVM(1, locatorProps);
locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "],localhost[" + locator2.getPort() + "]");
MemberVM locator3 = lsRule.startLocatorVM(2, locatorProps);
// has to start a server in order to run deploy command
lsRule.startServerVM(3, serverProps, locator.getPort());
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
expectedClusterConfig.verify(locator);
expectedClusterConfig.verify(locator2);
expectedClusterConfig.verify(locator3);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigDeployJarDUnitTest method testUndeployWithServerBounce.
@Test
public void testUndeployWithServerBounce() throws Exception {
// set up the locator/servers
MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
serverProps.setProperty(GROUPS, "group1");
MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
serverProps.setProperty(GROUPS, "group2");
MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
serverProps.setProperty(GROUPS, "group1,group2");
serverProps.setProperty(LOG_LEVEL, "info");
MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
ConfigGroup cluster = new ConfigGroup("cluster");
ConfigGroup group1 = new ConfigGroup("group1");
ConfigGroup group2 = new ConfigGroup("group2");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
ClusterConfig server1Config = new ClusterConfig(cluster, group1);
ClusterConfig server2Config = new ClusterConfig(cluster, group2);
ClusterConfig server3Config = new ClusterConfig(cluster, group1, group2);
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
// deploy cluster.jar to the cluster
cluster.addJar("cluster.jar");
expectedClusterConfig.verify(locator);
expectedClusterConfig.verify(server1);
expectedClusterConfig.verify(server2);
expectedClusterConfig.verify(server3);
// deploy group1.jar to both group1 and group2
gfshConnector.executeAndVerifyCommand("deploy --jar=" + group1Jar + " --group=group1,group2");
group1.addJar("group1.jar");
group2.addJar("group1.jar");
server3Config.verify(locator);
server1Config.verify(server1);
server2Config.verify(server2);
server3Config.verify(server3);
server3.getVM().bounce();
// test undeploy cluster
gfshConnector.executeAndVerifyCommand("undeploy --jar=cluster.jar");
server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
cluster = cluster.removeJar("cluster.jar");
server3Config.verify(locator);
server1Config.verify(server1);
server2Config.verify(server2);
server3Config.verify(server3);
gfshConnector.executeAndVerifyCommand("undeploy --jar=group1.jar --group=group1");
group1 = group1.removeJar("group1.jar");
/*
* TODO: GEODE-2779 This is the current (weird) behavior If you started server4 with
* group1,group2 after this undeploy command, it would have group1.jar (brought from
* cluster_config/group2/group1.jar on locator) whereas server3 (also in group1,group2) does not
* have this jar.
*/
ClusterConfig weirdServer3Config = new ClusterConfig(cluster, group1, new ConfigGroup(group2).removeJar("group1.jar"));
server3Config.verify(locator);
server1Config.verify(server1);
server2Config.verify(server2);
weirdServer3Config.verify(server3);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigDeployJarDUnitTest method testDeploy.
@Test
public void testDeploy() throws Exception {
// set up the locator/servers
MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
// server1 in no group
MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
// server2 in group1
serverProps.setProperty(GROUPS, "group1");
MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
// server3 in group1 and group2
serverProps.setProperty(GROUPS, "group1,group2");
MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
expectedClusterConfig.verify(locator);
expectedClusterConfig.verify(server1);
expectedClusterConfig.verify(server2);
expectedClusterConfig.verify(server3);
gfshConnector.executeAndVerifyCommand("deploy --jar=" + group1Jar + " --group=group1");
ConfigGroup group1 = new ConfigGroup("group1").jars("group1.jar");
ClusterConfig expectedGroup1Config = new ClusterConfig(cluster, group1);
expectedGroup1Config.verify(locator);
expectedClusterConfig.verify(server1);
expectedGroup1Config.verify(server2);
expectedGroup1Config.verify(server3);
gfshConnector.executeAndVerifyCommand("deploy --jar=" + group2Jar + " --group=group2");
ConfigGroup group2 = new ConfigGroup("group2").jars("group2.jar");
ClusterConfig expectedGroup1and2Config = new ClusterConfig(cluster, group1, group2);
expectedGroup1and2Config.verify(locator);
expectedClusterConfig.verify(server1);
expectedGroup1Config.verify(server2);
expectedGroup1and2Config.verify(server3);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigImportDUnitTest method testExportClusterConfig.
public void testExportClusterConfig(String zipFilePath) throws Exception {
MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
expectedClusterConfig.verify(server1);
expectedClusterConfig.verify(locatorVM);
gfshConnector.executeAndVerifyCommand("export cluster-configuration --zip-file-name=" + zipFilePath);
File exportedZip = new File(zipFilePath);
assertThat(exportedZip).exists();
Set<String> actualZipEnries = new ZipFile(exportedZip).stream().map(ZipEntry::getName).collect(Collectors.toSet());
ConfigGroup exportedClusterGroup = cluster.configFiles("cluster.xml", "cluster.properties");
ClusterConfig expectedExportedClusterConfig = new ClusterConfig(exportedClusterGroup);
Set<String> expectedZipEntries = new HashSet<>();
for (ConfigGroup group : expectedExportedClusterConfig.getGroups()) {
String groupDir = group.getName() + File.separator;
for (String jarOrXmlOrPropFile : group.getAllFiles()) {
expectedZipEntries.add(groupDir + jarOrXmlOrPropFile);
}
}
assertThat(actualZipEnries).isEqualTo(expectedZipEntries);
}
use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.
the class ClusterConfigImportDUnitTest method testImportWithRunningServerWithRegion.
@Test
public void testImportWithRunningServerWithRegion() throws Exception {
MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
// create another server as well
MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
String regionName = "regionA";
server1.invoke(() -> {
// this region will be created on both servers, but we should only be getting the name once.
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
});
CommandResult result = gfshConnector.executeCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
assertThat(result.getContent().toString()).contains("existing regions: " + regionName);
}
Aggregations