This is an automated email from the ASF dual-hosted git repository.

jasonhuynh pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 22a443b  GEODE-4172: CI 
Failure:CqPerfUsingPoolDUnitTest.testMatchingCQsWithMultipleServers (#1222)
22a443b is described below

commit 22a443b41776c392fd835ab982f4b15136aed878
Author: Jason Huynh <[email protected]>
AuthorDate: Mon Jan 8 13:39:48 2018 -0800

    GEODE-4172: CI 
Failure:CqPerfUsingPoolDUnitTest.testMatchingCQsWithMultipleServers (#1222)
    
      * broke test down into two tests
      * removed waits
      * added awaitility conditions
---
 .../cache/query/cq/dunit/CqQueryTestListener.java  |   2 +-
 .../cache/query/cq/dunit/CqPerfDUnitTest.java      |  86 ++++++++----------
 .../query/cq/dunit/CqPerfUsingPoolDUnitTest.java   | 100 ++++++++++-----------
 3 files changed, 85 insertions(+), 103 deletions(-)

diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/query/cq/dunit/CqQueryTestListener.java
 
b/geode-core/src/test/java/org/apache/geode/cache/query/cq/dunit/CqQueryTestListener.java
index d77e677..66462f2 100644
--- 
a/geode-core/src/test/java/org/apache/geode/cache/query/cq/dunit/CqQueryTestListener.java
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/query/cq/dunit/CqQueryTestListener.java
@@ -392,7 +392,7 @@ public class CqQueryTestListener implements 
CqStatusListener {
       final int totalEvents) {
     // Wait for expected events to arrive
     try {
-      Awaitility.await().atMost(5, TimeUnit.SECONDS).until(() -> {
+      Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
         if ((creates > 0 && creates != this.getCreateEventCount())
             || (updates > 0 && updates != this.getUpdateEventCount())
             || (deletes > 0 && deletes != this.getDeleteEventCount())
diff --git 
a/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfDUnitTest.java
 
b/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfDUnitTest.java
index e2255f6..923b2f0 100644
--- 
a/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfDUnitTest.java
+++ 
b/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfDUnitTest.java
@@ -671,11 +671,6 @@ public class CqPerfDUnitTest extends JUnit4CacheTestCase {
     cqDUnitTest.closeServer(server);
   }
 
-  /**
-   * Test for CQ Fail over.
-   *
-   * @throws Exception
-   */
   @Test
   public void testMatchingCQsWithMultipleServers() throws Exception {
     final Host host = Host.getHost(0);
@@ -723,18 +718,12 @@ public class CqPerfDUnitTest extends JUnit4CacheTestCase {
           CqQueryDUnitTest.KEY + i);
     }
 
-    Wait.pause(1 * 1000);
-
     cqDUnitTest.createServer(server2, ports[0]);
 
-
     final int port2 = server2.invoke(() -> 
CqQueryDUnitTest.getCacheServerPort());
     System.out
         .println("### Port on which server1 running : " + port1 + " Server2 
running : " + port2);
 
-    Wait.pause(3 * 1000);
-
-
     // UPDATE - 1.
     for (int k = 0; k < numCQs; k++) {
       cqDUnitTest.clearCQListenerEvents(client1, 
"testMatchingCQsWithMultipleServers_" + k);
@@ -761,7 +750,6 @@ public class CqPerfDUnitTest extends JUnit4CacheTestCase {
 
     int[] resultsCnt = new int[] {10, 1, 2};
 
-
     for (int i = 0; i < numCQs; i++) {
       cqDUnitTest.validateCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i,
           CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i], 
CqQueryDUnitTest.noTest);
@@ -770,68 +758,66 @@ public class CqPerfDUnitTest extends JUnit4CacheTestCase {
           CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i], 
CqQueryDUnitTest.noTest);
     }
 
-    // Close server1.
-    cqDUnitTest.closeServer(server1);
-
-    // Fail over should happen.
-    Wait.pause(5 * 1000);
+    cqDUnitTest.closeClient(client2);
+    cqDUnitTest.closeServer(server2);
+  }
 
-    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], 1 * 
clients.length);
 
-    for (int i = 0; i < numCQs; i++) {
-      cqDUnitTest.validateCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i], 
CqQueryDUnitTest.noTest);
+  @Test
+  public void testFailOverMatchingCQsWithMultipleServers() throws Exception {
+    final Host host = Host.getHost(0);
+    VM server1 = host.getVM(0);
+    VM server2 = host.getVM(1);
+    VM client1 = host.getVM(2);
+    VM client2 = host.getVM(3);
 
-      cqDUnitTest.validateCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i], 
CqQueryDUnitTest.noTest);
-    }
+    cqDUnitTest.createServer(server1);
 
-    // UPDATE - 2
-    for (int k = 0; k < numCQs; k++) {
-      cqDUnitTest.clearCQListenerEvents(client1, 
"testMatchingCQsWithMultipleServers_" + k);
-      cqDUnitTest.clearCQListenerEvents(client2, 
"testMatchingCQsWithMultipleServers_" + k);
-    }
+    VM clients[] = new VM[] {client1, client2};
 
-    cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], 10);
-    cqDUnitTest.createValues(server2, cqDUnitTest.regions[1], 10);
+    final int port1 = server1.invoke(() -> 
CqQueryDUnitTest.getCacheServerPort());
+    final String host0 = NetworkUtils.getServerHostName(server1.getHost());
+    // Create client.
 
+    // Create client with redundancyLevel -1
 
-    // Wait for cq1. on region[0]
-    for (int i = 1; i <= resultsCnt[0]; i++) {
-      cqDUnitTest.waitForUpdated(client1, 
"testMatchingCQsWithMultipleServers_0",
-          CqQueryDUnitTest.KEY + i);
-      cqDUnitTest.waitForUpdated(client2, 
"testMatchingCQsWithMultipleServers_0",
-          CqQueryDUnitTest.KEY + i);
-    }
+    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
 
-    // Wait for cq3. on region[1]
-    {
-      cqDUnitTest.waitForUpdated(client1, 
"testMatchingCQsWithMultipleServers_2",
-          CqQueryDUnitTest.KEY + "4");
-      cqDUnitTest.waitForUpdated(client2, 
"testMatchingCQsWithMultipleServers_2",
-          CqQueryDUnitTest.KEY + "4");
-    }
+    cqDUnitTest.createClient(client1, new int[] {port1, ports[0]}, host0, 
"-1");
+    cqDUnitTest.createClient(client2, new int[] {port1, ports[0]}, host0, 
"-1");
 
+    int numCQs = 3;
 
     for (int i = 0; i < numCQs; i++) {
-      cqDUnitTest.validateCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i] * 2, 
CqQueryDUnitTest.noTest);
+      cqDUnitTest.createCQ(client1, "testMatchingCQsWithMultipleServers_" + i, 
cqDUnitTest.cqs[i]);
+      cqDUnitTest.executeCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i, false, null);
 
-      cqDUnitTest.validateCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryDUnitTest.noTest, resultsCnt[i], resultsCnt[i] * 2, 
CqQueryDUnitTest.noTest);
+      cqDUnitTest.createCQ(client2, "testMatchingCQsWithMultipleServers_" + i, 
cqDUnitTest.cqs[i]);
+      cqDUnitTest.executeCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i, false, null);
     }
 
+    validateMatchingCqs(server1, numCQs, cqDUnitTest.cqs[0], 1 * 
clients.length);
+    validateMatchingCqs(server1, numCQs, cqDUnitTest.cqs[1], 1 * 
clients.length);
+
+
+    cqDUnitTest.createServer(server2, ports[0]);
+
+    // Close server1.
+    cqDUnitTest.closeServer(server1);
+
+    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], clients.length);
 
     // Close.
     cqDUnitTest.closeClient(client1);
 
-    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], 1 * 
(clients.length - 1));
+    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], (clients.length - 
1));
 
     cqDUnitTest.closeClient(client2);
     cqDUnitTest.closeServer(server2);
   }
 
 
+
   /**
    * Test for CQ Fail over.
    *
diff --git 
a/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
 
b/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
index c05d531..9d9d37d 100644
--- 
a/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
+++ 
b/geode-cq/src/test/java/org/apache/geode/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
@@ -21,7 +21,9 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
+import org.awaitility.Awaitility;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -719,9 +721,6 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
     cqDUnitTest.createPool(client2, poolName2, new String[] {host0, host0},
         new int[] {port1, ports[0]});
 
-    // cqDUnitTest.createClient(client1, new int[] {port1, ports[0]}, host0, 
"-1");
-    // cqDUnitTest.createClient(client2, new int[] {port1, ports[0]}, host0, 
"-1");
-
     int numCQs = 3;
 
     for (int i = 0; i < numCQs; i++) {
@@ -737,7 +736,6 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
     validateMatchingCqs(server1, numCQs, cqDUnitTest.cqs[0], 1 * 
clients.length);
     validateMatchingCqs(server1, numCQs, cqDUnitTest.cqs[1], 1 * 
clients.length);
 
-    Wait.pause(1 * 1000);
 
     // CREATE.
     cqDUnitTest.createValues(server1, cqDUnitTest.regions[0], 10);
@@ -748,8 +746,6 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
           CqQueryUsingPoolDUnitTest.KEY + i);
     }
 
-    Wait.pause(1 * 1000);
-
     cqDUnitTest.createServer(server2, ports[0]);
 
 
@@ -757,8 +753,6 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
     System.out
         .println("### Port on which server1 running : " + port1 + " Server2 
running : " + port2);
 
-    Wait.pause(3 * 1000);
-
 
     // UPDATE - 1.
     for (int k = 0; k < numCQs; k++) {
@@ -797,63 +791,61 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
 
     // Close server1.
     cqDUnitTest.closeServer(server1);
+    // Close.
+    cqDUnitTest.closeClient(client1);
 
-    // Fail over should happen.
-    Wait.pause(5 * 1000);
-
-    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], 1 * 
clients.length);
-
-    for (int i = 0; i < numCQs; i++) {
-      cqDUnitTest.validateCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i],
-          CqQueryUsingPoolDUnitTest.noTest);
+    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], 1 * 
(clients.length - 1));
 
-      cqDUnitTest.validateCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i],
-          CqQueryUsingPoolDUnitTest.noTest);
-    }
+    cqDUnitTest.closeClient(client2);
+    cqDUnitTest.closeServer(server2);
+  }
 
-    // UPDATE - 2
-    for (int k = 0; k < numCQs; k++) {
-      cqDUnitTest.clearCQListenerEvents(client1, 
"testMatchingCQsWithMultipleServers_" + k);
-      cqDUnitTest.clearCQListenerEvents(client2, 
"testMatchingCQsWithMultipleServers_" + k);
-    }
+  @Test
+  public void testFailOverForMatchingCQsWithMultipleServers() throws Exception 
{
+    final Host host = Host.getHost(0);
+    VM server1 = host.getVM(0);
+    VM server2 = host.getVM(1);
+    VM client1 = host.getVM(2);
+    VM client2 = host.getVM(3);
+    VM clients[] = new VM[] {client1, client2};
 
-    cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], 10);
-    cqDUnitTest.createValues(server2, cqDUnitTest.regions[1], 10);
 
+    cqDUnitTest.createServer(server1);
+    final String host0 = NetworkUtils.getServerHostName(server1.getHost());
+    final int port1 = server1.invoke(() -> 
CqQueryUsingPoolDUnitTest.getCacheServerPort());
+    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
 
-    // Wait for cq1. on region[0]
-    for (int i = 1; i <= resultsCnt[0]; i++) {
-      cqDUnitTest.waitForUpdated(client1, 
"testMatchingCQsWithMultipleServers_0",
-          CqQueryUsingPoolDUnitTest.KEY + i);
-      cqDUnitTest.waitForUpdated(client2, 
"testMatchingCQsWithMultipleServers_0",
-          CqQueryUsingPoolDUnitTest.KEY + i);
-    }
+    // Create client with redundancyLevel -1
+    String poolName1 = "testClientWithFeederAndCQ1";
+    String poolName2 = "testClientWithFeederAndCQ2";
 
-    // Wait for cq3. on region[1]
-    {
-      cqDUnitTest.waitForUpdated(client1, 
"testMatchingCQsWithMultipleServers_2",
-          CqQueryUsingPoolDUnitTest.KEY + "4");
-      cqDUnitTest.waitForUpdated(client2, 
"testMatchingCQsWithMultipleServers_2",
-          CqQueryUsingPoolDUnitTest.KEY + "4");
-    }
+    cqDUnitTest.createPool(client1, poolName1, new String[] {host0, host0},
+        new int[] {port1, ports[0]});
+    cqDUnitTest.createPool(client2, poolName2, new String[] {host0, host0},
+        new int[] {port1, ports[0]});
 
 
+    int numCQs = 3;
     for (int i = 0; i < numCQs; i++) {
-      cqDUnitTest.validateCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i] * 2,
-          CqQueryUsingPoolDUnitTest.noTest);
+      cqDUnitTest.createCQ(client1, poolName1, 
"testMatchingCQsWithMultipleServers_" + i,
+          cqDUnitTest.cqs[i]);
+      cqDUnitTest.executeCQ(client1, "testMatchingCQsWithMultipleServers_" + 
i, false, null);
 
-      cqDUnitTest.validateCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i,
-          CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i] * 2,
-          CqQueryUsingPoolDUnitTest.noTest);
+      cqDUnitTest.createCQ(client2, poolName2, 
"testMatchingCQsWithMultipleServers_" + i,
+          cqDUnitTest.cqs[i]);
+      cqDUnitTest.executeCQ(client2, "testMatchingCQsWithMultipleServers_" + 
i, false, null);
     }
 
+    cqDUnitTest.createServer(server2, ports[0]);
 
-    // Close.
+    // Close server1.
+    cqDUnitTest.closeServer(server1);
+
+    // Fail over should happen.
+    validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], clients.length);
     cqDUnitTest.closeClient(client1);
 
+    // server2 cq's should still be in the matching map
     validateMatchingCqs(server2, numCQs, cqDUnitTest.cqs[0], 1 * 
(clients.length - 1));
 
     cqDUnitTest.closeClient(client2);
@@ -961,15 +953,19 @@ public class CqPerfUsingPoolDUnitTest extends 
JUnit4CacheTestCase {
         }
 
         Map matchedCqMap = cqService.getMatchingCqMap();
-        assertEquals("The number of matched cq is not as expected.", mapSize, 
matchedCqMap.size());
+        Awaitility.await().atMost(10, TimeUnit.SECONDS)
+            .until(() -> assertEquals("The number of matched cq is not as 
expected.", mapSize,
+                matchedCqMap.size()));
 
         if (query != null) {
           if (!matchedCqMap.containsKey(query)) {
             fail("Query not found in the matched cq map. Query:" + query);
           }
           Collection cqs = (Collection) matchedCqMap.get(query);
-          assertEquals("Number of matched cqs are not equal to the expected 
matched cqs", numCqSize,
-              cqs.size());
+          Awaitility.await().atMost(5, TimeUnit.SECONDS)
+              .until(() -> assertEquals(
+                  "Number of matched cqs are not equal to the expected matched 
cqs", numCqSize,
+                  cqs.size()));
         }
       }
     });

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to