You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/06/01 17:59:43 UTC

[GitHub] [lucene-solr] murblanc commented on a change in pull request #1548: SOLR-14524: Harden MultiThreadedOCPTest testFillWorkQueue()

murblanc commented on a change in pull request #1548:
URL: https://github.com/apache/lucene-solr/pull/1548#discussion_r433396537



##########
File path: solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java
##########
@@ -79,40 +78,57 @@ private void testFillWorkQueue() throws Exception {
             QUEUE_OPERATION, MOCK_COLL_TASK.toLower(),
             ASYNC, String.valueOf(i),
 
-            "sleep", (i == 0 ? "1000" : "1") //first task waits for 1 second, and thus blocking
-            // all other tasks. Subsequent tasks only wait for 1ms
+            // third task waits for a long time, and thus blocks the queue for all other tasks for A_COLL.
+            // Subsequent tasks as well as the first two only wait for 1ms
+            "sleep", (i == 2 ? "10000" : "1")
         )));
         log.info("MOCK task added {}", i);
+      }
 
+      // Wait until we see the first two A_COLL tasks getting processed
+      boolean acoll0done = false, acoll1done = false;
+      for (int i = 0; i < 500; i++) {
+        if (!acoll0done) {
+          acoll0done = null != getStatusResponse("0", client).getResponse().get("MOCK_FINISHED");
+        }
+        if (!acoll1done) {
+          acoll1done = null != getStatusResponse("1", client).getResponse().get("MOCK_FINISHED");
+        }
+        if (acoll0done && acoll1done) break;
+        Thread.sleep(100);
       }
-      Thread.sleep(100);//wait and post the next message
+      assertTrue("Queue did not process first two tasks on A_COLL, can't run test", acoll0done && acoll1done);
+
+      // Make sure the long running task did not finish, otherwise no way the B_COLL task can be tested to run in parallel with it
+      assertNull("Long running task finished too early, can't test", getStatusResponse("2", client).getResponse().get("MOCK_FINISHED"));
 
-      //this is not going to be blocked because it operates on another collection
+      // Enqueue a task on another collection not competing with the lock on A_COLL and see that it can be executed right away
       distributedQueue.offer(Utils.toJSON(Utils.makeMap(
           "collection", "B_COLL",
           QUEUE_OPERATION, MOCK_COLL_TASK.toLower(),
           ASYNC, "200",
           "sleep", "1"
       )));
 
-
-      Long acoll = null, bcoll = null;
+      // We now check that either the B_COLL task has completed before the third (long running) task on A_COLL,
+      // Or if both have completed (if this check got significantly delayed for some reason), we verify B_COLL was first.
+      Long acoll3 = null, bcoll = null;
       for (int i = 0; i < 500; i++) {
-        if (bcoll == null) {
-          CollectionAdminResponse statusResponse = getStatusResponse("200", client);
-          bcoll = (Long) statusResponse.getResponse().get("MOCK_FINISHED");
-        }
-        if (acoll == null) {
-          CollectionAdminResponse statusResponse = getStatusResponse("2", client);
-          acoll = (Long) statusResponse.getResponse().get("MOCK_FINISHED");
+        if (acoll3 == null) {

Review comment:
       moved




----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org