Search in sources :

Example 11 with MemberVM

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

the class ClusterConfigStartMemberDUnitTest method testStartLocator.

@Test
public void testStartLocator() throws Exception {
    locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
    MemberVM secondLocator = lsRule.startLocatorVM(1, locatorProps);
    REPLICATED_CONFIG_FROM_ZIP.verify(secondLocator);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 12 with MemberVM

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

the class ClusterConfigStartMemberDUnitTest method testStartServerWithSingleGroup.

@Test
public void testStartServerWithSingleGroup() throws Exception {
    ClusterConfig expectedNoGroupConfig = new ClusterConfig(CLUSTER);
    ClusterConfig expectedGroup1Config = new ClusterConfig(CLUSTER, GROUP1);
    ClusterConfig expectedGroup2Config = new ClusterConfig(CLUSTER, GROUP2);
    MemberVM serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
    expectedNoGroupConfig.verify(serverWithNoGroup);
    serverProps.setProperty(GROUPS, "group1");
    MemberVM serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
    expectedGroup1Config.verify(serverForGroup1);
    serverProps.setProperty(GROUPS, "group2");
    MemberVM serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
    expectedGroup2Config.verify(serverForGroup2);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 13 with MemberVM

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

the class LuceneClusterConfigurationDUnitTest method indexWithAnalyzerGetsCreatedUsingClusterConfiguration.

@Test
public void indexWithAnalyzerGetsCreatedUsingClusterConfiguration() throws Exception {
    startNodeUsingClusterConfiguration(1);
    // Connect Gfsh to locator.
    gfshConnector.connectAndVerify(locator);
    // Create lucene index.
    // createLuceneIndexUsingGfsh();
    createLuceneIndexWithAnalyzerUsingGfsh(false);
    createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, null);
    // Start vm2. This should have lucene index created using cluster
    // configuration.
    MemberVM vm2 = startNodeUsingClusterConfiguration(2);
    vm2.invoke(() -> {
        LuceneService luceneService = LuceneServiceProvider.get(LocatorServerStartupRule.serverStarter.getCache());
        final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
        assertNotNull(index);
        String[] fields = new String[] { "field1", "field2", "field3" };
        validateIndexFields(fields, index);
        // Add this check back when we complete xml generation for analyzer.
        validateIndexFieldAnalyzer(fields, new String[] { "org.apache.lucene.analysis.standard.StandardAnalyzer", "org.apache.lucene.analysis.standard.StandardAnalyzer", "org.apache.lucene.analysis.standard.StandardAnalyzer" }, index);
    });
}
Also used : LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) MemberVM(org.apache.geode.test.dunit.rules.MemberVM) LuceneService(org.apache.geode.cache.lucene.LuceneService) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 14 with MemberVM

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

the class ClusterConfigurationIndexWithFromClauseDUnitTest method indexCreatedWithEntrySetInFromClauseMustPersist.

@Test
@Parameters(method = "getRegionTypes")
public void indexCreatedWithEntrySetInFromClauseMustPersist(RegionShortcut regionShortcut) throws Exception {
    MemberVM vm1 = lsRule.startServerVM(1, locator.getPort());
    gfshShellConnectionRule.connectAndVerify(locator);
    createRegionUsingGfsh(REGION_NAME, regionShortcut, null);
    createIndexUsingGfsh("\"" + REGION_NAME + ".entrySet() z\"", "z.key", INDEX_NAME);
    String serverName = vm1.getName();
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_MEMBER);
    gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
    lsRule.stopMember(1);
    lsRule.startServerVM(1, lsRule.getMember(0).getPort());
    ;
    verifyIndexRecreated(INDEX_NAME);
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 15 with MemberVM

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

the class ConnectToLocatorSSLDUnitTest method setUpLocatorAndConnect.

private void setUpLocatorAndConnect(Properties securityProps) throws Exception {
    MemberVM locator = lsRule.startLocatorVM(0, securityProps);
    // saving the securityProps to a file
    OutputStream out = new FileOutputStream(securityPropsFile);
    securityProps.store(out, null);
    /*
     * When using SSL, the GfshShellConnectionRule seems to leave behind state in the JVM that
     * causes test flakinesss. (Each test method will pass if run in isolation, but when all run
     * together, the second and third tests will fail.) To avoid this issue, we connect to our
     * locator from a remote VM which is cleaned up by the CleanupDUnitVMsRule in between tests.
     */
    final int locatorPort = locator.getPort();
    final String securityPropsFilePath = securityPropsFile.getCanonicalPath();
    Host.getHost(0).getVM(1).invoke(() -> {
        GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
        try {
            gfshConnector.connectAndVerify(locatorPort, GfshShellConnectionRule.PortType.locator, CliStrings.CONNECT__SECURITY_PROPERTIES, securityPropsFilePath);
        } finally {
            gfshConnector.close();
        }
    });
}
Also used : MemberVM(org.apache.geode.test.dunit.rules.MemberVM) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) GfshShellConnectionRule(org.apache.geode.test.dunit.rules.GfshShellConnectionRule)

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