Search in sources :

Example 96 with IgnoredException

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

the class MyFunctionException method testDistributedRegionFunctionExecutionOnDataPolicyEmpty_ClientServer_NoLastResult.

// GEODE-632: random ports, eats exceptions
@Category(FlakyTest.class)
@Test
public void testDistributedRegionFunctionExecutionOnDataPolicyEmpty_ClientServer_NoLastResult() {
    VM empty1 = replicate3;
    VM empty2 = normal;
    empty2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    replicate1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    replicate2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    empty1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    createCacheInClientVm();
    Integer port1 = (Integer) empty1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createServer(DataPolicy.EMPTY));
    Integer port2 = (Integer) empty2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createServer(DataPolicy.EMPTY));
    replicate1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createPeer(DataPolicy.REPLICATE));
    replicate2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createPeer(DataPolicy.REPLICATE));
    createClientAndPopulateClientRegion(DataPolicy.EMPTY, port1, port2);
    // add ExpectedException's to servers since client can connect to any
    // one of those
    final IgnoredException expectedEx = IgnoredException.addIgnoredException("did not send last result", empty1);
    final IgnoredException expectedEx2 = IgnoredException.addIgnoredException("did not send last result", empty2);
    try {
        executeFunction_NoLastResult();
    } finally {
        expectedEx.remove();
        expectedEx2.remove();
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) 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 IgnoredException

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

the class MyFunctionException method testDistributedRegionFunctionExecutionOnDataPolicyReplicate_ClientServer_FunctionInvocationTargetException_WithoutHA.

@Test
public void testDistributedRegionFunctionExecutionOnDataPolicyReplicate_ClientServer_FunctionInvocationTargetException_WithoutHA() {
    VM empty = replicate3;
    normal.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    replicate1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    replicate2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    empty.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createCacheInVm());
    createCacheInClientVm();
    registerFunction(new Boolean(false), new Integer(0));
    Integer port1 = (Integer) replicate1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createServer(DataPolicy.REPLICATE));
    Integer port2 = (Integer) replicate2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createServer(DataPolicy.REPLICATE));
    normal.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createPeer(DataPolicy.NORMAL));
    empty.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.createPeer(DataPolicy.EMPTY));
    replicate1.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.registerFunction(new Boolean(false), new Integer(0)));
    replicate2.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.registerFunction(new Boolean(false), new Integer(0)));
    normal.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.registerFunction(new Boolean(false), new Integer(0)));
    empty.invoke(() -> DistributedRegionFunctionExecutionDUnitTest.registerFunction(new Boolean(false), new Integer(0)));
    createClientAndPopulateClientRegion(DataPolicy.EMPTY, port1, port2);
    // add expected exception to avoid suspect strings
    final IgnoredException ex = IgnoredException.addIgnoredException("I have been thrown");
    executeFunctionFunctionInvocationTargetException_ClientServer_WithoutHA();
    ex.remove();
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 98 with IgnoredException

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

the class PRColocationDUnitTest method testColocatedPRWithLocalDestroy.

@Test
public void testColocatedPRWithLocalDestroy() throws Throwable {
    createCacheInAllVms();
    redundancy = new Integer(0);
    localMaxmemory = new Integer(50);
    totalNumBuckets = new Integer(11);
    // Create Customer PartitionedRegion in All VMs
    regionName = CustomerPartitionedRegionName;
    colocatedWith = null;
    isPartitionResolver = new Boolean(false);
    attributeObjects = new Object[] { regionName, redundancy, localMaxmemory, totalNumBuckets, colocatedWith, isPartitionResolver };
    createPartitionedRegion(attributeObjects);
    // Create Order PartitionedRegion in All VMs
    regionName = OrderPartitionedRegionName;
    colocatedWith = CustomerPartitionedRegionName;
    isPartitionResolver = new Boolean(false);
    attributeObjects = new Object[] { regionName, redundancy, localMaxmemory, totalNumBuckets, colocatedWith, isPartitionResolver };
    createPartitionedRegion(attributeObjects);
    // Put the customer 1-10 in CustomerPartitionedRegion
    accessor.invoke(() -> PRColocationDUnitTest.putCustomerPartitionedRegion(CustomerPartitionedRegionName));
    // Put the order 1-10 for each Customer in OrderPartitionedRegion
    accessor.invoke(() -> PRColocationDUnitTest.putOrderPartitionedRegion(OrderPartitionedRegionName));
    // add expected exception string
    final String expectedExMessage = "Any Region in colocation chain cannot be destroyed locally.";
    final IgnoredException ex = IgnoredException.addIgnoredException(expectedExMessage, dataStore1);
    dataStore1.invoke(new CacheSerializableRunnable("PR with Local destroy") {

        @Override
        public void run2() {
            Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + OrderPartitionedRegionName);
            try {
                partitionedregion.localDestroyRegion();
                fail("It should have thrown an Exception saying: " + expectedExMessage);
            } catch (Exception Expected) {
                LogWriterUtils.getLogWriter().info("Expected Messageee : " + Expected.getMessage());
                assertTrue(Expected.getMessage().contains(expectedExMessage));
            }
        }
    });
    dataStore1.invoke(new CacheSerializableRunnable("PR with Local Destroy") {

        @Override
        public void run2() {
            Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + CustomerPartitionedRegionName);
            try {
                partitionedregion.localDestroyRegion();
                fail("It should have thrown an Exception saying: " + expectedExMessage);
            } catch (Exception Expected) {
                LogWriterUtils.getLogWriter().info("Expected Messageee : " + Expected.getMessage());
                assertTrue(Expected.getMessage().contains(expectedExMessage));
            }
        }
    });
    ex.remove();
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) IgnoredException(org.apache.geode.test.dunit.IgnoredException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 99 with IgnoredException

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

the class WANTestBase method validateParallelSenderQueueAllBucketsDrained.

public static void validateParallelSenderQueueAllBucketsDrained(final String senderId) {
    IgnoredException exp = IgnoredException.addIgnoredException(RegionDestroyedException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        GatewaySender sender = null;
        for (GatewaySender s : senders) {
            if (s.getId().equals(senderId)) {
                sender = s;
                break;
            }
        }
        RegionQueue regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
        Set<BucketRegion> buckets = ((PartitionedRegion) regionQueue.getRegion()).getDataStore().getAllLocalPrimaryBucketRegions();
        for (final BucketRegion bucket : buckets) {
            Awaitility.await().atMost(180, TimeUnit.SECONDS).until(() -> {
                assertEquals("Expected bucket entries for bucket: " + bucket.getId() + " is: 0 but actual entries: " + bucket.keySet().size() + " This bucket isPrimary: " + bucket.getBucketAdvisor().isPrimary() + " KEYSET: " + bucket.keySet(), 0, bucket.keySet().size());
            });
        }
    // for loop ends
    } finally {
        exp.remove();
        exp1.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) BucketRegion(org.apache.geode.internal.cache.BucketRegion) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 100 with IgnoredException

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

the class WANTestBase method validateRegionSize.

public static void validateRegionSize(String regionName, final int regionSize, long waitTimeInMilliSec) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
    try {
        final Region r = cache.getRegion(Region.SEPARATOR + regionName);
        assertNotNull(r);
        if (regionSize != r.keySet().size()) {
            Awaitility.await().atMost(waitTimeInMilliSec, TimeUnit.MILLISECONDS).pollInterval(500, TimeUnit.MILLISECONDS).until(() -> assertEquals("Expected region entries: " + regionSize + " but actual entries: " + r.keySet().size() + " present region keyset " + r.keySet(), regionSize, r.keySet().size()));
        }
    } finally {
        exp.remove();
        exp1.remove();
    }
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) 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) CacheClosedException(org.apache.geode.cache.CacheClosedException)

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