Search in sources :

Example 1 with IgnoredException

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

the class WANTestBase method validateQueueContents.

public static void validateQueueContents(final String senderId, final int regionSize) {
    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
    IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
    try {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        GatewaySender sender = null;
        for (GatewaySender s : senders) {
            if (s.getId().equals(senderId)) {
                sender = s;
                break;
            }
        }
        if (!sender.isParallel()) {
            final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
            Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> {
                int size = 0;
                for (RegionQueue q : queues) {
                    size += q.size();
                }
                assertEquals("Expected queue entries: " + regionSize + " but actual entries: " + size, regionSize, size);
            });
        } else if (sender.isParallel()) {
            final RegionQueue regionQueue;
            regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
            Awaitility.await().atMost(120, TimeUnit.SECONDS).until(() -> assertEquals("Expected queue entries: " + regionSize + " but actual entries: " + regionQueue.size(), regionSize, regionQueue.size()));
        }
    } finally {
        exp1.remove();
        exp2.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 2 with IgnoredException

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

the class PDXNewWanDUnitTest method testWANPDX_ConflictingData.

/**
   * Test 1> Site 1 : 1 locator, 1 member 2> Site 2 : 1 locator, 1 member 3> DR is defined on member
   * 1 on site1 4> Serial GatewaySender is defined on member 1 on site1 5> Same DR is defined on
   * site2 member 1 6> Put is done with value which is PDXSerializable 7> Validate whether other
   * sites member receive this put operation. 8> Bounce site 1 and delete all of it's data 9> Make
   * some conflicting PDX registries in site 1 before the reconnect 10> Make sure we flag a warning
   * about the conflicting updates.
   */
@Test
public void testWANPDX_ConflictingData() {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
    vm2.invoke(() -> WANTestBase.createReceiver_PDX(nyPort));
    vm3.invoke(() -> WANTestBase.createCache_PDX(lnPort));
    vm3.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
    vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR", null, isOffHeap()));
    vm3.invoke(() -> WANTestBase.startSender("ln"));
    vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
    vm3.invoke(() -> WANTestBase.doPutsPDXSerializable(getTestMethodName() + "_RR", 1));
    vm2.invoke(() -> WANTestBase.validateRegionSize_PDX(getTestMethodName() + "_RR", 1));
    // bounce vm3
    vm3.invoke(() -> WANTestBase.closeCache());
    IgnoredException ex1 = IgnoredException.addIgnoredException("Trying to add a PDXType with the same id");
    IgnoredException ex2 = IgnoredException.addIgnoredException("CacheWriterException");
    IgnoredException ex3 = IgnoredException.addIgnoredException("does match the existing PDX type");
    IgnoredException ex4 = IgnoredException.addIgnoredException("ServerOperationException");
    IgnoredException ex5 = IgnoredException.addIgnoredException("Stopping the processor");
    try {
        // blow away vm3's PDX data
        vm3.invoke(() -> WANTestBase.deletePDXDir());
        vm3.invoke(() -> WANTestBase.createCache_PDX(lnPort));
        vm3.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 10, false, false, null, true));
        vm3.invoke(() -> WANTestBase.startSender("ln"));
        vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR", "ln", isOffHeap()));
        // Define a different type from vm3
        vm3.invoke(() -> WANTestBase.doPutsPDXSerializable2(getTestMethodName() + "_RR", 2));
        // Give the updates some time to make it over the WAN
        Wait.pause(10000);
        vm2.invoke(() -> WANTestBase.validateRegionSizeOnly_PDX(getTestMethodName() + "_RR", 2));
        vm3.invoke(() -> WANTestBase.closeCache());
    } finally {
        ex1.remove();
        ex2.remove();
        ex3.remove();
        ex4.remove();
        ex5.remove();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 3 with IgnoredException

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

the class ReplicatedRegion_ParallelWANPropagationDUnitTest method doPuts1.

public static void doPuts1(String regionName, int numPuts) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
    try {
        Region r = cache.getRegion(Region.SEPARATOR + regionName);
        assertNotNull(r);
        for (long i = 0; i < numPuts; i++) {
            LogWriterUtils.getLogWriter().info("Put : key : " + i);
            r.put(i, "1_" + i);
        }
    } finally {
        exp.remove();
        exp1.remove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) CacheClosedException(org.apache.geode.cache.CacheClosedException)

Example 4 with IgnoredException

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

the class ReplicatedRegion_ParallelWANPropagationDUnitTest method doPuts2.

public static void doPuts2(String regionName, int numPuts) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
    try {
        Region r = cache.getRegion(Region.SEPARATOR + regionName);
        assertNotNull(r);
        for (long i = 0; i < numPuts; i++) {
            LogWriterUtils.getLogWriter().info("Put : key : " + i);
            r.put(i, "2_" + i);
        }
    } finally {
        exp.remove();
        exp1.remove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) CacheClosedException(org.apache.geode.cache.CacheClosedException)

Example 5 with IgnoredException

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

the class WANTestBase method doPuts.

public static void doPuts(String regionName, int numPuts, Object value) {
    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
    IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
    try {
        Region r = cache.getRegion(Region.SEPARATOR + regionName);
        assertNotNull(r);
        for (long i = 0; i < numPuts; i++) {
            r.put(i, value);
        }
    } finally {
        exp1.remove();
        exp2.remove();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region)

Aggregations

IgnoredException (org.apache.geode.test.dunit.IgnoredException)142 Test (org.junit.Test)89 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)71 Region (org.apache.geode.cache.Region)46 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)46 VM (org.apache.geode.test.dunit.VM)43 Host (org.apache.geode.test.dunit.Host)38 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)34 AttributesFactory (org.apache.geode.cache.AttributesFactory)30 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)28 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)23 IOException (java.io.IOException)21 CacheClosedException (org.apache.geode.cache.CacheClosedException)21 LocalRegion (org.apache.geode.internal.cache.LocalRegion)20 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)16 RMIException (org.apache.geode.test.dunit.RMIException)15 GatewaySender (org.apache.geode.cache.wan.GatewaySender)14 BucketRegion (org.apache.geode.internal.cache.BucketRegion)14 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)14 CacheXmlException (org.apache.geode.cache.CacheXmlException)12