You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2018/04/12 22:40:44 UTC
lucene-solr:branch_7x: SOLR-12150: Fix a test bug in
CdcrBidirectionalTest.testBiDir
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 34bbbc428 -> c6c0821dd
SOLR-12150: Fix a test bug in CdcrBidirectionalTest.testBiDir
(cherry picked from commit 2a2a0b6)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c6c0821d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c6c0821d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c6c0821d
Branch: refs/heads/branch_7x
Commit: c6c0821ddb235269de27daeeb34db43110aaf0c2
Parents: 34bbbc4
Author: Varun Thacker <va...@apache.org>
Authored: Thu Apr 12 15:25:11 2018 -0700
Committer: Varun Thacker <va...@apache.org>
Committed: Thu Apr 12 15:40:39 2018 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solr/cloud/cdcr/CdcrBidirectionalTest.java | 24 +++++++++++---------
2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c6c0821d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e48e20d..4cf94f0 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -129,6 +129,8 @@ Bug Fixes
* SOLR-12065: A successful restore collection should mark the shard state as active and not buffering
(Rohit, Varun Thacker)
+
+* SOLR-12150: Fix a test bug in CdcrBidirectionalTest.testBiDir (Steve Rowe, Amrit Sarkar via Varun Thacker)
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c6c0821d/solr/core/src/test/org/apache/solr/cloud/cdcr/CdcrBidirectionalTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/cdcr/CdcrBidirectionalTest.java b/solr/core/src/test/org/apache/solr/cloud/cdcr/CdcrBidirectionalTest.java
index 4a7fae4..a11b9ac 100644
--- a/solr/core/src/test/org/apache/solr/cloud/cdcr/CdcrBidirectionalTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/cdcr/CdcrBidirectionalTest.java
@@ -32,7 +32,9 @@ import org.apache.solr.cloud.MiniSolrCloudCluster;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.TimeSource;
import org.apache.solr.handler.CdcrParams;
+import org.apache.solr.util.TimeOut;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -185,19 +187,20 @@ public class CdcrBidirectionalTest extends SolrTestCaseJ4 {
// ATOMIC UPDATES
req = new UpdateRequest();
doc = new SolrInputDocument();
+ String atomicFieldName = "abc";
ImmutableMap.of("", "");
String atomicUpdateId = "cluster2_" + random().nextInt(numDocs_c2);
doc.addField("id", atomicUpdateId);
doc.addField("xyz", ImmutableMap.of("delete", ""));
- doc.addField("abc", ImmutableMap.of("set", "ABC"));
+ doc.addField(atomicFieldName, ImmutableMap.of("set", "ABC"));
req.add(doc);
req.process(cluster2SolrClient);
cluster2SolrClient.commit();
String atomicQuery = "id:" + atomicUpdateId;
response = cluster2SolrClient.query(new SolrQuery(atomicQuery));
- assertEquals("cluster 2 wrong doc", "ABC", response.getResults().get(0).get("abc"));
- assertEquals("cluster 1 wrong doc", "ABC", getDocFieldValue(cluster1SolrClient, atomicQuery, "ABC"));
+ assertEquals("cluster 2 wrong doc", "ABC", response.getResults().get(0).get(atomicFieldName));
+ assertEquals("cluster 1 wrong doc", "ABC", getDocFieldValue(cluster1SolrClient, atomicQuery, "ABC", atomicFieldName ));
// logging cdcr clusters queue response
@@ -218,17 +221,16 @@ public class CdcrBidirectionalTest extends SolrTestCaseJ4 {
}
}
- private String getDocFieldValue(CloudSolrClient clusterSolrClient, String query, String match) throws Exception {
- long start = System.nanoTime();
- QueryResponse response = null;
- while (System.nanoTime() - start <= TimeUnit.NANOSECONDS.convert(120, TimeUnit.SECONDS)) {
+ private String getDocFieldValue(CloudSolrClient clusterSolrClient, String query, String match, String field) throws Exception {
+ TimeOut waitTimeOut = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME);
+ while (!waitTimeOut.hasTimedOut()) {
clusterSolrClient.commit();
- response = clusterSolrClient.query(new SolrQuery(query));
- if (match.equals(response.getResults().get(0).get("abc"))) {
- break;
+ QueryResponse response = clusterSolrClient.query(new SolrQuery(query));
+ if (response.getResults().size() > 0 && match.equals(response.getResults().get(0).get(field))) {
+ return (String) response.getResults().get(0).get(field);
}
Thread.sleep(1000);
}
- return response != null ? (String) response.getResults().get(0).get("abc") : "";
+ return null;
}
}