You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/09/24 17:10:28 UTC

[couchdb] branch add-integration-test-for-replicated-deleted-docs created (now 2b42a19)

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a change to branch add-integration-test-for-replicated-deleted-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at 2b42a19  Add more deleted docs replication cases to integration test

This branch includes the following new commits:

     new 2b42a19  Add more deleted docs replication cases to integration test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Add more deleted docs replication cases to integration test

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch add-integration-test-for-replicated-deleted-docs
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 2b42a19ead49c8cb3ce3431bef6973c7b6a01892
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Tue Sep 24 13:07:12 2019 -0400

    Add more deleted docs replication cases to integration test
    
    We test that a newly deleted document is replicated to the target and it bumps
    the deled doc count but doesn't change doc count.
    
    Another thing to test is that an already deleted document is replicated in
    where its revision path was extended on the source then gets replicated to the
    target. In that case neither del doc count not doc count are bumped.
---
 test/elixir/test/replication_test.exs | 62 ++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 5 deletions(-)

diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index 3ea525a..3d0e50b 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -430,6 +430,58 @@ defmodule ReplicationTest do
     assert change["id"] == del_doc["_id"]
     assert change["deleted"]
 
+    # Test new deletion is replicated, document wasn't on the target yet
+    [del_doc] = save_docs(src_db_name, [%{"_id" => "new_del_doc_1"}])
+
+    del_doc = Map.put(del_doc, "_deleted", true)
+    [del_doc] = save_docs(src_db_name, [del_doc])
+
+    result = replicate(src_prefix <> src_db_name, tgt_prefix <> tgt_db_name)
+    assert result["ok"]
+
+    retry_until(fn ->
+      src_info = get_db_info(src_db_name)
+      tgt_info = get_db_info(tgt_db_name)
+
+      assert tgt_info["doc_count"] == src_info["doc_count"]
+      assert tgt_info["doc_del_count"] == src_info["doc_del_count"]
+      assert tgt_info["doc_del_count"] == 2
+    end)
+
+    resp = Couch.get("/#{tgt_db_name}/#{del_doc["_id"]}")
+    assert resp.status_code == 404
+
+    resp = Couch.get!("/#{tgt_db_name}/_changes")
+    [change] = Enum.filter(resp.body["results"], &(&1["id"] == del_doc["_id"]))
+    assert change["id"] == del_doc["_id"]
+    assert change["deleted"]
+
+    # Test an already deleted deletion being replicated
+    [del_doc] = save_docs(src_db_name, [%{"_id" => "new_del_doc_1"}])
+    del_doc = Map.put(del_doc, "_deleted", true)
+    [del_doc] = save_docs(src_db_name, [del_doc])
+
+    result = replicate(src_prefix <> src_db_name, tgt_prefix <> tgt_db_name)
+    assert result["ok"]
+
+    retry_until(fn ->
+      src_info = get_db_info(src_db_name)
+      tgt_info = get_db_info(tgt_db_name)
+
+      assert tgt_info["doc_count"] == src_info["doc_count"]
+      assert tgt_info["doc_del_count"] == src_info["doc_del_count"]
+      assert tgt_info["doc_del_count"] == 2
+    end)
+
+    resp = Couch.get("/#{tgt_db_name}/#{del_doc["_id"]}")
+    assert resp.status_code == 404
+
+    resp = Couch.get!("/#{tgt_db_name}/_changes")
+    [change] = Enum.filter(resp.body["results"], &(&1["id"] == del_doc["_id"]))
+    assert change["id"] == del_doc["_id"]
+    assert change["deleted"]
+
+
     # Test replicating a conflict
     doc = Couch.get!("/#{src_db_name}/2").body
     [doc] = save_docs(src_db_name, [Map.put(doc, :value, "white")])
@@ -446,7 +498,7 @@ defmodule ReplicationTest do
     assert tgt_info["doc_count"] == src_info["doc_count"]
 
     assert is_list(result["history"])
-    assert length(result["history"]) == 4
+    assert length(result["history"]) == 6
     history = Enum.at(result["history"], 0)
     assert history["missing_checked"] == 1
     assert history["missing_found"] == 1
@@ -473,7 +525,7 @@ defmodule ReplicationTest do
     assert tgt_info["doc_count"] == src_info["doc_count"]
 
     assert is_list(result["history"])
-    assert length(result["history"]) == 5
+    assert length(result["history"]) == 7
     history = Enum.at(result["history"], 0)
     assert history["missing_checked"] == 1
     assert history["missing_found"] == 1
@@ -502,7 +554,7 @@ defmodule ReplicationTest do
     assert tgt_info["doc_count"] == src_info["doc_count"]
 
     assert is_list(result["history"])
-    assert length(result["history"]) == 6
+    assert length(result["history"]) == 8
     history = Enum.at(result["history"], 0)
     assert history["missing_checked"] == 1
     assert history["missing_found"] == 1
@@ -534,7 +586,7 @@ defmodule ReplicationTest do
     assert tgt_info["doc_count"] == src_info["doc_count"]
 
     assert is_list(result["history"])
-    assert length(result["history"]) == 7
+    assert length(result["history"]) == 9
     history = Enum.at(result["history"], 0)
     assert history["missing_checked"] == 3
     assert history["missing_found"] == 1
@@ -559,7 +611,7 @@ defmodule ReplicationTest do
     assert tgt_info["doc_count"] == src_info["doc_count"]
 
     assert is_list(result["history"])
-    assert length(result["history"]) == 8
+    assert length(result["history"]) == 10
     history = Enum.at(result["history"], 0)
     assert history["missing_checked"] == 2
     assert history["missing_found"] == 0