Search in sources :

Example 96 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class IndexCommandsDUnitTest method testDestroyIndexWithoutIndexName.

// GEODE-1315
@Category(FlakyTest.class)
@Test
public void testDestroyIndexWithoutIndexName() {
    setupSystem();
    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");
    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
    String commandString = csb.toString();
    CommandResult commandResult = executeCommand(commandString);
    String resultAsString = commandResultToString(commandResult);
    assertEquals(commandResult.getStatus(), Status.OK);
    csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    assertEquals(true, resultAsString.contains(indexName));
    assertEquals(true, resultAsString.contains(VM1Name));
    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
    csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group1);
    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());
    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");
    csb.addOption(CliStrings.CREATE_INDEX__TYPE, "hash");
    commandString = csb.toString();
    commandResult = executeCommand(commandString);
    resultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
    csb.addOption(CliStrings.DESTROY_INDEX__REGION, "StocksParReg");
    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(CliStrings.LIST_INDEX__INDEXES_NOT_FOUND_MESSAGE));
}
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)

Example 97 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class ListAndDescribeRegionDUnitTest method testDescribeRegionWithCompressionCodec.

/**
   * Asserts that a describe region command issued on a region with compression returns the correct
   * non default region attribute for compression and the correct codec value.
   */
// GEODE-1033: HeadlesssGFSH, random port, Snappy dependency
@Category(FlakyTest.class)
@Test
public void testDescribeRegionWithCompressionCodec() {
    final String regionName = "compressedRegion";
    VM vm = Host.getHost(0).getVM(1);
    setupSystem();
    // Create compressed region
    vm.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCompressedRegion(regionName);
        }
    });
    // Test the describe command; look for compression
    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
    csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
    String commandString = csb.toString();
    CommandResult commandResult = executeCommand(commandString);
    String commandResultAsString = commandResultToString(commandResult);
    assertEquals(Status.OK, commandResult.getStatus());
    assertTrue(commandResultAsString.contains(regionName));
    assertTrue(commandResultAsString.contains(RegionAttributesNames.COMPRESSOR));
    assertTrue(commandResultAsString.contains(RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER));
    // Destroy compressed region
    vm.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            Region region = getCache().getRegion(regionName);
            assertNotNull(region);
            region.destroyRegion();
        }
    });
}
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) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 98 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class MiscellaneousCommandsDUnitTest method testShutDownForTIMEOUT.

// GEODE-1385, 1518: time sensitive, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testShutDownForTIMEOUT() {
    setupForShutDown();
    ThreadUtils.sleep(2500);
    final VM vm0 = Host.getHost(0).getVM(0);
    vm0.invoke(new SerializableRunnable() {

        public void run() {
            System.setProperty("ThrowTimeoutException", "true");
        }
    });
    String command = "shutdown --time-out=15";
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String cmdResultStr = commandResultToString(cmdResult);
        getLogWriter().info("testShutDownForTIMEOUT cmdResultStr = " + cmdResultStr);
        CommandResult result = (CommandResult) ResultBuilder.createInfoResult(CliStrings.SHUTDOWN_TIMEDOUT);
        String expectedResult = commandResultToString(result);
        assertEquals(expectedResult, cmdResultStr);
    }
    vm0.invoke(new SerializableRunnable() {

        public void run() {
            System.clearProperty("ThrowTimeoutException");
        }
    });
}
Also used : Invoke.invokeInEveryVM(org.apache.geode.test.dunit.Invoke.invokeInEveryVM) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 99 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class MiscellaneousCommandsDUnitTest method testChangeLogLevelForMembers.

// GEODE-1605
@Category(FlakyTest.class)
@Test
public void testChangeLogLevelForMembers() {
    final VM vm0 = Host.getHost(0).getVM(0);
    final VM vm1 = Host.getHost(0).getVM(1);
    setupForChangeLogLelvel();
    String serverName1 = (String) vm0.invoke(new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            cachedLogLevel = System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "log-level");
            return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
        }
    });
    String serverName2 = (String) vm1.invoke(new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            cachedLogLevel = System.getProperty(DistributionConfig.GEMFIRE_PREFIX + "log-level");
            return GemFireCacheImpl.getInstance().getDistributedSystem().getDistributedMember().getId();
        }
    });
    String commandString = CliStrings.CHANGE_LOGLEVEL + " --" + CliStrings.CHANGE_LOGLEVEL__LOGLEVEL + "=finer" + " --" + CliStrings.CHANGE_LOGLEVEL__MEMBER + "=" + serverName1 + "," + serverName2;
    CommandResult commandResult = executeCommand(commandString);
    getLogWriter().info("testChangeLogLevel commandResult=" + commandResult);
    assertTrue(Status.OK.equals(commandResult.getStatus()));
    CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
    SectionResultData section = resultData.retrieveSection("section");
    assertNotNull(section);
    TabularResultData tableRsultData = section.retrieveTable("ChangeLogLevel");
    assertNotNull(tableRsultData);
    List<String> columns = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_MEMBER);
    List<String> status = tableRsultData.retrieveAllValues(CliStrings.CHANGE_LOGLEVEL__COLUMN_STATUS);
    assertEquals(columns.size(), 2);
    assertEquals(status.size(), 2);
    assertTrue(columns.contains(serverName1));
    assertTrue(columns.contains(serverName2));
    assertTrue(status.contains("true"));
}
Also used : Invoke.invokeInEveryVM(org.apache.geode.test.dunit.Invoke.invokeInEveryVM) SectionResultData(org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 100 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class GemfireDataCommandsDUnitTest method testSimulateForEntireDS.

// GEODE-1561
@Category(FlakyTest.class)
@Test
public void testSimulateForEntireDS() {
    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("testSimulateForEntireDS verified MBean and executing command");
    String command = "rebalance --simulate=true";
    CommandResult cmdResult = executeCommand(command);
    getLogWriter().info("testSimulateForEntireDS just after executing " + cmdResult);
    if (cmdResult != null) {
        String stringResult = commandResultToString(cmdResult);
        getLogWriter().info("testSimulateForEntireDS 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)

Aggregations

Category (org.junit.experimental.categories.Category)900 Test (org.junit.Test)856 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)148 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)121 File (java.io.File)102 Instant (org.joda.time.Instant)92 KV (org.apache.beam.sdk.values.KV)86 ArrayList (java.util.ArrayList)84 Row (org.apache.beam.sdk.values.Row)71 Schema (org.apache.beam.sdk.schemas.Schema)65 VM (org.apache.geode.test.dunit.VM)65 QuickTest (com.hazelcast.test.annotation.QuickTest)57 List (java.util.List)57 Matchers.containsString (org.hamcrest.Matchers.containsString)55 InputStream (java.io.InputStream)49 NightlyTest (com.hazelcast.test.annotation.NightlyTest)47 FileListView (com.owncloud.android.test.ui.models.FileListView)46 UsesSchema (org.apache.beam.sdk.testing.UsesSchema)43 StringUtils.byteArrayToJsonString (org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString)41 IOException (java.io.IOException)40