You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2020/02/12 18:25:00 UTC
[lucene-solr] branch branch_8x updated: SOLR-14245: Fix
ReplicaListTransformerTest
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 3dd484b SOLR-14245: Fix ReplicaListTransformerTest
3dd484b is described below
commit 3dd484ba29db04e4b5d4181e4a042dcc448b34be
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Wed Feb 12 11:10:26 2020 -0700
SOLR-14245: Fix ReplicaListTransformerTest
Previous changes to this issue 'fixed' the way the test was creating mock Replica instances,
to ensure all properties were specified -- but these changes tickled a bug in the existing test
scaffolding that caused it's "expecations" to be based on a regex check against only the base "url"
even though the test logic itself looked at the entire "core url"
The result is that there were reproducible failures if/when the randomly generated regex matched
".*1.*" because the existing test logic did not expect that to match the url or a Replica with
a core name of "core1" because it only considered the base url
(cherry picked from commit 49e20dbee4b7e74448928a48bfbb50da1018400f)
---
.../solrj/routing/ReplicaListTransformerTest.java | 32 ++++++++++++++++------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/routing/ReplicaListTransformerTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/routing/ReplicaListTransformerTest.java
index 2b784e5..5e90da2 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/routing/ReplicaListTransformerTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/routing/ReplicaListTransformerTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.solr.client.solrj.routing;
+import java.lang.invoke.MethodHandles;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -32,7 +34,11 @@ import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class ReplicaListTransformerTest extends SolrTestCase {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// A transformer that keeps only matching choices
private static class ToyMatchingReplicaListTransformer implements ReplicaListTransformer {
@@ -46,6 +52,7 @@ public class ReplicaListTransformerTest extends SolrTestCase {
public void transform(List<?> choices)
{
+ log.info("regex transform input: {}", choices);
Iterator<?> it = choices.iterator();
while (it.hasNext()) {
Object choice = it.next();
@@ -58,7 +65,9 @@ public class ReplicaListTransformerTest extends SolrTestCase {
} else {
url = null;
}
+ log.info("considering: {} w/url={}", choice, url);
if (url == null || !url.matches(regex)) {
+ log.info("removing {}", choice);
it.remove();
}
}
@@ -76,6 +85,7 @@ public class ReplicaListTransformerTest extends SolrTestCase {
public void transform(List<?> choices)
{
// no-op
+ log.info("No-Op transform ignoring input: {}", choices);
}
}
@@ -87,11 +97,11 @@ public class ReplicaListTransformerTest extends SolrTestCase {
final ReplicaListTransformer transformer;
if (random().nextBoolean()) {
-
+ log.info("Using ToyMatching Transfomer");
transformer = new ToyMatchingReplicaListTransformer(regex);
} else {
-
+ log.info("Using conditional Transfomer");
transformer = new HttpShardHandlerFactory() {
@Override
@@ -126,25 +136,29 @@ public class ReplicaListTransformerTest extends SolrTestCase {
final String url = urls.get(ii);
final Map<String,Object> propMap = new HashMap<String,Object>();
propMap.put("base_url", url);
- propMap.put("core", "core1");
- propMap.put("node_name", "node1");
+ propMap.put("core", "test_core");
+ propMap.put("node_name", "test_node");
propMap.put("type", "NRT");
// a skeleton replica, good enough for this test's purposes
final Replica replica = new Replica(name, propMap,"c1","s1");
inputs.add(replica);
- if (url.matches(regex)) {
+ final String coreUrl = replica.getCoreUrl();
+ if (coreUrl.matches(regex)) {
+ log.info("adding replica=[{}] to expected due to core url ({}) regex match on {} ",
+ replica, coreUrl, regex);
expectedTransformed.add(replica);
+ } else {
+ log.info("NOT expecting replica=[{}] due to core url ({}) regex mismatch ({})",
+ replica, coreUrl, regex);
}
+
}
final List<Replica> actualTransformed = new ArrayList<>(inputs);
transformer.transform(actualTransformed);
- assertEquals(expectedTransformed.size(), actualTransformed.size());
- for (int ii=0; ii<expectedTransformed.size(); ++ii) {
- assertEquals("mismatch for ii="+ii, expectedTransformed.get(ii), actualTransformed.get(ii));
- }
+ assertEquals(expectedTransformed, actualTransformed);
}
private final List<String> createRandomUrls() throws Exception {