nabarunnag commented on a change in pull request #6104:
URL: https://github.com/apache/geode/pull/6104#discussion_r592024935
##########
File path:
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java
##########
@@ -120,6 +125,111 @@
private static int bridgeServerPort;
+ @Test
+ public void testPutAllWithCQLocalDestroy() {
+ VM server1 = getVM(0);
+ VM server2 = getVM(1);
+ VM client = getVM(2);
+
+ final String cqName = "testPutAllWithCQLocalDestroy_0";
+ createServer(server1);
+ createServer(server2);
+ final String host = VM.getHostName();
+ final int port = server2.invoke(() -> getCacheServerPort());
+ createClient(client, port, host);
+ createCQ(client, cqName, cqs[0]);
+
+ int numObjects = 1000;
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ Map<String, Object> buffer = new HashMap();
+ for (int i = 1; i < numObjects; i++) {
+ Portfolio p = new Portfolio(i);
+ buffer.put("" + i, p);
+ }
+ region.putAll(buffer);
+ });
+
+ client.invoke(() -> {
+ QueryService cqService = getCache().getQueryService();
+ CqQuery cqQuery = cqService.getCq(cqName);
+ assertThat(cqQuery)
+ .withFailMessage("Failed to get CQ " + cqName)
+ .isNotNull();
+ cqQuery.executeWithInitialResults();
+ });
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ // PutAll with entries that do not satisfy CQ. This is to generate
LOCAL_DESTROY CQ event
+ Map<String, Object> buffer = new HashMap();
+ for (int i = 1; i < numObjects; i++) {
+ Portfolio p = new Portfolio(-1 * i);
+ buffer.put("" + i, p);
+ }
+ region.putAll(buffer);
+ });
+
+ cqHelper.closeClient(client);
+ cqHelper.closeServer(server2);
+ cqHelper.closeServer(server1);
+ }
+
+ @Test
+ public void testRemoveAllWithCQLocalDestroy() {
+ VM server1 = getVM(0);
+ VM server2 = getVM(1);
+ VM client = getVM(2);
+
+ final String cqName = "testRemoveAllWithCQLocalDestroy_0";
+ createServer(server1);
+ createServer(server2);
+ final String host = VM.getHostName();
+ final int port = server2.invoke(() -> getCacheServerPort());
+ createClient(client, port, host);
+ createCQ(client, cqName, cqs[0]);
+
+ int numObjects = 1000;
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ Map<String, Object> buffer = new HashMap();
+ for (int i = 1; i < numObjects; i++) {
+ Portfolio p = new Portfolio(i);
+ buffer.put("" + i, p);
+ }
+ region.putAll(buffer);
+ });
+
+ client.invoke(() -> {
+ QueryService cqService = getCache().getQueryService();
+ CqQuery cqQuery = cqService.getCq(cqName);
+ assertThat(cqQuery)
+ .withFailMessage("Failed to get CQ " + cqName)
+ .isNotNull();
+ cqQuery.executeWithInitialResults();
+ });
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ Set<String> keys = new HashSet<>();
+ for (int i = 1; i < numObjects; i++) {
+ keys.add("" + i);
+ }
+ // This is to generate LOCAL_DESTROY CQ event
+ region.removeAll(keys);
+ });
+
Review comment:
Should there be an assert at the end of the test to verify the behavior ?
##########
File path:
geode-cq/src/distributedTest/java/org/apache/geode/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java
##########
@@ -120,6 +125,111 @@
private static int bridgeServerPort;
+ @Test
+ public void testPutAllWithCQLocalDestroy() {
+ VM server1 = getVM(0);
+ VM server2 = getVM(1);
+ VM client = getVM(2);
+
+ final String cqName = "testPutAllWithCQLocalDestroy_0";
+ createServer(server1);
+ createServer(server2);
+ final String host = VM.getHostName();
+ final int port = server2.invoke(() -> getCacheServerPort());
+ createClient(client, port, host);
+ createCQ(client, cqName, cqs[0]);
+
+ int numObjects = 1000;
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ Map<String, Object> buffer = new HashMap();
+ for (int i = 1; i < numObjects; i++) {
+ Portfolio p = new Portfolio(i);
+ buffer.put("" + i, p);
+ }
+ region.putAll(buffer);
+ });
+
+ client.invoke(() -> {
+ QueryService cqService = getCache().getQueryService();
+ CqQuery cqQuery = cqService.getCq(cqName);
+ assertThat(cqQuery)
+ .withFailMessage("Failed to get CQ " + cqName)
+ .isNotNull();
+ cqQuery.executeWithInitialResults();
+ });
+
+ server1.invoke(() -> {
+ Region<String, Object> region =
+ getCache().getRegion(SEPARATOR + "root" + SEPARATOR + regions[0]);
+ // PutAll with entries that do not satisfy CQ. This is to generate
LOCAL_DESTROY CQ event
+ Map<String, Object> buffer = new HashMap();
+ for (int i = 1; i < numObjects; i++) {
+ Portfolio p = new Portfolio(-1 * i);
+ buffer.put("" + i, p);
+ }
+ region.putAll(buffer);
+ });
+
Review comment:
Should there be an assert at the end of the test to verify the behavior ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]