Search in sources :

Example 91 with Category

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

the class PersistentColocatedPartitionedRegionDUnitTest method testRebalanceWithOfflineChildRegionTwoDiskStores.

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

        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() {

        public void run() {
            Cache cache = getCache();
            DiskStore ds2 = cache.findDiskStore("disk2");
            if (ds2 == null) {
                ds2 = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("disk2");
            }
            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("disk2");
            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 92 with Category

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

the class PersistentRecoveryOrderDUnitTest method testCrashDuringPreparePersistentId.

// GEODE-1703: fails assertion: Region not created within30000
@Category(FlakyTest.class)
@Test
public void testCrashDuringPreparePersistentId() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    // Add a hook which will disconnect from the distributed
    // system when the initial image message shows up.
    vm0.invoke(new SerializableRunnable() {

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

                @Override
                public void beforeProcessMessage(DistributionManager dm, DistributionMessage message) {
                    if (message instanceof PrepareNewPersistentMemberMessage) {
                        DistributionMessageObserver.setInstance(null);
                        disconnectFromDS();
                    }
                }

                @Override
                public void afterProcessMessage(DistributionManager dm, DistributionMessage message) {
                }
            });
        }
    });
    createPersistentRegion(vm0);
    putAnEntry(vm0);
    updateTheEntry(vm0);
    AsyncInvocation async1 = createPersistentRegionAsync(vm1);
    // Wait for vm 1 to get stuck waiting for vm0, because vm0 has crashed
    waitForBlockedInitialization(vm1);
    // closeCache(vm0);
    closeCache(vm1);
    try {
        async1.getResult();
        fail("Should have seen a CacheClosedException");
    } catch (AssertionError e) {
        if (!CacheClosedException.class.isInstance(getRootCause(e))) {
            throw e;
        }
    }
    createPersistentRegion(vm0);
    createPersistentRegion(vm1);
    ;
    checkForEntry(vm0);
    checkForEntry(vm1);
}
Also used : DistributionMessage(org.apache.geode.distributed.internal.DistributionMessage) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) 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) 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 93 with Category

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

the class DestroyEntryPropagationDUnitTest method testVerifyDestroyNotReceivedBySender.

/**
   * This tests whether the destroy are received by the sender or not if there are situation of
   * Interest List fail over
   */
// GEODE-897: random port, time sensitive, waitForCriterion, 2 minute
@Category(FlakyTest.class)
// timeouts, eats exception (1 fixed)
@Test
public void testVerifyDestroyNotReceivedBySender() {
    final int maxWaitTime = Integer.getInteger(WAIT_PROPERTY, WAIT_DEFAULT).intValue();
    // First create entries on both servers via the two client
    vm2.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
    vm3.invoke(() -> DestroyEntryPropagationDUnitTest.createEntriesK1andK2());
    vm2.invoke(() -> DestroyEntryPropagationDUnitTest.registerKey1());
    vm3.invoke(() -> DestroyEntryPropagationDUnitTest.registerKey1());
    // Induce fail over of InterestList Endpoint to Server 2 by killing server1
    vm0.invoke(() -> DestroyEntryPropagationDUnitTest.killServer(new Integer(PORT1)));
    // Wait for 10 seconds to allow fail over. This would mean that Interest
    // has failed over to Server2.
    vm2.invoke(new CacheSerializableRunnable("Wait for server on port1 to be dead") {

        public void run2() throws CacheException {
            Region r = cache.getRegion(REGION_NAME);
            try {
                // Used in the case where we don't have a LiveServerMonitorThread
                r.put("ping", "pong1");
            } catch (CacheWriterException itsOK) {
            }
            try {
                // Used in the case where we don't have a LiveServerMonitorThread
                r.put("ping", "pong1");
            } catch (CacheWriterException itsOK) {
            }
            String poolName = r.getAttributes().getPoolName();
            assertNotNull(poolName);
            final PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
            assertNotNull(pool);
            WaitCriterion ev = new WaitCriterion() {

                public boolean done() {
                    return pool.getConnectedServerCount() != 2;
                }

                public String description() {
                    return null;
                }
            };
            Wait.waitForCriterion(ev, maxWaitTime, 200, true);
        }
    });
    // Start Server1 again so that both clients1 & Client 2 will establish
    // connection to server1 too.
    vm0.invoke(() -> DestroyEntryPropagationDUnitTest.startServer(new Integer(PORT1)));
    vm2.invoke(new CacheSerializableRunnable("Wait for server on port1 to spring to life") {

        public void run2() throws CacheException {
            Region r = cache.getRegion(REGION_NAME);
            String poolName = r.getAttributes().getPoolName();
            assertNotNull(poolName);
            final PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
            assertNotNull(pool);
            WaitCriterion ev = new WaitCriterion() {

                public boolean done() {
                    return pool.getConnectedServerCount() == 2;
                }

                public String description() {
                    return null;
                }
            };
            Wait.waitForCriterion(ev, maxWaitTime, 200, true);
        }
    });
    // Do a destroy on Server1 via Connection object from client1.
    // Client1 should not receive updated value while client2 should receive
    vm2.invoke(() -> acquireConnectionsAndDestroyEntriesK1andK2());
    // pause(10000);
    // Check if both the puts ( on key1 & key2 ) have reached the servers
    vm0.invoke(() -> DestroyEntryPropagationDUnitTest.verifyEntriesAreDestroyed());
    vm1.invoke(() -> DestroyEntryPropagationDUnitTest.verifyEntriesAreDestroyed());
    vm2.invoke(() -> DestroyEntryPropagationDUnitTest.verifyNoDestroyEntryInSender());
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) Region(org.apache.geode.cache.Region) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) CacheWriterException(org.apache.geode.cache.CacheWriterException) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 94 with Category

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

the class RegionManagementDUnitTest method testLruStats.

// GEODE-1930
@Category(FlakyTest.class)
@Test
public void testLruStats() throws Exception {
    createMembersAndThenManagers_tmp();
    for (VM memberVM : this.memberVMs) {
        createDiskRegion(memberVM);
    }
    verifyEntrySize(this.managerVM, 3);
}
Also used : Invoke.invokeInEveryVM(org.apache.geode.test.dunit.Invoke.invokeInEveryVM) VM(org.apache.geode.test.dunit.VM) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 95 with Category

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

the class GemfireDataCommandsDUnitTest method testRebalanceForEntireDS.

// GEODE-1487
@Category(FlakyTest.class)
@Test
public void testRebalanceForEntireDS() {
    setupTestRebalanceForEntireDS();
    // check if DistributedRegionMXBean is available so that command will not fail
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(checkRegionMBeans);
    getLogWriter().info("testRebalanceForEntireDS verified Mbean and executin command");
    String command = "rebalance";
    CommandResult cmdResult = executeCommand(command);
    getLogWriter().info("testRebalanceForEntireDS just after executing " + cmdResult);
    if (cmdResult != null) {
        String stringResult = commandResultToString(cmdResult);
        getLogWriter().info("testRebalanceForEntireDS stringResult : " + stringResult);
        assertEquals(Result.Status.OK, cmdResult.getStatus());
    } else {
        fail("testRebalanceForIncludeRegionFunction failed as did not get CommandResult");
    }
}
Also used : VM(org.apache.geode.test.dunit.VM) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) 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