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());
}
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));
}
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);
}
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();
}
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);
}
Aggregations