Search in sources :

Example 51 with IgnoredException

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

the class PartitionedRegionMetaDataCleanupDUnitTest method testCleanupOnCloseRegion.

@Test
public void testCleanupOnCloseRegion() {
    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();
    }
    closePr(vm0, "region1");
    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 52 with IgnoredException

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

the class PersistentRecoveryOrderDUnitTest method testSplitBrain.

@Test
public void testSplitBrain() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPersistentRegion(vm0);
    putAnEntry(vm0);
    closeRegion(vm0);
    createPersistentRegion(vm1);
    updateTheEntry(vm1);
    closeRegion(vm1);
    // VM0 doesn't know that VM1 ever existed
    // so it will start up.
    createPersistentRegion(vm0);
    IgnoredException e = IgnoredException.addIgnoredException(ConflictingPersistentDataException.class.getSimpleName(), vm1);
    try {
        // VM1 should not start up, because we should detect that vm1
        // was never in the same distributed system as vm0
        createPersistentRegion(vm1);
        fail("Should have thrown an exception, vm1 is from a 'different' distributed system");
    } catch (RuntimeException ok) {
        if (!(ok.getCause() instanceof ConflictingPersistentDataException)) {
            throw ok;
        }
    } finally {
        e.remove();
    }
}
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) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 53 with IgnoredException

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

the class DSObjectLocalOnly method testDataSerializersWithServerKillAndReInvoked.

@Test
public void testDataSerializersWithServerKillAndReInvoked() throws Exception {
    PORT1 = initServerCache(server1);
    PORT2 = initServerCache(server2);
    client1.invoke(() -> DataSerializerPropogationDUnitTest.createClientCache(NetworkUtils.getServerHostName(server1.getHost()), new Integer(PORT1)));
    client2.invoke(() -> DataSerializerPropogationDUnitTest.createClientCache(NetworkUtils.getServerHostName(server2.getHost()), new Integer(PORT2)));
    client1.invoke(() -> DataSerializerPropogationDUnitTest.registerDSObject7());
    client1.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithOnePut)));
    server1.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithOnePut)));
    server2.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithOnePut)));
    client2.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithOnePut)));
    // can get server connectivity exception
    final IgnoredException expectedEx = IgnoredException.addIgnoredException("Server unreachable", client1);
    server1.invoke(() -> DataSerializerPropogationDUnitTest.stopServer());
    try {
        client1.invoke(() -> DataSerializerPropogationDUnitTest.registerDSObject8());
    } catch (Exception e) {
    // we are putting in a client whose server is dead
    }
    try {
        client1.invoke(() -> DataSerializerPropogationDUnitTest.registerDSObject9());
    } catch (Exception e) {
    // we are putting in a client whose server is
    // dead
    }
    server1.invoke(() -> DataSerializerPropogationDUnitTest.startServer());
    client1.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithAllPuts)));
    server1.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithAllPuts)));
    server2.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithAllPuts)));
    client1.invoke(() -> DataSerializerPropogationDUnitTest.verifyDataSerializers(new Integer(instanceCountWithAllPuts)));
    expectedEx.remove();
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 54 with IgnoredException

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

the class DurableClientReconnectDUnitTest method testDurableReconnectWithBothNonRedundantServersDown.

@Test
public void testDurableReconnectWithBothNonRedundantServersDown() throws Exception {
    // create client cache and Send clientReady message
    createCacheClient();
    HashSet redundantServers = new HashSet(pool.getRedundantNames());
    redundantServers.add(pool.getPrimaryName());
    assertTrue(redundantServers.size() == 2);
    instance.determineAndVerfiyRedundantServers(redundantServers);
    instance.determineAndVerfiyNonRedundantServers(redundantServers);
    // Stop the durable client
    closeCache(true);
    Set nonRedundantSet = new HashSet();
    nonRedundantSet.add(SERVER1);
    nonRedundantSet.add(SERVER2);
    nonRedundantSet.add(SERVER3);
    nonRedundantSet.add(SERVER4);
    nonRedundantSet.removeAll(redundantServers);
    Object[] serverArray = nonRedundantSet.toArray();
    String rServer1 = (String) serverArray[0];
    String rServer2 = (String) serverArray[1];
    // can see sporadic socket closed exceptions
    final IgnoredException expectedEx = IgnoredException.addIgnoredException(SocketException.class.getName());
    instance.closeServer(rServer1);
    instance.closeServer(rServer2);
    createCacheClient();
    HashSet redundantServersAfterReconnect = new HashSet(pool.getRedundantNames());
    redundantServersAfterReconnect.add(pool.getPrimaryName());
    List redundantServersHistory = new ArrayList();
    redundantServersHistory.addAll(redundantServersAfterReconnect);
    redundantServersHistory.add(rServer1);
    redundantServersHistory.add(rServer2);
    instance.determineAndVerfiyNonRedundantServers(redundantServersHistory);
    expectedEx.remove();
    assertTrue(redundantServers.equals(redundantServersAfterReconnect));
    assertTrue(redundantServersAfterReconnect.size() == 2);
    assertFalse("redundantServersAfterReconnect contains " + rServer1, redundantServersAfterReconnect.contains(rServer1));
    assertFalse("redundantServersAfterReconnect contains " + rServer2, redundantServersAfterReconnect.contains(rServer2));
}
Also used : SocketException(java.net.SocketException) HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) HashSet(java.util.HashSet) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 55 with IgnoredException

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

the class CompressionCacheConfigDUnitTest method testCreateCacheWithBadCompressor.

/**
   * Asserts that member initialization fails when an unrecognized compressor is declared in the
   * cache.xml.
   */
@Test
public void testCreateCacheWithBadCompressor() throws Exception {
    IgnoredException.addIgnoredException("Unable to load class BAD_COMPRESSOR");
    File cacheXml = createCacheXml(BAD_COMPRESSOR);
    IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
    try {
        assertFalse(createCacheOnVM(getVM(0), cacheXml.getCanonicalPath()));
    } finally {
        expectedException.remove();
        cacheXml.delete();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) 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