Search in sources :

Example 96 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class GemfireDataCommandsDUnitTest method doTestSelectWithGfshEnvVariables.

public void doTestSelectWithGfshEnvVariables(boolean statusActive) {
    Random random = new Random(System.nanoTime());
    int randomInteger = random.nextInt(COUNT);
    String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from ${DATA_REGION} where ID <= ${PORTFOLIO_ID}" + " and status='${STATUS}'" + "\" --interactive=false";
    executeCommand("set variable --name=DATA_REGION --value=" + DATA_REGION_NAME_PATH);
    executeCommand("set variable --name=PORTFOLIO_ID --value=" + randomInteger);
    executeCommand("set variable --name=STATUS --value=" + (statusActive ? "active" : "inactive"));
    CommandResult cmdResult = executeCommand(query);
    printCommandOutput(cmdResult);
    validateSelectResult(cmdResult, true, -1, null);
    IgnoredException ex = addIgnoredException(QueryInvalidException.class.getSimpleName(), Host.getHost(0).getVM(0));
    try {
        query = "query --query=\"select ID , status , createTime , pk, floatMinValue from ${DATA_REGION2} where ID <= ${PORTFOLIO_ID2}" + " and status='${STATUS2}'" + "\" --interactive=false";
        cmdResult = executeCommand(query);
        printCommandOutput(cmdResult);
        validateSelectResult(cmdResult, false, 0, null);
    } finally {
        ex.remove();
    }
}
Also used : Random(java.util.Random) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 97 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class GemfireDataCommandsDUnitTest method testRecursiveLocateEntryCommand.

@Test
public void testRecursiveLocateEntryCommand() {
    final String keyPrefix = "testKey";
    final String valuePrefix = "testValue";
    setupForGetPutRemoveLocateEntry("testRecursiveLocateEntry");
    final VM vm1 = Host.getHost(0).getVM(1);
    final VM vm2 = Host.getHost(0).getVM(2);
    SerializableRunnable putKeys = new SerializableRunnable() {

        @Override
        public void run() {
            Cache cache = getCache();
            Region region = cache.getRegion(DATA_REGION_NAME_PATH);
            Region region2 = cache.getRegion(DATA_REGION_NAME_CHILD_1_PATH);
            Region region3 = cache.getRegion(DATA_REGION_NAME_CHILD_1_2_PATH);
            assertNotNull(region);
            region.clear();
            for (int i = 0; i < COUNT; i++) {
                String key = keyPrefix + i;
                String value = valuePrefix + i;
                region.put(key, value);
                region2.put(key, value);
                region3.put(key, value);
            }
        }
    };
    vm1.invoke(putKeys);
    for (int i = 0; i < COUNT; i++) {
        String key = keyPrefix + i;
        String command = "locate entry";
        command = command + " " + "--key=" + key + " --region=" + DATA_REGION_NAME_PATH + " --recursive=true";
        CommandResult cmdResult = executeCommand(command);
        printCommandOutput(cmdResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        validateResult(cmdResult, true);
        // 3 Regions X 2 members = 6
        validateLocationsResult(cmdResult, 6);
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache) InternalCache(org.apache.geode.internal.cache.InternalCache) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 98 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class GemfireDataCommandsDUnitTest method testRebalanceCommandForSimulate.

@Test
public void testRebalanceCommandForSimulate() {
    setupTestRebalanceForEntireDS();
    // check if DistributedRegionMXBean is available so that command will not fail
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(checkRegionMBeans);
    getLogWriter().info("testRebalanceCommandForSimulate verified Mbean and executing command");
    String command = "rebalance --simulate=true --include-region=" + "/" + REBALANCE_REGION_NAME;
    CommandResult cmdResult = executeCommand(command);
    getLogWriter().info("testRebalanceCommandForSimulate just after executing " + cmdResult);
    if (cmdResult != null) {
        String stringResult = commandResultToString(cmdResult);
        getLogWriter().info("testRebalanceCommandForSimulate stringResult : " + stringResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testRebalanceCommandForSimulate failed as did not get CommandResult");
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 99 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class GemfireDataCommandsDUnitTest method testRebalanceForEntireDS.

// GEODE-1487
@Category(FlakyTest.class)
@Test
public void testRebalanceForEntireDS() {
    setupTestRebalanceForEntireDS();
    // check if DistributedRegionMXBean is available so that command will not fail
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(checkRegionMBeans);
    getLogWriter().info("testRebalanceForEntireDS verified Mbean and executin command");
    String command = "rebalance";
    CommandResult cmdResult = executeCommand(command);
    getLogWriter().info("testRebalanceForEntireDS just after executing " + cmdResult);
    if (cmdResult != null) {
        String stringResult = commandResultToString(cmdResult);
        getLogWriter().info("testRebalanceForEntireDS stringResult : " + stringResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testRebalanceForIncludeRegionFunction failed as did not get CommandResult");
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Category(org.junit.experimental.categories.Category) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 100 with CommandResult

use of org.apache.geode.management.internal.cli.result.CommandResult in project geode by apache.

the class GemfireDataCommandsDUnitTest method testRebalanceForIncludeRegionFunction.

@Test
public void testRebalanceForIncludeRegionFunction() {
    // setup();
    setupWith2Regions();
    // check if DistributedRegionMXBean is available so that command will not fail
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(checkRegionMBeans);
    getLogWriter().info("testRebalanceForIncludeRegionFunction verified Mbean and executin command");
    String command = "rebalance --include-region=" + "/" + REBALANCE_REGION_NAME + ",/" + REBALANCE_REGION2_NAME;
    CommandResult cmdResult = executeCommand(command);
    getLogWriter().info("testRebalanceForIncludeRegionFunction just after executing " + cmdResult);
    if (cmdResult != null) {
        String stringResult = commandResultToString(cmdResult);
        getLogWriter().info("testRebalanceForIncludeRegionFunction stringResult : " + stringResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testRebalanceForIncludeRegionFunction failed as did not get CommandResult");
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)270 Test (org.junit.Test)222 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)208 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)131 Properties (java.util.Properties)94 VM (org.apache.geode.test.dunit.VM)80 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)71 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)67 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)45 File (java.io.File)44 Cache (org.apache.geode.cache.Cache)43 Region (org.apache.geode.cache.Region)39 Category (org.junit.experimental.categories.Category)33 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)32 InternalCache (org.apache.geode.internal.cache.InternalCache)29 DistributedMember (org.apache.geode.distributed.DistributedMember)26 ArrayList (java.util.ArrayList)16 RegionFactory (org.apache.geode.cache.RegionFactory)15 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)15 Gfsh (org.apache.geode.management.internal.cli.shell.Gfsh)14