Search in sources :

Example 86 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class GemfireDataCommandsDUnitTest method testImportExportData.

// GEODE-1404
@Category(FlakyTest.class)
@Test
public void testImportExportData() throws InterruptedException, IOException {
    final String regionName = "Region1";
    final String exportFileName = "export.gfd";
    final VM manager = Host.getHost(0).getVM(0);
    final VM vm1 = Host.getHost(0).getVM(1);
    final File exportFile = new File(exportFileName);
    final String filePath = exportFile.getCanonicalPath();
    try {
        if (!exportFile.exists()) {
            exportFile.createNewFile();
        }
        exportFile.deleteOnExit();
        setUpJmxManagerOnVm0ThenConnect(null);
        manager.invoke(new SerializableRunnable() {

            public void run() {
                createParReg(regionName, getCache());
            }
        });
        vm1.invoke(new SerializableRunnable() {

            @Override
            public void run() throws Exception {
                Region region = createParReg(regionName, getCache());
                for (int i = 0; i < 100; i++) {
                    region.put(i, i);
                }
            }
        });
        CommandStringBuilder csb = new CommandStringBuilder(CliStrings.EXPORT_DATA);
        csb.addOption(CliStrings.EXPORT_DATA__REGION, regionName);
        csb.addOption(CliStrings.EXPORT_DATA__MEMBER, "Manager");
        csb.addOption(CliStrings.EXPORT_DATA__FILE, filePath);
        String commandString = csb.toString();
        CommandResult cmdResult = executeCommand(commandString);
        String resultAsString = commandResultToString(cmdResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        getLogWriter().info("Command Output");
        getLogWriter().info(resultAsString);
        vm1.invoke(new SerializableRunnable() {

            public void run() {
                Region region = getCache().getRegion(regionName);
                for (int i = 0; i < 100; i++) {
                    region.destroy(i);
                }
            }
        });
        /*
       * Add CacheListener
       */
        manager.invoke(addCacheListenerInvocations(regionName));
        vm1.invoke(addCacheListenerInvocations(regionName));
        /*
       * Import the data
       */
        csb = new CommandStringBuilder(CliStrings.IMPORT_DATA);
        csb.addOption(CliStrings.IMPORT_DATA__REGION, regionName);
        csb.addOption(CliStrings.IMPORT_DATA__FILE, filePath);
        csb.addOption(CliStrings.IMPORT_DATA__MEMBER, "Manager");
        commandString = csb.toString();
        cmdResult = executeCommand(commandString);
        resultAsString = commandResultToString(cmdResult);
        getLogWriter().info("Result of import data");
        getLogWriter().info(resultAsString);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        /*
       * Validate the region entries after import They must match the entries before export
       */
        manager.invoke(new SerializableRunnable() {

            public void run() {
                Region region = getCache().getRegion(regionName);
                for (int i = 0; i < 100; i++) {
                    assertEquals(i, region.get(i));
                }
            }
        });
        /*
       * Verify callbacks were not invoked
       */
        manager.invoke(verifyCacheListenerInvocations(regionName, false));
        vm1.invoke(verifyCacheListenerInvocations(regionName, false));
        /*
       * Import the data with invokeCallbacks=true
       */
        vm1.invoke(new SerializableRunnable() {

            public void run() {
                Region region = getCache().getRegion(regionName);
                for (int i = 0; i < 100; i++) {
                    region.destroy(i);
                }
            }
        });
        csb = new CommandStringBuilder(CliStrings.IMPORT_DATA);
        csb.addOption(CliStrings.IMPORT_DATA__REGION, regionName);
        csb.addOption(CliStrings.IMPORT_DATA__FILE, filePath);
        csb.addOption(CliStrings.IMPORT_DATA__MEMBER, "Manager");
        csb.addOption(CliStrings.IMPORT_DATA__INVOKE_CALLBACKS, "true");
        commandString = csb.toString();
        cmdResult = executeCommand(commandString);
        commandResultToString(cmdResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        /*
       * Verify callbacks were invoked
       */
        manager.invoke(verifyCacheListenerInvocations(regionName, true));
        vm1.invoke(verifyCacheListenerInvocations(regionName, true));
        // Test for bad input
        csb = new CommandStringBuilder(CliStrings.EXPORT_DATA);
        csb.addOption(CliStrings.EXPORT_DATA__REGION, "FDSERW");
        csb.addOption(CliStrings.EXPORT_DATA__FILE, filePath);
        csb.addOption(CliStrings.EXPORT_DATA__MEMBER, "Manager");
        commandString = csb.getCommandString();
        cmdResult = executeCommand(commandString);
        resultAsString = commandResultToString(cmdResult);
        getLogWriter().info("Result of import data with wrong region name");
        getLogWriter().info(resultAsString);
        assertEquals(Result.Status.ERROR, cmdResult.getStatus());
        csb = new CommandStringBuilder(CliStrings.IMPORT_DATA);
        csb.addOption(CliStrings.IMPORT_DATA__REGION, regionName);
        csb.addOption(CliStrings.IMPORT_DATA__FILE, "#WEQW");
        csb.addOption(CliStrings.IMPORT_DATA__MEMBER, "Manager");
        commandString = csb.getCommandString();
        cmdResult = executeCommand(commandString);
        resultAsString = commandResultToString(cmdResult);
        getLogWriter().info("Result of import data with wrong file");
        getLogWriter().info(resultAsString);
        assertEquals(Result.Status.ERROR, cmdResult.getStatus());
    } finally {
        exportFile.delete();
    }
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Region(org.apache.geode.cache.Region) File(java.io.File) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) GfJsonException(org.apache.geode.management.internal.cli.json.GfJsonException) IOException(java.io.IOException) 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 87 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class QueueCommandsDUnitTest method testAsyncEventQueue.

// GEODE-1429
@Category(FlakyTest.class)
@Test
public void testAsyncEventQueue() throws IOException {
    final String queue1Name = "testAsyncEventQueue1";
    final String queue2Name = "testAsyncEventQueue2";
    final String diskStoreName = "testAsyncEventQueueDiskStore";
    Properties localProps = new Properties();
    localProps.setProperty(GROUPS, "Group0");
    setUpJmxManagerOnVm0ThenConnect(localProps);
    CommandResult cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    assertTrue(commandResultToString(cmdResult).contains("No Async Event Queues Found"));
    final VM vm1 = Host.getHost(0).getVM(1);
    final String vm1Name = "VM" + vm1.getPid();
    final File diskStoreDir = new File(new File(".").getAbsolutePath(), diskStoreName);
    this.filesToBeDeleted.add(diskStoreDir.getAbsolutePath());
    vm1.invoke(new SerializableRunnable() {

        public void run() {
            diskStoreDir.mkdirs();
            Properties localProps = new Properties();
            localProps.setProperty(NAME, vm1Name);
            localProps.setProperty(GROUPS, "Group1");
            getSystem(localProps);
            getCache();
        }
    });
    final VM vm2 = Host.getHost(0).getVM(2);
    final String vm2Name = "VM" + vm2.getPid();
    vm2.invoke(new SerializableRunnable() {

        public void run() {
            Properties localProps = new Properties();
            localProps.setProperty(NAME, vm2Name);
            localProps.setProperty(GROUPS, "Group2");
            getSystem(localProps);
            getCache();
        }
    });
    // Deploy a JAR file with an
    // AsyncEventListener/GatewayEventFilter/GatewayEventSubstitutionFilter
    // that can be instantiated on each server
    final File jarFile = new File(new File(".").getAbsolutePath(), "QueueCommandsDUnit.jar");
    QueueCommandsDUnitTest.this.filesToBeDeleted.add(jarFile.getAbsolutePath());
    ClassBuilder classBuilder = new ClassBuilder();
    byte[] jarBytes = classBuilder.createJarFromClassContent("com/qcdunit/QueueCommandsDUnitTestHelper", "package com.qcdunit;" + "import java.util.List; import java.util.Properties;" + "import org.apache.geode.internal.cache.xmlcache.Declarable2; import org.apache.geode.cache.asyncqueue.AsyncEvent;" + "import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;" + "import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.wan.GatewayQueueEvent;" + "import org.apache.geode.cache.EntryEvent;" + "public class QueueCommandsDUnitTestHelper implements Declarable2, GatewayEventFilter, GatewayEventSubstitutionFilter, AsyncEventListener {" + "Properties props;" + "public boolean processEvents(List<AsyncEvent> events) { return true; }" + "public void afterAcknowledgement(GatewayQueueEvent event) {}" + "public boolean beforeEnqueue(GatewayQueueEvent event) { return true; }" + "public boolean beforeTransmit(GatewayQueueEvent event) { return true; }" + "public Object getSubstituteValue(EntryEvent event) { return null; }" + "public void close() {}" + "public void init(final Properties props) {this.props = props;}" + "public Properties getConfig() {return this.props;}}");
    writeJarBytesToFile(jarFile, jarBytes);
    cmdResult = executeCommand("deploy --jar=QueueCommandsDUnit.jar");
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
    commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreName);
    commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__GROUP, "Group1");
    commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, diskStoreDir.getAbsolutePath());
    cmdResult = executeCommand(commandStringBuilder.toString());
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    String stringResult = commandResultToString(cmdResult);
    assertEquals(3, countLinesInString(stringResult, false));
    assertEquals(false, stringResult.contains("ERROR"));
    assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
    commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, queue1Name);
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP, "Group1");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE, "514");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "true");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE, diskStoreName);
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, "213");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCHTIMEINTERVAL, "946");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL, "true");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ENABLEBATCHCONFLATION, "true");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISPATCHERTHREADS, "2");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ORDERPOLICY, "PARTITION");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER, "com.qcdunit.QueueCommandsDUnitTestHelper");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__SUBSTITUTION_FILTER, "com.qcdunit.QueueCommandsDUnitTestHelper");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS, "false");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__FORWARD_EXPIRATION_DESTROY, "true");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestHelper");
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE, "param1,param2#value2");
    cmdResult = executeCommand(commandStringBuilder.toString());
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    stringResult = commandResultToString(cmdResult);
    assertEquals(3, countLinesInString(stringResult, false));
    assertEquals(false, stringResult.contains("ERROR"));
    assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
    // Verify that the queue was created on the correct member
    cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    stringResult = commandResultToString(cmdResult);
    assertEquals(3, countLinesInString(stringResult, false));
    assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue1Name + " .*514 .*true .*" + diskStoreName + " .*213 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper" + ".*"));
    assertTrue(stringContainsLine(stringResult, vm1Name + ".*param2=value2.*"));
    assertTrue(stringContainsLine(stringResult, vm1Name + ".*param1=[^\\w].*"));
    assertFalse(stringContainsLine(stringResult, vm2Name + ".*" + queue1Name + ".*"));
    vm1.invoke(new SerializableRunnable() {

        public void run() {
            Cache cache = getCache();
            AsyncEventQueue queue = cache.getAsyncEventQueue(queue1Name);
            assertEquals(queue.getBatchSize(), 514);
            assertEquals(queue.isPersistent(), true);
            assertEquals(queue.getDiskStoreName(), diskStoreName);
            assertEquals(queue.getMaximumQueueMemory(), 213);
            assertEquals(queue.getBatchTimeInterval(), 946);
            assertEquals(queue.isParallel(), true);
            assertEquals(queue.isBatchConflationEnabled(), true);
            assertEquals(queue.getDispatcherThreads(), 2);
            assertEquals(queue.getOrderPolicy().toString(), "PARTITION");
            assertEquals(queue.getGatewayEventFilters().size(), 1);
            assertEquals(queue.getGatewayEventFilters().get(0).getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
            assertEquals(queue.getGatewayEventSubstitutionFilter().getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
            assertEquals(queue.isDiskSynchronous(), false);
            assertEquals(queue.isForwardExpirationDestroy(), true);
            assertEquals(queue.getAsyncEventListener().getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
        }
    });
    commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, queue2Name);
    commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestHelper");
    cmdResult = executeCommand(commandStringBuilder.toString());
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    stringResult = commandResultToString(cmdResult);
    assertEquals(5, countLinesInString(stringResult, false));
    assertTrue(stringContainsLine(stringResult, "Manager.*Success"));
    assertTrue(stringContainsLine(stringResult, vm2Name + ".*Success"));
    assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
    // Verify that the queue was created on the correct members
    cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    stringResult = commandResultToString(cmdResult);
    assertEquals(6, countLinesInString(stringResult, false));
    assertTrue(stringContainsLine(stringResult, "Manager .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
    assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue1Name + " .*514 .*true .*" + diskStoreName + " .*213 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper" + ".*"));
    assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
    assertTrue(stringContainsLine(stringResult, vm2Name + " .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) VM(org.apache.geode.test.dunit.VM) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Properties(java.util.Properties) ClassBuilder(org.apache.geode.internal.ClassBuilder) File(java.io.File) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Cache(org.apache.geode.cache.Cache) 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 88 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class IndexCommandsDUnitTest method testCreateKeyIndexOnRegionWithPersistence.

public void testCreateKeyIndexOnRegionWithPersistence() {
    setupSystemPersist();
    // Creating key indexes on Persistent Partitioned Region
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
    csb.addOption(CliStrings.CREATE_INDEX__NAME, "id1");
    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "ty");
    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + parRegPersName);
    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "key");
    String commandString = csb.toString();
    writeToLog("Command String :\n ", commandString);
    CommandResult commandResult = executeCommand(commandString);
    String resultAsString = commandResultToString(commandResult);
    writeToLog("Command Result :\n", resultAsString);
    assertTrue(Status.OK.equals(commandResult.getStatus()));
    // Creating key indexes on Persistent Replicated Regions
    csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
    csb.addOption(CliStrings.CREATE_INDEX__NAME, "id2");
    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "ee");
    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + repRegPersName);
    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "key");
    commandString = csb.toString();
    writeToLog("Command String :\n ", commandString);
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    writeToLog("Command Result :\n", resultAsString);
    assertTrue(Status.OK.equals(commandResult.getStatus()));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 89 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class IndexCommandsDUnitTest method testCreateAndDestroyIndex.

public void testCreateAndDestroyIndex() {
    setupSystem();
    /***
     * Basic Create and Destroy
     */
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
    String commandString = csb.toString();
    writeToLog("Command String :\n ", commandString);
    CommandResult commandResult = executeCommand(commandString);
    String resultAsString = commandResultToString(commandResult);
    writeToLog("testCreateAndDestroyIndex", resultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(resultAsString.contains(indexName));
    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
    csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "/StocksParReg");
    commandString = csb.toString();
    writeToLog("Command String :\n ", commandString);
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    writeToLog("testCreateAndDestroyIndex", resultAsString);
    assertEquals(commandResult.getStatus(), Status.OK);
    commandResult = executeCommand(CliStrings.LIST_INDEX);
    resultAsString = commandResultToString(commandResult);
    assertEquals(commandResult.getStatus(), Status.OK);
    assertFalse(resultAsString.contains(indexName));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult)

Example 90 with CommandStringBuilder

use of org.apache.geode.management.internal.cli.util.CommandStringBuilder in project geode by apache.

the class IndexCommandsDUnitTest method testClearMultipleIndexes.

// GEODE-689: random ports, unused returns, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testClearMultipleIndexes() {
    setupSystem();
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
    String commandString = csb.toString();
    writeToLog("Command String :\n ", commandString);
    CommandResult commandResult = executeCommand(commandString);
    String resultAsString = commandResultToString(commandResult);
    writeToLog("testClearMultipleIndexes", resultAsString);
    assertEquals(Status.OK, commandResult.getStatus());
    csb = new CommandStringBuilder(CliStrings.DEFINE_INDEX);
    csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName + "2");
    csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
    csb.addOption(CliStrings.CREATE_INDEX__REGION, "/StocksParReg");
    csb = new CommandStringBuilder(CliStrings.CLEAR_DEFINED_INDEXES);
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(!resultAsString.contains(indexName));
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) 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)

Aggregations

CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)186 Test (org.junit.Test)88 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)87 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)71 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)47 VM (org.apache.geode.test.dunit.VM)41 File (java.io.File)39 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)37 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)36 Properties (java.util.Properties)16 Region (org.apache.geode.cache.Region)14 Category (org.junit.experimental.categories.Category)14 Cache (org.apache.geode.cache.Cache)12 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)12 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)11 IOException (java.io.IOException)10 UnknownHostException (java.net.UnknownHostException)7 HashMap (java.util.HashMap)6 RegionAttributes (org.apache.geode.cache.RegionAttributes)6 ClusterConfigurationService (org.apache.geode.distributed.internal.ClusterConfigurationService)6