Search in sources :

Example 81 with IgnoredException

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

the class FixedPartitioningDUnitTest method testSamePartitionName_Primary_OnTwoMembers.

/**
   * Test validation : only one node should return primary for a particular partition name for a
   * specific FPR at any given point of time. DuplicatePrimaryPartitionException is thrown during
   * FPR creation if this condition is not met.
   */
@Test
public void testSamePartitionName_Primary_OnTwoMembers() {
    IgnoredException ex = IgnoredException.addIgnoredException("DuplicatePrimaryPartitionException");
    try {
        member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
        List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
        fpaList.add(fpa1);
        member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
        member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
        fpaList.clear();
        fpaList.add(fpa1);
        member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
        member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
        fpaList.clear();
        fpaList.add(fpa1);
        member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
        fail("DuplicatePrimaryPartitionException Expected");
    } catch (Exception duplicate) {
        if (!((duplicate.getCause() instanceof DuplicatePrimaryPartitionException) && (duplicate.getCause().getMessage().contains("can not be defined as primary on more than one node")))) {
            Assert.fail("Expected DuplicatePrimaryPartitionException ", duplicate);
        }
    } finally {
        ex.remove();
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) ArrayList(java.util.ArrayList) IgnoredException(org.apache.geode.test.dunit.IgnoredException) DuplicatePrimaryPartitionException(org.apache.geode.cache.DuplicatePrimaryPartitionException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PartitionNotAvailableException(org.apache.geode.cache.partition.PartitionNotAvailableException) DuplicatePrimaryPartitionException(org.apache.geode.cache.DuplicatePrimaryPartitionException) 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 82 with IgnoredException

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

the class FixedPartitioningDUnitTest method testNumBuckets_totalNumBuckets.

/**
   * Sum of num-buckets for different primary partitions should not be greater than totalNumBuckets.
   */
@Test
public void testNumBuckets_totalNumBuckets() {
    IgnoredException expected = IgnoredException.addIgnoredException("IllegalStateException");
    try {
        member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", null, 1, 0, 5, new QuarterPartitionResolver(), null, false));
        member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
        FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2, false, 3);
        List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
        fpaList.add(fpa1);
        fpaList.add(fpa2);
        member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 5, new QuarterPartitionResolver(), null, false));
        member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
        fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
        fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter3, false, 3);
        fpaList.clear();
        fpaList.add(fpa1);
        fpaList.add(fpa2);
        member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 5, new QuarterPartitionResolver(), null, false));
        fail("IllegalStateException expected");
    } catch (Exception ex) {
        if (!((ex.getCause() instanceof IllegalStateException) && (ex.getCause().getMessage().contains("for different primary partitions should not be greater than total-num-buckets ")))) {
            Assert.fail("Expected IllegalStateException ", ex);
        }
    } finally {
        expected.remove();
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) ArrayList(java.util.ArrayList) IgnoredException(org.apache.geode.test.dunit.IgnoredException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PartitionNotAvailableException(org.apache.geode.cache.partition.PartitionNotAvailableException) DuplicatePrimaryPartitionException(org.apache.geode.cache.DuplicatePrimaryPartitionException) 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 83 with IgnoredException

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

the class ReplicatedRegion_ParallelWANPropagationDUnitTest method doPuts0.

public static void doPuts0(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, "0_" + 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 84 with IgnoredException

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

the class WanAutoDiscoveryDUnitTest method testInvalidHostRemoteLocators.

@Test
public void testInvalidHostRemoteLocators() {
    IgnoredException ie = IgnoredException.addIgnoredException("could not get remote locator information for remote site");
    try {
        Set<String> remoteLocators = new HashSet();
        addUnknownHost(remoteLocators);
        testRemoteLocators(remoteLocators, false, 0);
    } finally {
        ie.remove();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) HashSet(java.util.HashSet) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 85 with IgnoredException

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

the class WANTestBase method createSender.

public static void createSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManualStart) {
    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
    try {
        File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
        persistentDirectory.mkdir();
        DiskStoreFactory dsf = cache.createDiskStoreFactory();
        File[] dirs1 = new File[] { persistentDirectory };
        GatewaySenderFactory gateway = configureGateway(dsf, dirs1, dsName, isParallel, maxMemory, batchSize, isConflation, isPersistent, filter, isManualStart, numDispatcherThreadsForTheRun, GatewaySender.DEFAULT_ORDER_POLICY);
        gateway.create(dsName, remoteDsId);
    } finally {
        exln.remove();
    }
}
Also used : GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

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