Search in sources :

Example 41 with IgnoredException

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

the class PersistentColocatedPartitionedRegionDUnitTest method testColocatedPRAttributes.

@Test
public void testColocatedPRAttributes() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(1);
    vm0.invoke(new SerializableRunnable("create") {

        public void run() {
            Cache cache = getCache();
            DiskStore ds = cache.findDiskStore("disk");
            if (ds == null) {
                ds = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("disk");
            }
            // Create Persistent region
            AttributesFactory af = new AttributesFactory();
            PartitionAttributesFactory paf = new PartitionAttributesFactory();
            paf.setRedundantCopies(0);
            af.setPartitionAttributes(paf.create());
            af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
            af.setDiskStoreName("disk");
            cache.createRegion("persistentLeader", af.create());
            af.setDataPolicy(DataPolicy.PARTITION);
            af.setDiskStoreName(null);
            cache.createRegion("nonPersistentLeader", af.create());
            // Create a non persistent PR
            af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
            af.setDiskStoreName("disk");
            paf.setColocatedWith("nonPersistentLeader");
            af.setPartitionAttributes(paf.create());
            // Try to colocate a persistent PR with the non persistent PR. This should fail.
            IgnoredException exp = IgnoredException.addIgnoredException("IllegalStateException");
            try {
                cache.createRegion("colocated", af.create());
                fail("should not have been able to create a persistent region colocated with a non persistent region");
            } catch (IllegalStateException expected) {
            // do nothing
            } finally {
                exp.remove();
            }
            // Try to colocate a persistent PR with another persistent PR. This should work.
            paf.setColocatedWith("persistentLeader");
            af.setPartitionAttributes(paf.create());
            cache.createRegion("colocated", af.create());
            // We should also be able to colocate a non persistent region with a persistent region.
            af.setDataPolicy(DataPolicy.PARTITION);
            af.setDiskStoreName(null);
            paf.setColocatedWith("persistentLeader");
            af.setPartitionAttributes(paf.create());
            cache.createRegion("colocated2", af.create());
        }
    });
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) 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) Cache(org.apache.geode.cache.Cache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 42 with IgnoredException

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

the class PersistentColocatedPartitionedRegionDUnitTest method replaceOfflineMemberAndRestart.

/**
   * Test for support issue 7870. 1. Run three members with redundancy 1 and recovery delay 0 2.
   * Kill one of the members, to trigger replacement of buckets 3. Shutdown all members and restart.
   * 
   * What was happening is that in the parent PR, we discarded our offline data in one member, but
   * in the child PR the other members ended up waiting for the child bucket to be created in the
   * member that discarded it's offline data.
   * 
   * @throws Throwable
   */
public void replaceOfflineMemberAndRestart(SerializableRunnable createPRs) throws Throwable {
    disconnectAllFromDS();
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    // Create the PR on three members
    vm0.invoke(createPRs);
    vm1.invoke(createPRs);
    vm2.invoke(createPRs);
    // Create some buckets.
    createData(vm0, 0, NUM_BUCKETS, "a");
    createData(vm0, 0, NUM_BUCKETS, "a", "region2");
    // Close one of the members to trigger redundancy recovery.
    closeCache(vm2);
    // Wait until redundancy is recovered.
    waitForRedundancyRecovery(vm0, 1, PR_REGION_NAME);
    waitForRedundancyRecovery(vm0, 1, "region2");
    createData(vm0, 0, NUM_BUCKETS, "b");
    createData(vm0, 0, NUM_BUCKETS, "b", "region2");
    IgnoredException expected = IgnoredException.addIgnoredException("PartitionOfflineException");
    try {
        // Close the remaining members.
        vm0.invoke(new SerializableCallable() {

            public Object call() throws Exception {
                InternalDistributedSystem ds = (InternalDistributedSystem) getCache().getDistributedSystem();
                AdminDistributedSystemImpl.shutDownAllMembers(ds.getDistributionManager(), 600000);
                return null;
            }
        });
        // Make sure that vm-1 is completely disconnected
        // The shutdown all asynchronously finishes the disconnect after
        // replying to the admin member.
        vm1.invoke(new SerializableRunnable() {

            public void run() {
                basicGetSystem().disconnect();
            }
        });
        // Recreate the members. Try to make sure that
        // the member with the latest copy of the buckets
        // is the one that decides to throw away it's copy
        // by starting it last.
        AsyncInvocation async0 = vm0.invokeAsync(createPRs);
        AsyncInvocation async1 = vm1.invokeAsync(createPRs);
        Wait.pause(2000);
        AsyncInvocation async2 = vm2.invokeAsync(createPRs);
        async0.getResult(MAX_WAIT);
        async1.getResult(MAX_WAIT);
        async2.getResult(MAX_WAIT);
        checkData(vm0, 0, NUM_BUCKETS, "b");
        checkData(vm0, 0, NUM_BUCKETS, "b", "region2");
        waitForRedundancyRecovery(vm0, 1, PR_REGION_NAME);
        waitForRedundancyRecovery(vm0, 1, "region2");
        waitForRedundancyRecovery(vm1, 1, PR_REGION_NAME);
        waitForRedundancyRecovery(vm1, 1, "region2");
        waitForRedundancyRecovery(vm2, 1, PR_REGION_NAME);
        waitForRedundancyRecovery(vm2, 1, "region2");
        // Make sure we don't have any extra buckets after the restart
        int totalBucketCount = getBucketList(vm0).size();
        totalBucketCount += getBucketList(vm1).size();
        totalBucketCount += getBucketList(vm2).size();
        assertEquals(2 * NUM_BUCKETS, totalBucketCount);
        totalBucketCount = getBucketList(vm0, "region2").size();
        totalBucketCount += getBucketList(vm1, "region2").size();
        totalBucketCount += getBucketList(vm2, "region2").size();
        assertEquals(2 * NUM_BUCKETS, totalBucketCount);
    } finally {
        expected.remove();
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Host(org.apache.geode.test.dunit.Host) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) 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) IOException(java.io.IOException)

Example 43 with IgnoredException

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

the class PersistentColocatedPartitionedRegionDUnitTest method testCrashDuringRedundancySatisfaction.

/**
   * Test what happens when we crash in the middle of satisfying redundancy for a colocated bucket.
   * 
   * @throws Throwable
   */
// This test method is disabled because it is failing
// periodically and causing cruise control failures
// See bug #46748
@Test
public void testCrashDuringRedundancySatisfaction() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    SerializableRunnable createPRs = new SerializableRunnable("region1") {

        public void run() {
            Cache cache = getCache();
            DiskStore ds = cache.findDiskStore("disk");
            if (ds == null) {
                ds = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("disk");
            }
            AttributesFactory af = new AttributesFactory();
            PartitionAttributesFactory paf = new PartitionAttributesFactory();
            paf.setRedundantCopies(1);
            // Workaround for 44414 - disable recovery delay so we shutdown
            // vm1 at a predictable point.
            paf.setRecoveryDelay(-1);
            paf.setStartupRecoveryDelay(-1);
            af.setPartitionAttributes(paf.create());
            af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
            af.setDiskStoreName("disk");
            cache.createRegion(PR_REGION_NAME, af.create());
            paf.setColocatedWith(PR_REGION_NAME);
            af.setPartitionAttributes(paf.create());
            cache.createRegion("region2", af.create());
        }
    };
    // Create the PR on vm0
    vm0.invoke(createPRs);
    // Create some buckets.
    createData(vm0, 0, NUM_BUCKETS, "a");
    createData(vm0, 0, NUM_BUCKETS, "a", "region2");
    vm1.invoke(createPRs);
    // We shouldn't have created any buckets in vm1 yet.
    assertEquals(Collections.emptySet(), getBucketList(vm1));
    // Add an observer that will disconnect before allowing the peer to
    // GII a colocated bucket. This should leave the peer with only the parent
    // bucket
    vm0.invoke(new SerializableRunnable() {

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

                @Override
                public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
                    if (message instanceof RequestImageMessage) {
                        if (((RequestImageMessage) message).regionPath.contains("region2")) {
                            DistributionMessageObserver.setInstance(null);
                            disconnectFromDS();
                        }
                    }
                }
            });
        }
    });
    IgnoredException ex = IgnoredException.addIgnoredException("PartitionOfflineException", vm1);
    try {
        // as we satisfy redundancy with vm1.
        try {
            RebalanceResults rr = rebalance(vm1);
        } catch (Exception expected) {
            // disconnect
            if (!(expected.getCause() instanceof PartitionOfflineException)) {
                throw expected;
            }
        }
        // Wait for vm0 to be closed by the callback
        vm0.invoke(new SerializableCallable() {

            public Object call() throws Exception {
                Wait.waitForCriterion(new WaitCriterion() {

                    public boolean done() {
                        InternalDistributedSystem ds = basicGetSystem();
                        return ds == null || !ds.isConnected();
                    }

                    public String description() {
                        return "DS did not disconnect";
                    }
                }, MAX_WAIT, 100, true);
                return null;
            }
        });
        // close the cache in vm1
        SerializableCallable disconnectFromDS = new SerializableCallable() {

            public Object call() throws Exception {
                disconnectFromDS();
                return null;
            }
        };
        vm1.invoke(disconnectFromDS);
        // Make sure vm0 is disconnected. This avoids a race where we
        // may still in the process of disconnecting even though the our async listener
        // found the system was disconnected
        vm0.invoke(disconnectFromDS);
    } finally {
        ex.remove();
    }
    // Create the cache and PRs on both members
    AsyncInvocation async0 = vm0.invokeAsync(createPRs);
    AsyncInvocation async1 = vm1.invokeAsync(createPRs);
    async0.getResult(MAX_WAIT);
    async1.getResult(MAX_WAIT);
    // Make sure the data was recovered correctly
    checkData(vm0, 0, NUM_BUCKETS, "a");
    // Workaround for bug 46748.
    checkData(vm0, 0, NUM_BUCKETS, "a", "region2");
}
Also used : SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Host(org.apache.geode.test.dunit.Host) RequestImageMessage(org.apache.geode.internal.cache.InitialImageOperation.RequestImageMessage) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) 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) IOException(java.io.IOException) DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) IgnoredException(org.apache.geode.test.dunit.IgnoredException) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) RebalanceResults(org.apache.geode.cache.control.RebalanceResults) Cache(org.apache.geode.cache.Cache) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 44 with IgnoredException

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

the class PersistentColocatedPartitionedRegionDUnitTest method testModifyColocation.

/**
   * Test that a user is not allowed to change the colocation of a PR with persistent data.
   * 
   * @throws Throwable
   */
// GEODE-900: disk dependency, filesystem sensitive
@Category(FlakyTest.class)
@Test
public void testModifyColocation() throws Throwable {
    // Create PRs where region3 is colocated with region1.
    createColocatedPRs("region1");
    // Close everything
    closeCache();
    // Restart colocated with "region2"
    IgnoredException ex = IgnoredException.addIgnoredException("DiskAccessException|IllegalStateException");
    try {
        createColocatedPRs("region2");
        fail("Should have received an illegal state exception");
    } catch (IllegalStateException expected) {
    // do nothing
    } finally {
        ex.remove();
    }
    // Close everything
    closeCache();
    // Restart colocated with region1.
    // Make sure we didn't screw anything up.
    createColocatedPRs("/region1");
    // Close everything
    closeCache();
    // Restart uncolocated. We don't allow changing
    // from uncolocated to colocated.
    ex = IgnoredException.addIgnoredException("DiskAccessException|IllegalStateException");
    try {
        createColocatedPRs(null);
        fail("Should have received an illegal state exception");
    } catch (IllegalStateException expected) {
    // do nothing
    } finally {
        ex.remove();
    }
    // Close everything
    closeCache();
}
Also used : 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 45 with IgnoredException

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

the class PersistentPartitionedRegionDUnitTest method testDiskConflictWithCoLocation.

@Test
public void testDiskConflictWithCoLocation() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    // createPR(vm0, 1);
    createCoLocatedPR(vm0, 1, false);
    // create some buckets
    createData(vm0, 0, 2, "a");
    createData(vm0, 0, 2, "a", PR_CHILD_REGION_NAME);
    closePR(vm0, PR_CHILD_REGION_NAME);
    closePR(vm0);
    // createPR(vm1, 1);
    createCoLocatedPR(vm1, 1, false);
    // create an overlapping bucket
    createData(vm1, 2, 4, "a");
    createData(vm1, 2, 4, "a", PR_CHILD_REGION_NAME);
    IgnoredException[] expectVm0 = { IgnoredException.addIgnoredException("ConflictingPersistentDataException", vm0), IgnoredException.addIgnoredException("CacheClosedException", vm0) };
    try {
        createCoLocatedPR(vm0, 1, true);
        // Cache should have closed due to ConflictingPersistentDataException
        vm0.invoke(() -> {
            Awaitility.await().atMost(MAX_WAIT, TimeUnit.MILLISECONDS).until(() -> basicGetCache().isClosed());
            basicGetCache().getCancelCriterion();
        });
    } 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, PR_CHILD_REGION_NAME);
    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)

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