You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/05/24 13:19:25 UTC

[GitHub] [ignite] NSAmelchev commented on a change in pull request #6563: IGNITE-11670 Java thin client: Queries are inconsistent in case of fa…

NSAmelchev commented on a change in pull request #6563: IGNITE-11670 Java thin client: Queries are inconsistent in case of fa…
URL: https://github.com/apache/ignite/pull/6563#discussion_r287355386
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/client/ReliabilityTest.java
 ##########
 @@ -168,62 +153,92 @@ public void testSingleServerFailover() throws Exception {
         }
     }
 
-    /** */
-    @FunctionalInterface
-    private interface Assertion {
-        /** */
-        void call() throws Exception;
+    /**
+     * Test that failover doesn't lead to silent query inconsistency.
+     */
+    @Test
+    public void testQueryConsistencyOnFailover() throws Exception {
+        int CLUSTER_SIZE = 2;
+
+        try (LocalIgniteCluster cluster = LocalIgniteCluster.start(CLUSTER_SIZE);
+             IgniteClient client = Ignition.startClient(new ClientConfiguration()
+                 .setAddresses(cluster.clientAddresses().toArray(new String[CLUSTER_SIZE])))
+        ) {
+            ClientCache<Integer, Integer> cache = client.createCache("cache");
+
+            cache.put(0, 0);
+            cache.put(1, 1);
+
+            Query<Cache.Entry<Integer, String>> qry = new ScanQuery<Integer, String>().setPageSize(1);
+
+            try (QueryCursor<Cache.Entry<Integer, String>> cur = cache.query(qry)) {
+                int cnt = 0;
+
+                for (Iterator<Cache.Entry<Integer, String>> it = cur.iterator(); it.hasNext(); it.next()) {
+                    cnt++;
+
+                    if (cnt == 1)
+                        dropAllThinClientConnections(Ignition.allGrids().get(0));
+                }
+
+                assertEquals(2, cnt);
+            }
+            catch (ClientReconnectedException expected) {
 
 Review comment:
   Why you don't check that the expected exception will be thrown? 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services