Search in sources :

Example 21 with MemberVM

use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.

the class ClusterConfigImportDUnitTest method testImportClusterConfig.

@Test
public void testImportClusterConfig() throws Exception {
    gfshConnector.executeAndVerifyCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
    // Make sure that a backup of the old clusterConfig was created
    assertThat(locatorVM.getWorkingDir().listFiles()).filteredOn((File file) -> file.getName().contains("cluster_config")).hasSize(2);
    CONFIG_FROM_ZIP.verify(locatorVM);
    // start server1 with no group
    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
    new ClusterConfig(CLUSTER).verify(server1);
    // start server2 in group1
    serverProps.setProperty(GROUPS, "group1");
    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
    new ClusterConfig(CLUSTER, GROUP1).verify(server2);
    // start server3 in group1 and group2
    serverProps.setProperty(GROUPS, "group1,group2");
    MemberVM server3 = lsRule.startServerVM(3, serverProps, locatorVM.getPort());
    new ClusterConfig(CLUSTER, GROUP1, GROUP2).verify(server3);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) File(java.io.File) ZipFile(java.util.zip.ZipFile) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 22 with MemberVM

use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.

the class ClusterConfigImportDUnitTest method testImportWithMultipleLocators.

@Test
public void testImportWithMultipleLocators() throws Exception {
    locatorProps.setProperty(LOCATORS, "localhost[" + locatorVM.getPort() + "]");
    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
    locatorProps.setProperty(LOCATORS, "localhost[" + locatorVM.getPort() + "],localhost[" + locator1.getPort() + "]");
    MemberVM locator2 = lsRule.startLocatorVM(2, locatorProps);
    gfshConnector.executeAndVerifyCommand("import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
    CONFIG_FROM_ZIP.verify(locatorVM);
    REPLICATED_CONFIG_FROM_ZIP.verify(locator1);
    REPLICATED_CONFIG_FROM_ZIP.verify(locator2);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 23 with MemberVM

use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.

the class ClusterConfigStartMemberDUnitTest method startLocatorWithLoadCCFromDir.

private MemberVM startLocatorWithLoadCCFromDir() throws Exception {
    File locatorDir = lsRule.getTempFolder().newFolder("locator-0");
    File configDir = new File(locatorDir, "cluster_config");
    // The unzip should yield a cluster config directory structure like:
    // tempFolder/locator-0/cluster_config/cluster/cluster.xml
    // tempFolder/locator-0/cluster_config/cluster/cluster.properties
    // tempFolder/locator-0/cluster_config/cluster/cluster.jar
    // tempFolder/locator-0/cluster_config/group1/ {group1.xml, group1.properties, group1.jar}
    // tempFolder/locator-0/cluster_config/group2/ ...
    ZipUtils.unzip(clusterConfigZipPath, configDir.getCanonicalPath());
    Properties properties = new Properties();
    properties.setProperty(ENABLE_CLUSTER_CONFIGURATION, "true");
    properties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
    properties.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
    MemberVM locator = lsRule.startLocatorVM(0, properties);
    CONFIG_FROM_ZIP.verify(locator);
    return locator;
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Properties(java.util.Properties) File(java.io.File)

Example 24 with MemberVM

use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.

the class ClusterConfigStartMemberDUnitTest method testStartServerWithMultipleGroup.

@Test
public void testStartServerWithMultipleGroup() throws Exception {
    ClusterConfig expectedGroup1And2Config = new ClusterConfig(CLUSTER, GROUP1, GROUP2);
    serverProps.setProperty(GROUPS, "group1,group2");
    MemberVM server = lsRule.startServerVM(1, serverProps, locator.getPort());
    expectedGroup1And2Config.verify(server);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 25 with MemberVM

use of org.apache.geode.test.dunit.rules.MemberVM in project geode by apache.

the class LuceneClusterConfigurationDUnitTest method verifyMemberWithGroupStartsAfterAlterRegion.

@Test
public void verifyMemberWithGroupStartsAfterAlterRegion() throws Exception {
    // Start a member with no group
    startNodeUsingClusterConfiguration(1);
    // Start a member with group
    String group = "group1";
    Properties properties = new Properties();
    properties.setProperty(GROUPS, group);
    MemberVM vm2 = startNodeUsingClusterConfiguration(2, properties);
    // Connect Gfsh to locator
    gfshConnector.connectAndVerify(locator);
    // Create index and region in no group
    createLuceneIndexUsingGfsh();
    createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, null);
    // Alter region in group
    CommandResult alterRegionResult = alterRegionUsingGfsh(group);
    TabularResultData alterRegionResultData = (TabularResultData) alterRegionResult.getResultData();
    List<String> alterRegionResultDataStatus = alterRegionResultData.retrieveAllValues("Status");
    // Verify region is altered on only one server
    assertEquals(1, alterRegionResultDataStatus.size());
    assertEquals("Region \"/" + REGION_NAME + "\" altered on \"" + vm2.getName() + "\"", alterRegionResultDataStatus.get(0));
    // Start another member with group
    startNodeUsingClusterConfiguration(3, properties);
    // Verify all members have indexes
    CommandResult listIndexesResult = listIndexesUsingGfsh();
    TabularResultData listIndexesResultData = (TabularResultData) listIndexesResult.getResultData();
    List<String> listIndexesResultDataStatus = listIndexesResultData.retrieveAllValues("Status");
    assertEquals(3, listIndexesResultDataStatus.size());
    for (String status : listIndexesResultDataStatus) {
        assertEquals("Initialized", status);
    }
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Properties(java.util.Properties) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

MemberVM (org.apache.geode.test.dunit.rules.MemberVM)27 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)19 Test (org.junit.Test)19 Properties (java.util.Properties)8 File (java.io.File)5 ZipFile (java.util.zip.ZipFile)3 Cache (org.apache.geode.cache.Cache)3 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)3 HashSet (java.util.HashSet)2 LuceneIndex (org.apache.geode.cache.lucene.LuceneIndex)2 LuceneService (org.apache.geode.cache.lucene.LuceneService)2 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)2 InternalLocator (org.apache.geode.distributed.internal.InternalLocator)2 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)2 Before (org.junit.Before)2 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Serializable (java.io.Serializable)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1