lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1588487 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/ solr/test-framework/ solr/test-framework/src/java/org/apache/solr/cloud/
Date Fri, 18 Apr 2014 15:12:42 GMT
Author: markrmiller
Date: Fri Apr 18 15:12:41 2014
New Revision: 1588487

URL: http://svn.apache.org/r1588487
Log:
SOLR-5996: Fix checkIfDiffIsLegal, add some testing, refactor out a few methods into CloudInspectUtil.

Added:
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java
      - copied, changed from r1588486, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java
      - copied, changed from r1588486, lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java?rev=1588487&r1=1588486&r2=1588487&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
Fri Apr 18 15:12:41 2014
@@ -412,7 +412,7 @@ public class FullSolrCloudDistribCmdsTes
     long cloudCount = cloudClient.query(query).getResults().getNumFound();
 
     
-    compareResults(controlCount, cloudCount);
+    CloudInspectUtil.compareResults(controlClient, cloudClient);
     
     assertEquals("Control does not match cloud", controlCount, cloudCount);
     System.out.println("DOCS:" + controlCount);

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java?rev=1588487&r1=1588486&r2=1588487&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
Fri Apr 18 15:12:41 2014
@@ -219,11 +219,8 @@ public class SyncSliceTest extends Abstr
             + leaderJetty.url + " Dead Guy:" + deadJetty.url + "skip list:" + skipServers,
shardFailMessage);
     
     // good place to test compareResults
-    boolean shouldFail = compareResults(
-        controlClient.query(new SolrQuery("*:*")).getResults().getNumFound(),
-        cloudClient.query(new SolrQuery("*:*")).getResults().getNumFound());
-    assertTrue("A test that compareResults is working correctly failed",
-        shouldFail);
+    boolean shouldFail = CloudInspectUtil.compareResults(controlClient, cloudClient);
+    assertTrue("A test that compareResults is working correctly failed", shouldFail);
     
     jetties = new HashSet<>();
     jetties.addAll(shardToJetty.get("shard1"));

Copied: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java
(from r1588486, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java?p2=lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java&p1=lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestCloudInspectUtil.java&r1=1588486&r2=1588487&rev=1588487&view=diff
==============================================================================
    (empty)

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1588487&r1=1588486&r2=1588487&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
(original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Fri Apr 18 15:12:41 2014
@@ -1036,7 +1036,7 @@ public abstract class AbstractFullDistri
             SolrDocumentList lst1 = lastJetty.client.solrClient.query(query).getResults();
             SolrDocumentList lst2 = cjetty.client.solrClient.query(query).getResults();
 
-            showDiff(lst1, lst2, lastJetty.url, cjetty.url);
+            CloudInspectUtil.showDiff(lst1, lst2, lastJetty.url, cjetty.url);
           }
 
         }
@@ -1101,92 +1101,6 @@ public abstract class AbstractFullDistri
       }
     }
   }
-  
-  private String toStr(SolrDocumentList lst, int maxSz) {
-    if (lst.size() <= maxSz) return lst.toString();
-
-    StringBuilder sb = new StringBuilder("SolrDocumentList[sz=" + lst.size());
-    if (lst.size() != lst.getNumFound()) {
-      sb.append(" numFound=" + lst.getNumFound());
-    }
-    sb.append("]=");
-    sb.append(lst.subList(0,maxSz/2).toString());
-    sb.append(" , [...] , ");
-    sb.append(lst.subList(lst.size()-maxSz/2, lst.size()).toString());
-
-    return sb.toString();
-  }
-  
-  boolean checkIfDiffIsLegal(SolrDocumentList a, SolrDocumentList b, String aName, String
bName, Set<String> addFails, Set<String> deleteFails) {
-    boolean legal = true;
-    Set<SolrDocument> setA = new HashSet<>();
-    for (SolrDocument sdoc : a) {
-      setA.add(sdoc);
-    }
-
-    Set<SolrDocument> setB = new HashSet<>();
-    for (SolrDocument sdoc : b) {
-      setB.add(sdoc);
-    }
-
-    Set<SolrDocument> onlyInA = new HashSet<>(setA);
-    onlyInA.removeAll(setB);
-    Set<SolrDocument> onlyInB = new HashSet<>(setB);
-    onlyInB.removeAll(setA);
-
-    for (SolrDocument doc : onlyInA) {
-      if (!addFails.contains(doc.getFirstValue("id"))) {
-        legal = false;
-      } else {
-        System.err.println("###### Only in " + aName + ": " + onlyInA
-            + ", but this is expected because we found an add fail for "
-            + doc.getFirstValue("id"));
-      }
-    }
-      
-    for (SolrDocument doc : onlyInB) {
-      if (!deleteFails.contains(doc.getFirstValue("id"))) {
-        legal = false;
-      } else {
-        System.err.println("###### Only in " + bName + ": " + onlyInB
-            + ", but this is expected because we found a delete fail for "
-            + doc.getFirstValue("id"));
-      }
-    }
-    
-    return legal;
-  }
-
-  Set<Map> showDiff(SolrDocumentList a, SolrDocumentList b, String aName, String bName)
{
-    System.err.println("######"+aName+ ": " + toStr(a,10));
-    System.err.println("######"+bName+ ": " + toStr(b,10));
-    System.err.println("###### sizes=" + a.size() + "," + b.size());
-    
-    Set<Map> setA = new HashSet<>();
-    for (SolrDocument sdoc : a) {
-      setA.add(new HashMap(sdoc));
-    }
-
-    Set<Map> setB = new HashSet<>();
-    for (SolrDocument sdoc : b) {
-      setB.add(new HashMap(sdoc));
-    }
-
-    Set<Map> onlyInA = new HashSet<>(setA);
-    onlyInA.removeAll(setB);
-    Set<Map> onlyInB = new HashSet<>(setB);
-    onlyInB.removeAll(setA);
-
-    if (onlyInA.size() > 0) {
-      System.err.println("###### Only in " + aName + ": " + onlyInA);
-    }
-    if (onlyInB.size() > 0) {
-      System.err.println("###### Only in " + bName + ": " + onlyInB);
-    }
-
-    onlyInA.addAll(onlyInB);
-    return onlyInA;
-  }
 
   /* Checks both shard replcia consistency and against the control shard.
   * The test will be failed if differences are found.
@@ -1272,70 +1186,12 @@ public abstract class AbstractFullDistri
       String msg = "document count mismatch.  control=" + controlDocs + " sum(shards)="+
cnt + " cloudClient="+cloudClientDocs;
       log.error(msg);
 
-      boolean shouldFail = compareResults(controlDocs, cloudClientDocs, addFails, deleteFails);
+      boolean shouldFail = CloudInspectUtil.compareResults(controlClient, cloudClient, addFails,
deleteFails);
       if (shouldFail) {
         fail(msg);
       }
     }
   }
-
-  protected boolean compareResults(long controlDocs, long cloudClientDocs)
-      throws SolrServerException {
-    return compareResults(controlDocs, cloudClientDocs, null, null);
-  }
-  
-  protected boolean compareResults(long controlDocs, long cloudClientDocs, Set<String>
addFails, Set<String> deleteFails)
-      throws SolrServerException {
-    SolrParams q;
-    SolrDocumentList controlDocList;
-    SolrDocumentList cloudDocList;
-    // re-execute the query getting ids
-    q = params("q","*:*","rows","100000", "fl","id", "tests","checkShardConsistency(vsControl)/getIds");
   // add a tag to aid in debugging via logs
-    controlDocList = controlClient.query(q).getResults();
-    if (controlDocs != controlDocList.getNumFound()) {
-      log.error("Something changed! control now " + controlDocList.getNumFound());
-    };
-
-    cloudDocList = cloudClient.query(q).getResults();
-    if (cloudClientDocs != cloudDocList.getNumFound()) {
-      log.error("Something changed! cloudClient now " + cloudDocList.getNumFound());
-    };
-
-    if (addFails != null || deleteFails != null) {
-      boolean legal = checkIfDiffIsLegal(controlDocList, cloudDocList,
-          "controlDocList", "cloudDocList", addFails, deleteFails);
-      if (legal) {
-        return false;
-      }
-    }
-    
-    Set<Map> differences = showDiff(controlDocList, cloudDocList,
-        "controlDocList", "cloudDocList");
-
-    // get versions for the mismatched ids
-    boolean foundId = false;
-    StringBuilder ids = new StringBuilder("id:(");
-    for (Map doc : differences) {
-      ids.append(" "+doc.get("id"));
-      foundId = true;
-    }
-    ids.append(")");
-    
-    if (foundId) {
-      // get versions for those ids that don't match
-      q = params("q", ids.toString(), "rows", "100000", "fl", "id,_version_",
-          "sort", "id asc", "tests",
-          "checkShardConsistency(vsControl)/getVers"); // add a tag to aid in
-                                                       // debugging via logs
-      
-      SolrDocumentList a = controlClient.query(q).getResults();
-      SolrDocumentList b = cloudClient.query(q).getResults();
-      
-      log.error("controlClient :" + a + "\n\tcloudClient :" + b);
-    }
-    
-    return true;
-  }
   
   protected SolrServer getClient(String nodeName) {
     for (CloudJettyRunner cjetty : cloudJettys) {

Copied: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java
(from r1588486, lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java)
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java?p2=lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java&p1=lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/CloudInspectUtil.java&r1=1588486&r2=1588487&rev=1588487&view=diff
==============================================================================
    (empty)



Mime
View raw message