Search in sources :

Example 56 with Category

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

the class WanCommandCreateGatewayReceiverDUnitTest method testCreateGatewayReceiver_onMultipleMembers.

/**
   * GatewayReceiver with given attributes on multiple members.
   */
// GEODE-1355
@Category(FlakyTest.class)
@Test
public void testCreateGatewayReceiver_onMultipleMembers() {
    VM puneLocator = Host.getLocator();
    int punePort = (Integer) puneLocator.invoke(() -> getLocatorPort());
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + punePort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, punePort));
    vm3.invoke(() -> createCache(punePort));
    vm4.invoke(() -> createCache(punePort));
    vm5.invoke(() -> createCache(punePort));
    final DistributedMember vm3Member = (DistributedMember) vm3.invoke(() -> getMember());
    final DistributedMember vm4Member = (DistributedMember) vm4.invoke(() -> getMember());
    String command = CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART + "=true" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__BINDADDRESS + "=localhost" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT + "=10000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MEMBER + "=" + vm3Member.getId() + "," + vm4Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
        List<String> status = resultData.retrieveAllValues("Status");
        assertEquals(2, status.size());
        // verify there is no error in the status
        for (int i = 0; i < status.size(); i++) {
            assertTrue("GatewayReceiver creation failed with: " + status.get(i), status.get(i).indexOf("ERROR:") == -1);
        }
    } else {
        fail("testCreateGatewayReceiver failed as did not get CommandResult");
    }
    vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null));
    vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost", 100000, 512000, null));
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) Properties(java.util.Properties) 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 57 with Category

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

the class WanCommandStatusDUnitTest method testGatewayReceiverStatus_OnMember.

// GEODE-1395
@Category(FlakyTest.class)
@Test
public void testGatewayReceiverStatus_OnMember() {
    Integer lnPort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
    Properties props = getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + lnPort + "]");
    setUpJmxManagerOnVm0ThenConnect(props);
    Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, lnPort));
    vm6.invoke(() -> createAndStartReceiver(nyPort));
    vm3.invoke(() -> createAndStartReceiver(lnPort));
    vm4.invoke(() -> createAndStartReceiver(lnPort));
    vm5.invoke(() -> createAndStartReceiver(lnPort));
    final DistributedMember vm3Member = (DistributedMember) vm3.invoke(() -> getMember());
    pause(10000);
    String command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__MEMBER + "=" + vm3Member.getId();
    CommandResult cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus : " + strCmdResult + ">>>>> ");
        assertEquals(Result.Status.OK, cmdResult.getStatus());
        // TabularResultData tableResultData = (TabularResultData) cmdResult.getResultData();
        // List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        // assertIndexDetailsEquals(1, result_Status.size());
        // assertFalse(strCmdResult.contains(CliStrings.GATEWAY_NOT_RUNNING));
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
    } else {
        fail("testGatewayReceiverStatus failed as did not get CommandResult");
    }
    vm3.invoke(() -> stopReceiver());
    vm4.invoke(() -> stopReceiver());
    vm5.invoke(() -> stopReceiver());
    pause(10000);
    command = CliStrings.STATUS_GATEWAYRECEIVER + " --" + CliStrings.STATUS_GATEWAYRECEIVER__MEMBER + "=" + vm3Member.getId();
    cmdResult = executeCommand(command);
    if (cmdResult != null) {
        String strCmdResult = commandResultToString(cmdResult);
        getLogWriter().info("testGatewayReceiverStatus : " + strCmdResult + ">>>>> ");
        // TabularResultData tableResultData =
        // (TabularResultData) cmdResult.getResultData();
        // List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        // assertIndexDetailsEquals(1, result_Status.size());
        // assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
        TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_RECEIVER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_RECEIVER);
        List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
        assertEquals(1, result_Status.size());
        assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
    } else {
        fail("testGatewayReceiverStatus failed as did not get CommandResult");
    }
}
Also used : TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) DistributedMember(org.apache.geode.distributed.DistributedMember) Properties(java.util.Properties) 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 58 with Category

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

the class RedisDistDUnitTest method testConcOps.

/**
   * Just make sure there are no unexpected server crashes
   */
// GEODE-1697
@Category(FlakyTest.class)
@Test
public void testConcOps() throws Exception {
    final int ops = 100;
    final String hKey = TEST_KEY + "hash";
    final String lKey = TEST_KEY + "list";
    final String zKey = TEST_KEY + "zset";
    final String sKey = TEST_KEY + "set";
    class ConcOps extends ClientTestBase {

        protected ConcOps(int port) {
            super(port);
        }

        @Override
        public Object call() throws Exception {
            Jedis jedis = new Jedis(localHost, port, JEDIS_TIMEOUT);
            Random r = new Random();
            for (int i = 0; i < ops; i++) {
                int n = r.nextInt(4);
                if (n == 0) {
                    jedis.hset(hKey, randString(), randString());
                    jedis.hgetAll(hKey);
                    jedis.hvals(hKey);
                } else if (n == 1) {
                    jedis.lpush(lKey, randString());
                    jedis.rpush(lKey, randString());
                    jedis.ltrim(lKey, 0, 100);
                    jedis.lrange(lKey, 0, -1);
                } else if (n == 2) {
                    jedis.zadd(zKey, r.nextDouble(), randString());
                    jedis.zrangeByLex(zKey, "(a", "[z");
                    jedis.zrangeByScoreWithScores(zKey, 0, 1, 0, 100);
                    jedis.zremrangeByScore(zKey, r.nextDouble(), r.nextDouble());
                } else {
                    jedis.sadd(sKey, randString());
                    jedis.smembers(sKey);
                    jedis.sdiff(sKey, "afd");
                    jedis.sunionstore("dst", sKey, "afds");
                }
            }
            return null;
        }
    }
    // Expect to run with no exception
    AsyncInvocation i = client1.invokeAsync(new ConcOps(server1Port));
    client2.invoke(new ConcOps(server2Port));
    i.getResult();
}
Also used : Jedis(redis.clients.jedis.Jedis) Random(java.util.Random) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) 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 59 with Category

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

the class CqPerfDUnitTest method testMatchingCqs.

/**
   * Test for common CQs. To test the changes relating to, executing CQ only once for all similar
   * CQs.
   * 
   * @throws Exception
   */
// GEODE-1164: random ports, thread sleeps, time sensitive, eats
@Category(FlakyTest.class)
// exceptions (fixed 1), async behavior
@Test
public void testMatchingCqs() throws Exception {
    final Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);
    cqDUnitTest.createServer(server);
    final int port = server.invoke(() -> CqQueryDUnitTest.getCacheServerPort());
    final String host0 = NetworkUtils.getServerHostName(server.getHost());
    cqDUnitTest.createClient(client, port, host0);
    // Create and Execute same kind of CQs.
    for (int i = 0; i < 4; i++) {
        cqDUnitTest.createCQ(client, "testMatchingCqs_" + i, cqDUnitTest.cqs[0]);
        cqDUnitTest.executeCQ(client, "testMatchingCqs_" + i, false, null);
    }
    validateMatchingCqs(server, 1, cqDUnitTest.cqs[0], 4);
    int size = 1;
    // Create.
    cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
    cqDUnitTest.waitForCreated(client, "testMatchingCqs_0", CqQueryDUnitTest.KEY + size);
    cqDUnitTest.waitForCreated(client, "testMatchingCqs_3", CqQueryDUnitTest.KEY + size);
    // Close one of the CQ.
    cqDUnitTest.closeCQ(client, "testMatchingCqs_0");
    validateMatchingCqs(server, 1, cqDUnitTest.cqs[0], 3);
    // Update.
    cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
    cqDUnitTest.waitForUpdated(client, "testMatchingCqs_3", CqQueryDUnitTest.KEY + size);
    // Stop one of the CQ.
    cqDUnitTest.stopCQ(client, "testMatchingCqs_1");
    validateMatchingCqs(server, 1, cqDUnitTest.cqs[0], 2);
    // Update - 2.
    cqDUnitTest.clearCQListenerEvents(client, "testMatchingCqs_3");
    cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
    cqDUnitTest.waitForUpdated(client, "testMatchingCqs_3", CqQueryDUnitTest.KEY + size);
    // stopped CQ should not receive 2nd/previous updates.
    cqDUnitTest.validateCQ(client, "testMatchingCqs_1", /* resultSize: */
    CqQueryDUnitTest.noTest, /* creates: */
    size, /* updates: once */
    size, /* deletes; */
    0, /* queryInserts: */
    size, /* queryUpdates: */
    size, /* queryDeletes: */
    0, /* totalEvents: */
    size * 2);
    // Execute the stopped CQ.
    cqDUnitTest.executeCQ(client, "testMatchingCqs_1", false, null);
    // Update - 3.
    cqDUnitTest.clearCQListenerEvents(client, "testMatchingCqs_3");
    cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
    cqDUnitTest.waitForUpdated(client, "testMatchingCqs_3", CqQueryDUnitTest.KEY + size);
    cqDUnitTest.validateCQ(client, "testMatchingCqs_1", /* resultSize: */
    CqQueryDUnitTest.noTest, /* creates: */
    size, /* updates: 2 */
    size * 2, /* deletes; */
    0, /* queryInserts: */
    size, /* queryUpdates: */
    size * 2, /* queryDeletes: */
    0, /* totalEvents: */
    size * 3);
    // Create different kind of CQs.
    cqDUnitTest.createCQ(client, "testMatchingCqs_4", cqDUnitTest.cqs[1]);
    cqDUnitTest.executeCQ(client, "testMatchingCqs_4", false, null);
    cqDUnitTest.createCQ(client, "testMatchingCqs_5", cqDUnitTest.cqs[1]);
    cqDUnitTest.executeCQ(client, "testMatchingCqs_5", false, null);
    cqDUnitTest.createCQ(client, "testMatchingCqs_6", cqDUnitTest.cqs[2]);
    cqDUnitTest.executeCQ(client, "testMatchingCqs_6", false, null);
    validateMatchingCqs(server, 3, cqDUnitTest.cqs[1], 2);
    cqDUnitTest.closeCQ(client, "testMatchingCqs_6");
    validateMatchingCqs(server, 2, cqDUnitTest.cqs[1], 2);
    cqDUnitTest.closeCQ(client, "testMatchingCqs_5");
    cqDUnitTest.closeCQ(client, "testMatchingCqs_4");
    cqDUnitTest.closeCQ(client, "testMatchingCqs_3");
    cqDUnitTest.closeCQ(client, "testMatchingCqs_2");
    cqDUnitTest.closeCQ(client, "testMatchingCqs_1");
    validateMatchingCqs(server, 0, null, 0);
    // update 4
    cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
    // Close.
    cqDUnitTest.closeClient(client);
    cqDUnitTest.closeServer(server);
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) 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 60 with Category

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

the class PrCqUsingPoolDUnitTest method testEventsDuringQueryExecution.

/**
   * Test for events created during the CQ query execution. When CQs are executed using
   * executeWithInitialResults there may be possibility that the region changes during that time may
   * not be reflected in the query result set thus making the query data and region data
   * inconsistent.
   * 
   * @throws Exception
   */
// GEODE-1181, 1253: random ports, eats exceptions (fixed some), async
@Category(FlakyTest.class)
// behavior
@Test
public void testEventsDuringQueryExecution() throws Exception {
    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM client = host.getVM(2);
    final String cqName = "testEventsDuringQueryExecution_0";
    // Server.
    createServer(server1);
    createServer(server2);
    final int port = server1.invoke(() -> PrCqUsingPoolDUnitTest.getCacheServerPort());
    final String host0 = NetworkUtils.getServerHostName(server1.getHost());
    String poolName1 = "testEventsDuringQueryExecution";
    createPool(client, poolName1, host0, port);
    // create CQ.
    createCQ(client, poolName1, cqName, cqs[0]);
    final int numObjects = 200;
    final int totalObjects = 500;
    // initialize Region.
    server1.invoke(new CacheSerializableRunnable("Update Region") {

        public void run2() throws CacheException {
            Region region = getCache().getRegion("/root/" + regions[0]);
            for (int i = 1; i <= numObjects; i++) {
                Portfolio p = new Portfolio(i);
                region.put("" + i, p);
            }
        }
    });
    // Keep updating region (async invocation).
    server1.invokeAsync(new CacheSerializableRunnable("Update Region") {

        public void run2() throws CacheException {
            Region region = getCache().getRegion("/root/" + regions[0]);
            for (int i = numObjects + 1; i <= totalObjects; i++) {
                Portfolio p = new Portfolio(i);
                region.put("" + i, p);
            }
        }
    });
    // Execute CQ while update is in progress.
    client.invoke(new CacheSerializableRunnable("Execute CQ") {

        public void run2() throws CacheException {
            QueryService cqService = getCache().getQueryService();
            // Get CqQuery object.
            CqQuery cq1 = cqService.getCq(cqName);
            if (cq1 == null) {
                fail("Failed to get CQ " + cqName);
            }
            SelectResults cqResults = null;
            try {
                cqResults = cq1.executeWithInitialResults();
            } catch (Exception ex) {
                throw new AssertionError("Failed to execute  CQ " + cqName, ex);
            }
            // getLogWriter().info("initial result size = " + cqResults.size());
            CqQueryTestListener cqListener = (CqQueryTestListener) cq1.getCqAttributes().getCqListener();
            // Wait for the last key to arrive.
            for (int i = 0; i < 4; i++) {
                try {
                    cqListener.waitForCreated("" + totalObjects);
                    // Found skip from the loop.
                    break;
                } catch (CacheException ex) {
                    if (i == 3) {
                        throw ex;
                    }
                }
            }
            // Check if the events from CqListener are in order.
            int oldId = 0;
            for (Object cqEvent : cqListener.events.toArray()) {
                int newId = new Integer(cqEvent.toString()).intValue();
                if (oldId > newId) {
                    fail("Queued events for CQ Listener during execution with " + "Initial results is not in the order in which they are created.");
                }
                oldId = newId;
            }
            // Check if all the IDs are present as part of Select Results and CQ Events.
            HashSet ids = new HashSet(cqListener.events);
            for (Object o : cqResults.asList()) {
                Struct s = (Struct) o;
                ids.add(s.get("key"));
            }
            // Iterator iter = cqResults.asSet().iterator();
            // while (iter.hasNext()) {
            // Portfolio p = (Portfolio)iter.next();
            // ids.add(p.getPk());
            // //getLogWriter().info("Result set value : " + p.getPk());
            // }
            HashSet missingIds = new HashSet();
            String key = "";
            for (int i = 1; i <= totalObjects; i++) {
                key = "" + i;
                if (!(ids.contains(key))) {
                    missingIds.add(key);
                }
            }
            if (!missingIds.isEmpty()) {
                fail("Missing Keys in either ResultSet or the Cq Event list. " + " Missing keys : [size : " + missingIds.size() + "]" + missingIds + " Ids in ResultSet and CQ Events :" + ids);
            }
        }
    });
    cqHelper.closeClient(client);
    cqHelper.closeServer(server2);
    cqHelper.closeServer(server1);
}
Also used : CacheException(org.apache.geode.cache.CacheException) Portfolio(org.apache.geode.cache.query.data.Portfolio) Host(org.apache.geode.test.dunit.Host) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) Struct(org.apache.geode.cache.query.Struct) SelectResults(org.apache.geode.cache.query.SelectResults) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) QueryService(org.apache.geode.cache.query.QueryService) VM(org.apache.geode.test.dunit.VM) Region(org.apache.geode.cache.Region) CqQuery(org.apache.geode.cache.query.CqQuery) HashSet(java.util.HashSet) 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)

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