Search in sources :

Example 91 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testDiskConflictWithRedundancy.

@Test
public void testDiskConflictWithRedundancy() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, 1);
    // create some buckets
    createData(vm0, 0, 2, "a");
    closePR(vm0);
    createPR(vm1, 1);
    // create an overlapping bucket
    createData(vm1, 1, 2, "a");
    IgnoredException[] expectVm0 = { IgnoredException.addIgnoredException("ConflictingPersistentDataException", vm0), IgnoredException.addIgnoredException("CacheClosedException", vm0) };
    try {
        createPR(vm0, 1);
        fail("should have seen a conflicting data exception");
    } catch (Exception ex) {
        boolean expectedException = false;
        if (ex.getCause() instanceof CacheClosedException) {
            CacheClosedException cce = (CacheClosedException) ex.getCause();
            if (cce.getCause() instanceof ConflictingPersistentDataException) {
                expectedException = true;
            }
        }
        if (!expectedException) {
            throw ex;
        }
    } finally {
        for (IgnoredException ie : expectVm0) {
            ie.remove();
        }
    }
    closePR(vm1);
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) Host(org.apache.geode.test.dunit.Host) CacheClosedException(org.apache.geode.cache.CacheClosedException) RevokeFailedException(org.apache.geode.cache.persistence.RevokeFailedException) RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) ConflictingPersistentDataException(org.apache.geode.cache.persistence.ConflictingPersistentDataException) DiskAccessException(org.apache.geode.cache.DiskAccessException) ConcurrentModificationException(java.util.ConcurrentModificationException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) RMIException(org.apache.geode.test.dunit.RMIException) CacheClosedException(org.apache.geode.cache.CacheClosedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) ReplyException(org.apache.geode.distributed.internal.ReplyException) QueryException(org.apache.geode.cache.query.QueryException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 92 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testBug42226.

/**
   * Test for bug 4226. 1. Member A has the bucket 2. Member B starts creating the bucket. It tells
   * member A that it hosts the bucket 3. Member A crashes 4. Member B destroys the bucket and
   * throws a partition offline exception, because it wasn't able to complete initialization. 5.
   * Member A recovers, and gets stuck waiting for member B.
   * 
   * @throws Throwable
   */
// GEODE-1208: time sensitive, multiple non-thread-safe test hooks,
@Category(FlakyTest.class)
// async actions
@Test
public void testBug42226() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    // Add a hook which will disconnect from the distributed
    // system when the initial image message shows up.
    vm0.invoke(new SerializableRunnable() {

        public void run() {
            DistributionMessageObserver.setInstance(new DistributionMessageObserver() {

                @Override
                public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
                    if (message instanceof RequestImageMessage) {
                        RequestImageMessage rim = (RequestImageMessage) message;
                        // Don't disconnect until we see a bucket
                        if (rim.regionPath.contains("_B_")) {
                            DistributionMessageObserver.setInstance(null);
                            disconnectFromDS();
                        }
                    }
                }

                @Override
                public void afterProcessMessage(DistributionManager dm, DistributionMessage message) {
                }
            });
        }
    });
    LogWriterUtils.getLogWriter().info("Creating region in VM0");
    createPR(vm0, 1, 0, 1);
    // Make sure we create a bucket
    createData(vm0, 0, 1, "a");
    // This should recover redundancy, which should cause vm0 to disconnect
    IgnoredException ex = IgnoredException.addIgnoredException("PartitionOfflineException");
    try {
        LogWriterUtils.getLogWriter().info("Creating region in VM1");
        createPR(vm1, 1, 0, 1);
        // Make sure get a partition offline exception
        try {
            createData(vm1, 0, 1, "a");
        } catch (RMIException e) {
            // We expect a PartitionOfflineException
            if (!(e.getCause() instanceof PartitionOfflineException)) {
                throw e;
            }
        }
    } finally {
        ex.remove();
    }
    // Make sure vm0 is really disconnected (avoids a race with the observer).
    vm0.invoke(new SerializableRunnable() {

        public void run() {
            disconnectFromDS();
        }
    });
    // This should recreate the bucket
    AsyncInvocation async1 = createPRAsync(vm0, 1, 0, 1);
    async1.getResult(MAX_WAIT);
    checkData(vm1, 0, 1, "a");
}
Also used : RMIException(org.apache.geode.test.dunit.RMIException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) RequestImageMessage(org.apache.geode.internal.cache.InitialImageOperation.RequestImageMessage) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) 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 93 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testRevokedMemberRedundancy1.

/**
   * Test to make sure that we recreate a bucket if a member is revoked
   * 
   * @throws Throwable
   */
@Test
public void testRevokedMemberRedundancy1() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    createPR(vm0, 1);
    createPR(vm1, 1);
    createData(vm0, 0, NUM_BUCKETS, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    assertEquals(vm0Buckets, vm1Buckets);
    closeCache(vm1);
    // This should work, because this bucket is still available.
    checkData(vm0, 0, NUM_BUCKETS, "a");
    createData(vm0, 0, NUM_BUCKETS, "b");
    revokeKnownMissingMembers(vm2, 1);
    // This should make a copy of all of the buckets,
    // because we have revoked VM1.
    createPR(vm2, 1);
    Set<Integer> vm2Buckets = getBucketList(vm2);
    assertEquals(vm1Buckets, vm2Buckets);
    IgnoredException ex = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getName(), vm1);
    try {
        createPR(vm1, 1);
        fail("Should have recieved a SplitDistributedSystemException");
    } catch (RMIException e) {
        // We revoked this member.
        if (!(e.getCause() instanceof RevokedPersistentDataException)) {
            throw e;
        }
    }
    // Test that we can bounce vm0 and vm1, and still get a RevokedPersistentDataException
    // when vm1 tries to recover
    closeCache(vm0);
    closeCache(vm2);
    AsyncInvocation async0 = createPRAsync(vm0, 1);
    AsyncInvocation async2 = createPRAsync(vm2, 1);
    async0.getResult();
    async2.getResult();
    try {
        createPR(vm1, 1);
        fail("Should have recieved a RevokedPersistentDataException");
    } catch (RMIException e) {
        // We revoked this member.
        if (!(e.getCause() instanceof RevokedPersistentDataException)) {
            throw e;
        }
    }
    ex.remove();
    // The data shouldn't be affected.
    checkData(vm2, 0, NUM_BUCKETS, "b");
}
Also used : RevokedPersistentDataException(org.apache.geode.cache.persistence.RevokedPersistentDataException) RMIException(org.apache.geode.test.dunit.RMIException) VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 94 with IgnoredException

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

the class UpdateVersionDUnitTest method closeCache.

private static void closeCache() {
    if (cache != null && !cache.isClosed()) {
        for (IgnoredException expectedException : expectedExceptions) {
            cache.getLogger().info(expectedException.getRemoveMessage());
        }
        expectedExceptions.clear();
        cache.getDistributedSystem().disconnect();
        cache.close();
    }
    cache = null;
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException)

Example 95 with IgnoredException

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

the class UpdateVersionDUnitTest method createCache.

/*
   * Helper Methods
   */
private static void createCache(Integer locPort) {
    UpdateVersionDUnitTest test = new UpdateVersionDUnitTest();
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + locPort + "]");
    props.setProperty(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
    props.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
    props.setProperty(USE_CLUSTER_CONFIGURATION, "false");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    IgnoredException ex = new IgnoredException("could not get remote locator information for remote site");
    cache.getLogger().info(ex.getAddMessage());
    expectedExceptions.add(ex);
    ex = new IgnoredException("Pool ln1 is not available");
    cache.getLogger().info(ex.getAddMessage());
    expectedExceptions.add(ex);
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

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