Search in sources :

Example 46 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testMissingMemberRedundancy0.

/**
   * Test that we wait for missing data to come back if the redundancy was 0.
   */
@Test
public void testMissingMemberRedundancy0() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    createPR(vm0, 0);
    createPR(vm1, 0);
    createData(vm0, 0, NUM_BUCKETS, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    final int aVM0Bucket = vm0Buckets.iterator().next();
    final int aVM1Bucket = vm1Buckets.iterator().next();
    closeCache(vm1);
    IgnoredException ex = IgnoredException.addIgnoredException("PartitionOfflineException");
    try {
        checkReadWriteOperationsWithOfflineMember(vm0, aVM0Bucket, aVM1Bucket);
        // Make sure that a newly created member is informed about the offline member
        createPR(vm2, 0);
        checkReadWriteOperationsWithOfflineMember(vm2, aVM0Bucket, aVM1Bucket);
    } finally {
        ex.remove();
    }
    // This should work, because these are new buckets
    createData(vm0, NUM_BUCKETS, 113, "a");
    createPR(vm1, 0);
    // The data should be back online now.
    checkData(vm0, 0, 113, "a");
    closeCache(vm0);
    closeCache(vm1);
}
Also used : VM(org.apache.geode.test.dunit.VM) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 47 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testRevokeAfterStartup.

@Test
public void testRevokeAfterStartup() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    int numBuckets = 50;
    createPR(vm0, 1);
    createPR(vm1, 1);
    createData(vm0, 0, numBuckets, "a");
    Set<Integer> vm0Buckets = getBucketList(vm0);
    Set<Integer> vm1Buckets = getBucketList(vm1);
    assertEquals(vm0Buckets, vm1Buckets);
    closeCache(vm0);
    createData(vm1, 0, numBuckets, "b");
    closeCache(vm1);
    AsyncInvocation a1 = createPRAsync(vm0, 1);
    // [dsmith] Make sure that vm0 is waiting for vm1 to recover
    // If VM(0) recovers early, that is a problem, because vm1
    // has newer data
    Thread.sleep(500);
    assertTrue(a1.isAlive());
    revokeKnownMissingMembers(vm2, 1);
    a1.getResult(MAX_WAIT);
    assertEquals(vm0Buckets, getBucketList(vm0));
    checkData(vm0, 0, numBuckets, "a");
    createData(vm0, numBuckets, 113, "b");
    checkData(vm0, numBuckets, 113, "b");
    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;
        }
    }
    ex.remove();
}
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 48 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testChangedToalBucketNumberSinglePR.

/**
   * Test total-buckets-num getting bigger, which cause exception. but changed to smaller should be
   * ok.
   */
@Test
public void testChangedToalBucketNumberSinglePR() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    createPR(vm0, 0, 0, 5);
    createData(vm0, 0, 5, "a");
    closeCache(vm0);
    IgnoredException expect = IgnoredException.addIgnoredException("IllegalStateException", vm0);
    expect = IgnoredException.addIgnoredException("DiskAccessException", vm0);
    try {
        createPR(vm0, 0, 0, 2);
        fail("Expect to get java.lang.IllegalStateException, but it did not");
    } catch (RMIException exp) {
        assertTrue(exp.getCause() instanceof IllegalStateException);
        IllegalStateException ise = (IllegalStateException) exp.getCause();
        Object[] prms = new Object[] { "/" + PR_REGION_NAME, 2, 5 };
        assertTrue(ise.getMessage().contains(LocalizedStrings.PartitionedRegion_FOR_REGION_0_TotalBucketNum_1_SHOULD_NOT_BE_CHANGED_Previous_Configured_2.toString(prms)));
    }
    closeCache(vm0);
    try {
        createPR(vm0, 0, 0, 10);
        fail("Expect to get java.lang.IllegalStateException, but it did not");
    } catch (RMIException exp) {
        assertTrue(exp.getCause() instanceof IllegalStateException);
        IllegalStateException ise = (IllegalStateException) exp.getCause();
        Object[] prms = new Object[] { "/" + PR_REGION_NAME, 10, 5 };
        assertTrue(ise.getMessage().contains(LocalizedStrings.PartitionedRegion_FOR_REGION_0_TotalBucketNum_1_SHOULD_NOT_BE_CHANGED_Previous_Configured_2.toString(prms)));
    }
    expect.remove();
}
Also used : 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) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 49 with IgnoredException

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

the class PartitionedRegionMetaDataCleanupDUnitTest method testCrash.

@Test
public void testCrash() throws InterruptedException {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, "region1", 5);
    createPR(vm1, "region2", 10);
    // This should fail
    IgnoredException ex = IgnoredException.addIgnoredException("IllegalStateException", vm1);
    try {
        createPR(vm1, "region1", 10);
        fail("Should have received an exception");
    } catch (RMIException e) {
    // ok
    } finally {
        ex.remove();
    }
    ex = IgnoredException.addIgnoredException("DistributedSystemDisconnectedException", vm0);
    try {
        fakeCrash(vm0);
    } finally {
        ex.remove();
    }
    waitForCreate(vm0, "region1", 15);
}
Also used : 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) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 50 with IgnoredException

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

the class PartitionedRegionMetaDataCleanupDUnitTest method testCleanupOnCloseCache.

@Test
public void testCleanupOnCloseCache() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, "region1", 5);
    createPR(vm1, "region2", 10);
    // This should fail
    IgnoredException ex = IgnoredException.addIgnoredException("IllegalStateException", vm1);
    try {
        createPR(vm1, "region1", 10);
        fail("Should have received an exception");
    } catch (RMIException e) {
    // ok
    } finally {
        ex.remove();
    }
    closeCache(vm0);
    waitForCreate(vm0, "region1", 15);
}
Also used : 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) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

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