Search in sources :

Example 46 with AsyncInvocation

use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.

the class SerialWANPersistenceEnabledGatewaySenderDUnitTest method testPersistentReplicatedRegionWithGatewaySender_Restart.

/**
   * Enable persistence for Region. No persistence for GatewaySender. Kill the vm with regions and
   * bring that up again. Check if the remote site receives all the event. again?
   * 
   */
@Test
public void testPersistentReplicatedRegionWithGatewaySender_Restart() {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
    createCacheInVMs(nyPort, vm2, vm3);
    createReceiverInVMs(vm2, vm3);
    createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
    vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
    vm5.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
    vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR", null, isOffHeap()));
    vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR", null, isOffHeap()));
    startSenderInVMs("ln", vm4, vm5);
    vm4.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm5.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm6.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm7.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm4.invoke(() -> WANTestBase.pauseSender("ln"));
    vm5.invoke(() -> WANTestBase.pauseSender("ln"));
    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 1000));
    LogWriterUtils.getLogWriter().info("Completed puts in the region");
    // verify if the queue has all the events
    // vm4.invoke(() -> WANTestBase.checkQueueSize( "ln", 1000
    // ));
    // vm5.invoke(() -> WANTestBase.checkQueueSize( "ln", 1000
    // ));
    //
    // vm2.invoke(() -> WANTestBase.validateRegionSize(
    // testName + "_RR", 0 ));
    // vm3.invoke(() -> WANTestBase.validateRegionSize(
    // testName + "_RR", 0 ));
    // kill the vm
    vm4.invoke(() -> WANTestBase.killSender());
    vm5.invoke(() -> WANTestBase.killSender());
    LogWriterUtils.getLogWriter().info("Killed the sender. ");
    // restart the vm
    vm4.invoke(() -> WANTestBase.createCache(lnPort));
    vm5.invoke(() -> WANTestBase.createCache(lnPort));
    vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
    LogWriterUtils.getLogWriter().info("Created the sender.... in vm4 ");
    vm5.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
    LogWriterUtils.getLogWriter().info("Created the sender.... in vm5 ");
    vm4.invoke(() -> WANTestBase.startSender("ln"));
    LogWriterUtils.getLogWriter().info("Started the sender in vm 4");
    vm5.invoke(() -> WANTestBase.startSender("ln"));
    LogWriterUtils.getLogWriter().info("Started the sender in vm 5");
    AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm5.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    try {
        inv1.join();
    } catch (InterruptedException e) {
        fail("Got interrupted exception while waiting for startSender to finish.");
    }
    Wait.pause(5000);
    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 1000));
    vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR", 1000));
    vm3.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR", 1000));
}
Also used : AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 47 with AsyncInvocation

use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.

the class WanAutoDiscoveryDUnitTest method test_NY_Recognises_TK_AND_HK_Simultaneously.

// GEODE-1920
@Category(FlakyTest.class)
@Test
public void test_NY_Recognises_TK_AND_HK_Simultaneously() {
    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
    Set<InetSocketAddress> locatorPortsln = new HashSet<>();
    dsVsPort.put(1, locatorPortsln);
    Integer lnLocPort1 = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    locatorPortsln.add(new InetSocketAddress("localhost", lnLocPort1));
    Set<InetSocketAddress> locatorPortsny = new HashSet<>();
    dsVsPort.put(2, locatorPortsny);
    Integer nyLocPort1 = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnLocPort1));
    locatorPortsny.add(new InetSocketAddress("localhost", nyLocPort1));
    int AsyncInvocationArrSize = 4;
    AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
    Set<InetSocketAddress> locatorPortstk = new HashSet<>();
    dsVsPort.put(3, locatorPortstk);
    async[0] = vm2.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(3, lnLocPort1));
    Set<InetSocketAddress> locatorPortshk = new HashSet<>();
    dsVsPort.put(4, locatorPortshk);
    async[1] = vm3.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(4, nyLocPort1));
    ArrayList<Integer> locatorPortsln2 = new ArrayList<Integer>();
    async[2] = vm4.invokeAsync(() -> WANTestBase.createSecondLocator(1, lnLocPort1));
    ArrayList<Integer> locatorPortsny2 = new ArrayList<Integer>();
    async[3] = vm5.invokeAsync(() -> WANTestBase.createSecondLocator(2, nyLocPort1));
    try {
        async[0].join();
        async[1].join();
        async[2].join();
        async[3].join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        fail();
    }
    locatorPortstk.add(new InetSocketAddress("localhost", (Integer) async[0].getReturnValue()));
    locatorPortshk.add(new InetSocketAddress("localhost", (Integer) async[1].getReturnValue()));
    locatorPortsln.add(new InetSocketAddress("localhost", (Integer) async[2].getReturnValue()));
    locatorPortsny.add(new InetSocketAddress("localhost", (Integer) async[3].getReturnValue()));
    vm0.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
    vm1.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
    vm2.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
    vm3.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) 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)

Example 48 with AsyncInvocation

use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.

the class TestFunction method testPrimarySendersOnDifferentVMsPRSocketPolicy.

// Uses partitioned regions and conserve-sockets=true
// this always causes a distributed deadlock
@Test
public void testPrimarySendersOnDifferentVMsPRSocketPolicy() throws Exception {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstPeerLocator(1));
    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
    createCachesWith(Boolean.TRUE, nyPort, lnPort);
    createSerialSenders();
    createPartitionedRegions(nyPort);
    startSerialSenders();
    exerciseWANOperations();
    AsyncInvocation invVM4transaction = vm4.invokeAsync(() -> SerialGatewaySenderDistributedDeadlockDUnitTest.doTxPutsPR(getTestMethodName() + "_RR", 100, 1000));
    AsyncInvocation invVM5transaction = vm5.invokeAsync(() -> SerialGatewaySenderDistributedDeadlockDUnitTest.doTxPutsPR(getTestMethodName() + "_RR", 100, 1000));
    AsyncInvocation invVM4 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 1000));
    AsyncInvocation invVM5 = vm5.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 1000));
    exerciseFunctions();
    try {
        invVM4transaction.join();
        invVM5transaction.join();
        invVM4.join();
        invVM5.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 49 with AsyncInvocation

use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.

the class SerialGatewaySenderOperationsDUnitTest method testStartPauseResumeSerialGatewaySender.

@Test
public void testStartPauseResumeSerialGatewaySender() {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
    createCacheInVMs(nyPort, vm2, vm3);
    createReceiverInVMs(vm2, vm3);
    createSenderCaches(lnPort);
    createSenderVM4();
    createSenderVM5();
    createReceiverRegions();
    createSenderRegions();
    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 10));
    startSenderInVMs("ln", vm4, vm5);
    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 100));
    vm4.invoke(() -> WANTestBase.pauseSender("ln"));
    vm5.invoke(() -> WANTestBase.pauseSender("ln"));
    vm4.invoke(() -> SerialGatewaySenderOperationsDUnitTest.verifySenderPausedState("ln"));
    vm5.invoke(() -> SerialGatewaySenderOperationsDUnitTest.verifySenderPausedState("ln"));
    AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR", 10));
    vm4.invoke(() -> WANTestBase.resumeSender("ln"));
    vm5.invoke(() -> WANTestBase.resumeSender("ln"));
    vm4.invoke(() -> SerialGatewaySenderOperationsDUnitTest.verifySenderResumedState("ln"));
    vm5.invoke(() -> SerialGatewaySenderOperationsDUnitTest.verifySenderResumedState("ln"));
    try {
        inv1.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        fail("Interrupted the async invocation.");
    }
    LogWriterUtils.getLogWriter().info("Completed puts in the region");
    validateQueueContents(vm4, "ln", 0);
    validateQueueContents(vm5, "ln", 0);
    vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR", 100));
    vm3.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR", 100));
}
Also used : AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 50 with AsyncInvocation

use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.

the class SerialWANPropagationDUnitTest method testReplicatedSerialPropagationWithRemoteSiteBouncedBack_ReceiverPersistent.

@Test
public void testReplicatedSerialPropagationWithRemoteSiteBouncedBack_ReceiverPersistent() throws Exception {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
    // these are part of remote site
    createCacheInVMs(nyPort, vm2);
    vm2.invoke(() -> WANTestBase.createReceiver());
    // these are part of local site
    createCacheInVMs(lnPort, vm4, vm5);
    // senders are created on local site. Batch size is kept to a high (170) so
    // there will be less number of exceptions (occur during dispatchBatch) in
    // the log
    vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 350, false, false, null, true));
    // create one RR (RR_1) on remote site
    vm2.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
    // start the senders on local site
    vm4.invoke(() -> WANTestBase.startSender("ln"));
    // create one RR (RR_1) on local site
    vm4.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
    // start puts in RR_1 in another thread
    AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_1", 8000));
    // close cache in remote site. This will automatically kill the remote
    // receivers.
    Wait.pause(2000);
    vm1.invoke(() -> WANTestBase.shutdownLocator());
    vm2.invoke(() -> WANTestBase.closeCache());
    inv1.join();
    // Do some extra puts after cache close so that some events are in the queue.
    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_1", 1000));
    // verify that all is well in local site
    vm4.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 8000));
    vm4.invoke(() -> WANTestBase.verifyRegionQueueNotEmpty("ln"));
    vm1.invoke(() -> WANTestBase.bringBackLocatorOnOldPort(2, lnPort, nyPort));
    createCacheInVMs(nyPort, vm2);
    vm2.invoke(() -> WANTestBase.createPersistentReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
    vm2.invoke(() -> WANTestBase.createReceiver());
    vm4.invoke(() -> WANTestBase.validateQueueContents("ln", 0));
    vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 8000));
    vm2.invoke(() -> WANTestBase.checkMinimumGatewayReceiverStats(1, 1));
}
Also used : AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Aggregations

AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)314 Test (org.junit.Test)280 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)275 VM (org.apache.geode.test.dunit.VM)186 Host (org.apache.geode.test.dunit.Host)175 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)139 Region (org.apache.geode.cache.Region)87 CacheException (org.apache.geode.cache.CacheException)65 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)65 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)61 Cache (org.apache.geode.cache.Cache)44 AttributesFactory (org.apache.geode.cache.AttributesFactory)41 IgnoredException (org.apache.geode.test.dunit.IgnoredException)35 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)28 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)26 LocalRegion (org.apache.geode.internal.cache.LocalRegion)26 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)25 Ignore (org.junit.Ignore)25 Category (org.junit.experimental.categories.Category)25