diff options
author | Nick Vatamaniuc <vatamane@apache.org> | 2019-09-24 13:07:12 -0400 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2019-09-24 13:41:11 -0400 |
commit | fe9ffad8fa49bcbe071f416805564547e80c6b96 (patch) | |
tree | 7d4cc07f8ab4117f63b4e744ffd6f8b877ffba06 | |
parent | eed8fb189dcbc2fe17eff798d16228ae036ce0ac (diff) | |
download | couchdb-fe9ffad8fa49bcbe071f416805564547e80c6b96.tar.gz |
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.
-rw-r--r-- | test/elixir/test/replication_test.exs | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs index 3ea525aed..3d0e50b40 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 |