Search in sources :

Example 1 with GfshShellConnectionRule

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

the class ConcurrentDeployDUnitTest method connectToLocator.

public static void connectToLocator(int locatorPort) throws Exception {
    gfsh = new GfshShellConnectionRule();
    gfsh.connectAndVerify(locatorPort, GfshShellConnectionRule.PortType.locator);
}
Also used : GfshShellConnectionRule(org.apache.geode.test.dunit.rules.GfshShellConnectionRule)

Example 2 with GfshShellConnectionRule

use of org.apache.geode.test.dunit.rules.GfshShellConnectionRule 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)

Example 3 with GfshShellConnectionRule

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

the class PDXPostProcessorDUnitTest method testGfshCommand.

@Test
public void testGfshCommand() {
    // have client2 input some domain data into the region
    client2.invoke(() -> {
        ClientCache cache = createClientCache("super-user", "1234567", server.getPort());
        Region region = createProxyRegion(cache, REGION_NAME);
        // put in a value that's a domain object
        region.put("key1", new SimpleClass(1, (byte) 1));
        // put in a byte value
        region.put("key2", BYTES);
    });
    client1.invoke(() -> {
        GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
        gfsh.secureConnectAndVerify(server.getJmxPort(), GfshShellConnectionRule.PortType.jmxManger, "dataUser", "1234567");
        // get command
        CommandResult result = gfsh.executeAndVerifyCommand("get --key=key1 --region=AuthRegion");
        if (pdxPersistent)
            assertThat(gfsh.getGfshOutput().contains("org.apache.geode.pdx.internal.PdxInstanceImpl"));
        else
            assertThat(gfsh.getGfshOutput()).contains("SimpleClass");
        result = gfsh.executeAndVerifyCommand("get --key=key2 --region=AuthRegion");
        assertTrue(result.getContent().toString().contains("byte[]"));
        gfsh.executeAndVerifyCommand("query --query=\"select * from /AuthRegion\"");
        gfsh.close();
    });
    PDXPostProcessor pp = (PDXPostProcessor) SecurityService.getSecurityService().getPostProcessor();
    assertEquals(pp.getCount(), 4);
}
Also used : Region(org.apache.geode.cache.Region) SecurityTestUtil.createProxyRegion(org.apache.geode.security.SecurityTestUtil.createProxyRegion) ClientCache(org.apache.geode.cache.client.ClientCache) SecurityTestUtil.createClientCache(org.apache.geode.security.SecurityTestUtil.createClientCache) GfshShellConnectionRule(org.apache.geode.test.dunit.rules.GfshShellConnectionRule) SimpleClass(org.apache.geode.pdx.SimpleClass) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

GfshShellConnectionRule (org.apache.geode.test.dunit.rules.GfshShellConnectionRule)3 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Region (org.apache.geode.cache.Region)1 ClientCache (org.apache.geode.cache.client.ClientCache)1 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)1 SimpleClass (org.apache.geode.pdx.SimpleClass)1 SecurityTestUtil.createClientCache (org.apache.geode.security.SecurityTestUtil.createClientCache)1 SecurityTestUtil.createProxyRegion (org.apache.geode.security.SecurityTestUtil.createProxyRegion)1 MemberVM (org.apache.geode.test.dunit.rules.MemberVM)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)1 Test (org.junit.Test)1