You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2017/01/05 14:30:13 UTC

lucene-solr:jira/solr-5944: SOLR-5944: Fix UpdateLogTest to rename a test and add more conditions for deletes

Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-5944 7431268ab -> aeb114ffd


SOLR-5944: Fix UpdateLogTest to rename a test and add more conditions for deletes


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/aeb114ff
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/aeb114ff
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/aeb114ff

Branch: refs/heads/jira/solr-5944
Commit: aeb114ffdd1f29880d2be7adfc045ac1855c0ef5
Parents: 7431268
Author: ichattopadhyaya@gmail.com <ic...@gmail.com>
Authored: Thu Jan 5 19:59:50 2017 +0530
Committer: ichattopadhyaya@gmail.com <ic...@gmail.com>
Committed: Thu Jan 5 19:59:50 2017 +0530

----------------------------------------------------------------------
 .../org/apache/solr/update/UpdateLogTest.java   | 32 ++++++++++++++------
 1 file changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/aeb114ff/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java b/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java
index 3c1befa..2c0fd3c 100644
--- a/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java
+++ b/solr/core/src/test/org/apache/solr/update/UpdateLogTest.java
@@ -29,6 +29,7 @@ import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.update.processor.DistributedUpdateProcessor;
 import org.junit.BeforeClass;
 import org.junit.Test;
+
 import static org.junit.internal.matchers.StringContains.containsString;
 
 public class UpdateLogTest extends SolrTestCaseJ4 {
@@ -157,17 +158,28 @@ public class UpdateLogTest extends SolrTestCaseJ4 {
   }
 
   @Test
-  public void testApplyPartialUpdatesWithDBQ() { // nocommit: missleading name?
-
-    // nocommit: no in-place updates happening in this test?
- 
+  public void testApplyPartialUpdatesWithDelete() throws Exception {
     ulogAdd(ulog, null, sdoc("id", "1", "title_s", "title1", "val1_i_dvo", "1", "_version_", "100"));
-    ulogAdd(ulog, 100L, sdoc("id", "1", "val1_i_dvo", "2", "_version_", "101"));
-    ulogAdd(ulog, 101L, sdoc("id", "1", "val1_i_dvo", "3", "_version_", "102"));
-    ulogDelete(ulog, "1", 200L, true); // dbq, "id:1"
-    assertNull(ulog.lookup(DOC_1_INDEXED_ID));
-
-    // nocommit: need more rigerous assertions about expected behavior after DBQ (new RT searcher?)
+    ulogAdd(ulog, 100L, sdoc("id", "1", "val1_i_dvo", "2", "_version_", "101")); // in-place update
+    ulogAdd(ulog, 101L, sdoc("id", "1", "val1_i_dvo", "3", "_version_", "102")); // in-place update
+    
+    // sanity check that the update log has one document, and RTG returns the document
+    assertEquals(1, ulog.map.size());
+    assertJQ(req("qt","/get", "id","1"), "=={'doc':{\"id\":\"1\", \"val1_i_dvo\":3, \"_version_\":102, \"title_s\":\"title1\"}}");
+    
+    boolean dbq = random().nextBoolean();
+    ulogDelete(ulog, "1", 200L, dbq); // delete id:1 document
+    if (dbq) {
+      assertNull(ulog.lookup(DOC_1_INDEXED_ID)); // any DBQ clears out the ulog, so this document shouldn't exist
+      assertEquals(0, ulog.map.size());
+      assertTrue(String.valueOf(ulog.prevMap), ulog.prevMap == null || ulog.prevMap.size() == 0);
+      assertTrue(String.valueOf(ulog.prevMap2), ulog.prevMap2 == null || ulog.prevMap2.size() == 0);
+      // verify that the document is deleted, by doing an RTG call
+      assertJQ(req("qt","/get", "id","1"), "=={'doc':null}");
+    } else { // dbi
+      List entry = ((List)ulog.lookup(DOC_1_INDEXED_ID));
+      assertEquals(UpdateLog.DELETE, (int)entry.get(UpdateLog.FLAGS_IDX) & UpdateLog.OPERATION_MASK);
+    }
   }
 
   /**