use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class SerialWANPropagationDUnitTest method testReplicatedSerialPropagationWithRemoteRegionDestroy3.
@Test
public void testReplicatedSerialPropagationWithRemoteRegionDestroy3() throws Exception {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
// these are part of remote site
createCacheInVMs(nyPort, vm2, vm3);
// create one RR (RR_1) on remote site
vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
// create another RR (RR_2) on remote site
vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", null, isOffHeap()));
vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", null, isOffHeap()));
createReceiverInVMs(vm2, vm3);
// these are part of local site
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
// create one RR (RR_1) on local site
vm4.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm5.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm6.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm7.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
// create another RR (RR_2) on local site
vm4.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", "ln", isOffHeap()));
vm5.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", "ln", isOffHeap()));
vm6.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", "ln", isOffHeap()));
vm7.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_2", "ln", isOffHeap()));
// senders are created on local site
vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 200, false, false, null, true));
vm5.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 200, false, false, null, true));
// start the senders on local site
startSenderInVMs("ln", vm4, vm5);
IgnoredException.addIgnoredException(BatchException70.class.getName());
IgnoredException.addIgnoredException(ServerOperationException.class.getName());
// start puts in RR_1 in another thread
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_1", 1000));
// start puts in RR_2 in another thread
AsyncInvocation inv2 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_2", 1000));
// destroy RR_2 on remote site in the middle
vm2.invoke(() -> WANTestBase.destroyRegion(getTestMethodName() + "_RR_2"));
inv1.join();
inv2.join();
vm4.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 1000));
// in local site
try {
vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 1000));
} finally {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "GatewaySender.REMOVE_FROM_QUEUE_ON_EXCEPTION", "False");
vm4.invoke(new CacheSerializableRunnable("UnSetting system property ") {
public void run2() throws CacheException {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "GatewaySender.REMOVE_FROM_QUEUE_ON_EXCEPTION", "False");
}
});
vm5.invoke(new CacheSerializableRunnable("UnSetting system property ") {
public void run2() throws CacheException {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "GatewaySender.REMOVE_FROM_QUEUE_ON_EXCEPTION", "False");
}
});
}
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class SerialWANPropagationDUnitTest method testReplicatedSerialPropagationWithRemoteRegionDestroy.
/**
* 1 region and sender configured on local site and 1 region and a receiver configured on remote
* site. Puts to the local region are in progress. Remote region is destroyed in the middle.
*/
@Test
public void testReplicatedSerialPropagationWithRemoteRegionDestroy() throws Exception {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
// these are part of remote site
createCacheInVMs(nyPort, vm2, vm3);
createReceiverInVMs(vm2, vm3);
// these are part of local site
createCacheInVMs(lnPort, vm4, vm5, vm6, vm7);
// senders are created on local site
vm4.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 500, false, false, null, true));
vm5.invoke(() -> WANTestBase.createSender("ln", 2, false, 100, 500, false, false, null, true));
// create one RR (RR_1) on remote site
vm2.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
vm3.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", null, isOffHeap()));
// start the senders on local site
startSenderInVMs("ln", vm4, vm5);
// create one RR (RR_1) on local site
vm4.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm5.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm6.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
vm7.invoke(() -> WANTestBase.createReplicatedRegion(getTestMethodName() + "_RR_1", "ln", isOffHeap()));
IgnoredException.addIgnoredException(BatchException70.class.getName());
IgnoredException.addIgnoredException(ServerOperationException.class.getName());
// start puts in RR_1 in another thread
AsyncInvocation inv1 = vm4.invokeAsync(() -> WANTestBase.doPuts(getTestMethodName() + "_RR_1", 1000));
// destroy RR_1 in remote site
vm2.invoke(() -> WANTestBase.destroyRegion(getTestMethodName() + "_RR_1"));
inv1.join();
// verify that all is well in local site. All the events should be present in local region
vm4.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_RR_1", 1000));
// assuming some events might have been dispatched before the remote region was destroyed,
// sender's region queue will have events less than 1000 but the queue will not be empty.
// NOTE: this much verification might be sufficient in DUnit. Hydra will take care of
// more in depth validations.
vm4.invoke(() -> WANTestBase.verifyRegionQueueNotEmpty("ln"));
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ClientRegisterInterestAuthDUnitTest method testRegisterInterest.
@Test
public void testRegisterInterest() throws Exception {
// client1 connects to server as a user not authorized to do any operations
AsyncInvocation ai1 = client1.invokeAsync(() -> {
ClientCache cache = createClientCache("stranger", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
assertNotAuthorized(() -> region.registerInterest("key3"), "DATA:READ:AuthRegion:key3");
});
// client2 connects to user as a user authorized to use AuthRegion region
AsyncInvocation ai2 = client2.invokeAsync(() -> {
ClientCache cache = createClientCache("authRegionUser", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
// DATA:READ:AuthRegion:key3;
region.registerInterest("key3");
});
// client3 connects to user as a user authorized to use key1 in AuthRegion region
AsyncInvocation ai3 = client3.invokeAsync(() -> {
ClientCache cache = createClientCache("key1User", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
assertNotAuthorized(() -> region.registerInterest("key2"), "DATA:READ:AuthRegion:key2");
});
ai1.await();
ai2.await();
ai3.await();
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ClientRegisterInterestAuthDUnitTest method testRegisterInterestList.
@Test
public void testRegisterInterestList() throws Exception {
List<String> keys = new ArrayList<>();
keys.add("key1");
keys.add("key2");
// client1 connects to server as a user not authorized to do any operations
AsyncInvocation ai1 = client1.invokeAsync(() -> {
ClientCache cache = createClientCache("stranger", "1234567", server.getPort());
Region region = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
assertNotAuthorized(() -> region.registerInterest(keys), "DATA:READ:AuthRegion");
});
// client2 connects to user as a user authorized to use AuthRegion region
AsyncInvocation ai2 = client2.invokeAsync(() -> {
ClientCache cache = createClientCache("authRegionUser", "1234567", server.getPort());
Region region = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
// DATA:READ:AuthRegion;
region.registerInterest(keys);
});
// client3 connects to user as a user authorized to use key1 in AuthRegion region
AsyncInvocation ai3 = client3.invokeAsync(() -> {
ClientCache cache = createClientCache("key1User", "1234567", server.getPort());
Region region = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
assertNotAuthorized(() -> region.registerInterest(keys), "DATA:READ:AuthRegion");
});
ai1.await();
ai2.await();
ai3.await();
}
use of org.apache.geode.test.dunit.AsyncInvocation in project geode by apache.
the class ClientUnregisterInterestAuthDUnitTest method testUnregisterInterest.
@Test
public void testUnregisterInterest() throws Exception {
// client2 connects to user as a user authorized to use AuthRegion region
AsyncInvocation ai1 = client2.invokeAsync(() -> {
ClientCache cache = createClientCache("authRegionUser", "1234567", server.getPort());
Region region = createProxyRegion(cache, REGION_NAME);
region.registerInterest("key3");
// DATA:READ:AuthRegion:key3;
region.unregisterInterest("key3");
});
ai1.await();
}
Aggregations