use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method testServerCacheClosedFailoverWithTwoServerAliveHA.
/*
* Ensure that the while executing the function if the servers is down then the execution is
* failover to other available server
*/
@Test
public void testServerCacheClosedFailoverWithTwoServerAliveHA() throws InterruptedException {
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(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.stopServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.putOperation());
int AsyncInvocationArrSize = 1;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.executeFunctionHA());
server2.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.startServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.startServerHA());
server1.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.closeCacheHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.verifyDeadAndLiveServers(new Integer(1), new Integer(2)));
ThreadUtils.join(async[0], 5 * 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.apache.geode.test.dunit.AsyncInvocation 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.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method testServerCacheClosedFailoverWithTwoServerAliveHA.
/*
* Ensure that the while executing the function if the servers is down then the execution is
* failover to other available server
*/
@Test
public void testServerCacheClosedFailoverWithTwoServerAliveHA() throws InterruptedException {
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
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(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.stopServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.putOperation());
int AsyncInvocationArrSize = 1;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.executeFunctionHA());
server2.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.startServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.startServerHA());
server1.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.closeCacheHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.verifyDeadAndLiveServers(new Integer(1), new Integer(2)));
ThreadUtils.join(async[0], 5 * 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.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method testServerFailoverWithTwoServerAliveHA.
/*
* Ensure that the while executing the function if the servers is down then the execution is
* failover to other available server
*/
@Test
public void testServerFailoverWithTwoServerAliveHA() throws InterruptedException {
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
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(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.stopServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.putOperation());
int AsyncInvocationArrSize = 1;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.executeFunctionHA());
server2.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.startServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.startServerHA());
server1.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.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.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class PersistentColocatedPartitionedRegionDUnitTest method testHierarchyOfColocatedChildPRsMissingGrandchild.
/**
* Testing that all missing persistent PRs in a colocation hierarchy are logged as warnings
*/
@Test
public void testHierarchyOfColocatedChildPRsMissingGrandchild() throws Throwable {
// millis
int loggerTestInterval = 4000;
int numChildGenerations = 3;
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
vm0.invoke(new NumChildPRGenerationsSetter(numChildGenerations));
vm1.invoke(new NumChildPRGenerationsSetter(numChildGenerations));
vm0.invoke(createPRColocationHierarchy);
vm1.invoke(createPRColocationHierarchy);
createData(vm0, 0, NUM_BUCKETS, "a");
createData(vm0, 0, NUM_BUCKETS, "b", "region2");
createData(vm0, 0, NUM_BUCKETS, "c", "region3");
Set<Integer> vm0Buckets = getBucketList(vm0, PR_REGION_NAME);
assertFalse(vm0Buckets.isEmpty());
Set<Integer> vm1Buckets = getBucketList(vm1, PR_REGION_NAME);
assertFalse(vm1Buckets.isEmpty());
for (int i = 2; i < numChildGenerations + 2; ++i) {
String childName = "region" + i;
assertEquals(vm0Buckets, getBucketList(vm0, childName));
assertEquals(vm1Buckets, getBucketList(vm1, childName));
}
closeCache(vm0);
closeCache(vm1);
vm0.invoke(new ColocationLoggerIntervalSetter(loggerTestInterval));
vm1.invoke(new ColocationLoggerIntervalSetter(loggerTestInterval));
// Expected warning logs only on the child region, because without the child there's nothing
// known about the remaining hierarchy
vm0.invoke(new ExpectedNumLogMessageSetter(numChildGenerations * (numChildGenerations + 1) / 2));
vm1.invoke(new ExpectedNumLogMessageSetter(numChildGenerations * (numChildGenerations + 1) / 2));
vm0.invoke(new DelayForChildCreationSetter((int) (loggerTestInterval)));
vm1.invoke(new DelayForChildCreationSetter((int) (loggerTestInterval)));
Object logMsg = "";
AsyncInvocation async0 = vm0.invokeAsync(createPRsSequencedChildrenCreationThread);
AsyncInvocation async1 = vm1.invokeAsync(createPRsSequencedChildrenCreationThread);
logMsg = async1.get(MAX_WAIT, TimeUnit.MILLISECONDS);
async0.get(MAX_WAIT, TimeUnit.MILLISECONDS);
vm0.invoke(new ExpectedNumLogMessageResetter());
vm1.invoke(new ExpectedNumLogMessageResetter());
vm0.invoke(new ColocationLoggerIntervalResetter());
vm1.invoke(new ColocationLoggerIntervalResetter());
assertTrue("Expected missing colocated region warning on remote. Got message \"" + logMsg + "\"", logMsg.toString().matches(PATTERN_FOR_MISSING_CHILD_LOG));
}
Aggregations