madrob commented on a change in pull request #112: URL: https://github.com/apache/solr/pull/112#discussion_r628351285
########## File path: solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java ########## @@ -528,31 +511,38 @@ private void waitForNumDocsInAllActiveReplicas(int numDocs) throws IOException, } private void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas) throws IOException, SolrServerException, InterruptedException { - waitForNumDocsInAllReplicas(numDocs, replicas, "*:*"); + waitForNumDocsInAllReplicas(numDocs, replicas, "*:*", null, null); } - private void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas, String query) throws IOException, SolrServerException, InterruptedException { + static void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas, String query, String user, String pass) throws IOException, SolrServerException, InterruptedException { TimeOut t = new TimeOut(REPLICATION_TIMEOUT_SECS, TimeUnit.SECONDS, TimeSource.NANO_TIME); for (Replica r:replicas) { - try (HttpSolrClient replicaClient = getHttpSolrClient(r.getCoreUrl())) { + String replicaUrl = r.getCoreUrl(); + try (HttpSolrClient replicaClient = getHttpSolrClient(replicaUrl)) { while (true) { + QueryRequest req = new QueryRequest(new SolrQuery(query)); + if (user != null) { Review comment: `&& pass != null`? ########## File path: solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java ########## @@ -528,31 +511,38 @@ private void waitForNumDocsInAllActiveReplicas(int numDocs) throws IOException, } private void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas) throws IOException, SolrServerException, InterruptedException { - waitForNumDocsInAllReplicas(numDocs, replicas, "*:*"); + waitForNumDocsInAllReplicas(numDocs, replicas, "*:*", null, null); } - private void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas, String query) throws IOException, SolrServerException, InterruptedException { + static void waitForNumDocsInAllReplicas(int numDocs, Collection<Replica> replicas, String query, String user, String pass) throws IOException, SolrServerException, InterruptedException { TimeOut t = new TimeOut(REPLICATION_TIMEOUT_SECS, TimeUnit.SECONDS, TimeSource.NANO_TIME); for (Replica r:replicas) { - try (HttpSolrClient replicaClient = getHttpSolrClient(r.getCoreUrl())) { + String replicaUrl = r.getCoreUrl(); + try (HttpSolrClient replicaClient = getHttpSolrClient(replicaUrl)) { while (true) { + QueryRequest req = new QueryRequest(new SolrQuery(query)); + if (user != null) { + req.setBasicAuthCredentials(user, pass); + } try { - assertEquals("Replica " + r.getName() + " not up to date after " + REPLICATION_TIMEOUT_SECS + " seconds", - numDocs, replicaClient.query(new SolrQuery(query)).getResults().getNumFound()); + long numFound = req.process(replicaClient).getResults().getNumFound(); + assertEquals("Replica " + r.getName() + " (" + replicaUrl + ") not up to date after 30 seconds; found " + numFound + ", expected " + numDocs, Review comment: the "found x expected y" will be part of the assertion failed message anyway. ########## File path: solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java ########## @@ -1208,6 +1208,7 @@ private void setupPolling(String intervalStr) { log.info("Poll disabled"); return; } + ExecutorUtil.setServerThreadFlag(true); // so PKI auth works Review comment: I agree with @cpoerschke - unset it in the finally block. I don't want somebody else to later come in and accidentally re-use this thread pool and get surprised with a RCE. ########## File path: solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java ########## @@ -229,37 +223,26 @@ public void testAddDocs() throws Exception { numDocs++; cluster.getSolrClient().add(collectionName, new SolrInputDocument("id", String.valueOf(numDocs), "foo", "bar")); cluster.getSolrClient().commit(collectionName); + log.info("Committed doc {} to leader", numDocs); Slice s = docCollection.getSlices().iterator().next(); try (HttpSolrClient leaderClient = getHttpSolrClient(s.getLeader().getCoreUrl())) { assertEquals(numDocs, leaderClient.query(new SolrQuery("*:*")).getResults().getNumFound()); } + log.info("Found {} docs in leader, verifying updates make it to {} pull replicas", numDocs, numPullReplicas); - TimeOut t = new TimeOut(REPLICATION_TIMEOUT_SECS, TimeUnit.SECONDS, TimeSource.NANO_TIME); - for (Replica r:s.getReplicas(EnumSet.of(Replica.Type.PULL))) { - //TODO: assert replication < REPLICATION_TIMEOUT_SECS + List<Replica> pullReplicas = s.getReplicas(EnumSet.of(Replica.Type.PULL)); + waitForNumDocsInAllReplicas(numDocs, pullReplicas); + + for (Replica r : pullReplicas) { try (HttpSolrClient pullReplicaClient = getHttpSolrClient(r.getCoreUrl())) { - while (true) { - try { - assertEquals("Replica " + r.getName() + " not up to date after 10 seconds", - numDocs, pullReplicaClient.query(new SolrQuery("*:*")).getResults().getNumFound()); - break; - } catch (AssertionError e) { - if (t.hasTimedOut()) { - throw e; - } else { - Thread.sleep(100); - } - } - } - SolrQuery req = new SolrQuery( - "qt", "/admin/plugins", - "stats", "true"); + SolrQuery req = new SolrQuery("qt", "/admin/plugins", "stats", "true"); QueryResponse statsResponse = pullReplicaClient.query(req); - assertEquals("Replicas shouldn't process the add document request: " + statsResponse, - 0L, ((Map<String, Object>)(statsResponse.getResponse()).findRecursive("plugins", "UPDATE", "updateHandler", "stats")).get("UPDATE.updateHandler.adds")); + assertNull("Replicas shouldn't process the add document request: " + statsResponse, Review comment: I liked the comment you had before about how pull replicas don't have add counts -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org