Search in sources :

Example 86 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method testServerFailoverWithTwoServerAliveHA.

/*
   * Ensure that the while executing the function if the servers is down then the execution is
   * failover to other available server
   */
// GEODE-1497
@Category(FlakyTest.class)
@Test
public void testServerFailoverWithTwoServerAliveHA() throws InterruptedException {
    IgnoredException.addIgnoredException("FunctionInvocationTargetException");
    IgnoredException.addIgnoredException("Connection reset");
    IgnoredException.addIgnoredException("SocketTimeoutException");
    IgnoredException.addIgnoredException("ServerConnectivityException");
    IgnoredException.addIgnoredException("Socket Closed");
    ArrayList commonAttributes = createCommonServerAttributes("TestPartitionedRegion", null, 1, 13, null);
    createClientServerScenarion(commonAttributes, 20, 20, 20);
    Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA);
    registerFunctionAtServer(function);
    server2.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.stopServerHA());
    server3.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.stopServerHA());
    client.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.putOperation());
    int AsyncInvocationArrSize = 1;
    AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
    async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.executeFunctionHA());
    server2.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.startServerHA());
    server3.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.startServerHA());
    server1.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.stopServerHA());
    client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.verifyDeadAndLiveServers(new Integer(1), new Integer(2)));
    ThreadUtils.join(async[0], 6 * 60 * 1000);
    if (async[0].getException() != null) {
        Assert.fail("UnExpected Exception Occurred : ", async[0].getException());
    }
    List l = (List) async[0].getReturnValue();
    assertEquals(2, l.size());
}
Also used : Function(org.apache.geode.cache.execute.Function) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 87 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class PersistentPartitionedRegionDUnitTest method testCrashDuringBucketCreation.

/**
   * Test for bug 41336
   */
// GEODE-1738
@Category(FlakyTest.class)
@Test
public void testCrashDuringBucketCreation() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    vm0.invoke(new SerializableRunnable("Install observer") {

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

                @Override
                public void beforeSendMessage(DistributionManager dm, DistributionMessage msg) {
                    if (msg instanceof ManageBucketReplyMessage) {
                        Cache cache = getCache();
                        disconnectFromDS();
                        await().atMost(30, SECONDS).until(() -> {
                            return (cache == null || cache.isClosed());
                        });
                        LogWriterUtils.getLogWriter().info("Cache is confirmed closed");
                    }
                }
            });
        }
    });
    createPR(vm0, 0);
    createPR(vm1, 0);
    createData(vm1, 0, 4, "a");
    Set<Integer> vm1Buckets = getBucketList(vm1);
    // Make sure the test hook ran
    vm0.invoke(new SerializableRunnable("Check for no distributed system") {

        public void run() {
            assertEquals(null, GemFireCacheImpl.getInstance());
        }
    });
    checkData(vm1, 0, 4, "a");
    assertEquals(4, vm1Buckets.size());
    createPR(vm0, 0);
    checkData(vm0, 0, 4, "a");
    assertEquals(vm1Buckets, getBucketList(vm1));
    assertEquals(Collections.emptySet(), getBucketList(vm0));
    closeCache(vm0);
    closeCache(vm1);
    AsyncInvocation async0 = createPRAsync(vm0, 0);
    AsyncInvocation async1 = createPRAsync(vm1, 0);
    async0.getResult();
    async1.getResult();
    checkData(vm0, 0, 4, "a");
    assertEquals(vm1Buckets, getBucketList(vm1));
    assertEquals(Collections.emptySet(), getBucketList(vm0));
}
Also used : DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) ManageBucketReplyMessage(org.apache.geode.internal.cache.partitioned.ManageBucketMessage.ManageBucketReplyMessage) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) DistributionMessageObserver(org.apache.geode.distributed.internal.DistributionMessageObserver) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Cache(org.apache.geode.cache.Cache) 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 88 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class PersistentColocatedPartitionedRegionDUnitTest method testRebalanceWithOfflineChildRegion.

// GEODE-506: time sensitive, async actions with 30 sec max
@Category(FlakyTest.class)
@Test
public void testRebalanceWithOfflineChildRegion() throws Throwable {
    SerializableRunnable createParentPR = new SerializableRunnable("createParentPR") {

        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(0);
            paf.setRecoveryDelay(0);
            af.setPartitionAttributes(paf.create());
            af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
            af.setDiskStoreName("disk");
            cache.createRegion(PR_REGION_NAME, af.create());
        }
    };
    SerializableRunnable createChildPR = new SerializableRunnable("createChildPR") {

        public void run() {
            Cache cache = getCache();
            AttributesFactory af = new AttributesFactory();
            PartitionAttributesFactory paf = new PartitionAttributesFactory();
            paf.setRedundantCopies(0);
            paf.setRecoveryDelay(0);
            paf.setColocatedWith(PR_REGION_NAME);
            af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
            af.setDiskStoreName("disk");
            af.setPartitionAttributes(paf.create());
            cache.createRegion("region2", af.create());
        }
    };
    rebalanceWithOfflineChildRegion(createParentPR, createChildPR);
}
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) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache) 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 89 with Category

use of org.junit.experimental.categories.Category 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 90 with Category

use of org.junit.experimental.categories.Category in project geode by apache.

the class PersistentPartitionedRegionDUnitTest method testCleanStop.

// GEODE-1582: race in async region creation causing GII when not
@Category(FlakyTest.class)
// expected
@Test
public void testCleanStop() throws Throwable {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    createPR(vm0, 1);
    createPR(vm1, 1);
    createData(vm0, 0, 1, "a");
    fakeCleanShutdown(vm1, 0);
    fakeCleanShutdown(vm0, 0);
    AsyncInvocation async1 = createPRAsync(vm0, 1);
    // [dsmith] Make sure that vm0 is waiting for vm1 to recover
    // If VM(0) recovers early, that is a problem, because
    // we can now longer do a clean restart
    AsyncInvocation async2 = createPRAsync(vm1, 1);
    async1.getResult(MAX_WAIT);
    async2.getResult(MAX_WAIT);
    checkData(vm0, 0, 1, "a");
    checkData(vm1, 0, 1, "a");
    checkRecoveredFromDisk(vm0, 0, true);
    checkRecoveredFromDisk(vm1, 0, true);
    closePR(vm0);
    closePR(vm1);
    async1 = createPRAsync(vm0, 1);
    async2 = createPRAsync(vm1, 1);
    async1.getResult(MAX_WAIT);
    async2.getResult(MAX_WAIT);
    checkData(vm0, 0, 1, "a");
    checkData(vm1, 0, 1, "a");
    checkRecoveredFromDisk(vm0, 0, false);
    checkRecoveredFromDisk(vm1, 0, true);
}
Also used : VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) 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)

Aggregations

Category (org.junit.experimental.categories.Category)900 Test (org.junit.Test)856 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)148 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)121 File (java.io.File)102 Instant (org.joda.time.Instant)92 KV (org.apache.beam.sdk.values.KV)86 ArrayList (java.util.ArrayList)84 Row (org.apache.beam.sdk.values.Row)71 Schema (org.apache.beam.sdk.schemas.Schema)65 VM (org.apache.geode.test.dunit.VM)65 QuickTest (com.hazelcast.test.annotation.QuickTest)57 List (java.util.List)57 Matchers.containsString (org.hamcrest.Matchers.containsString)55 InputStream (java.io.InputStream)49 NightlyTest (com.hazelcast.test.annotation.NightlyTest)47 FileListView (com.owncloud.android.test.ui.models.FileListView)46 UsesSchema (org.apache.beam.sdk.testing.UsesSchema)43 StringUtils.byteArrayToJsonString (org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString)41 IOException (java.io.IOException)40