You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2018/03/26 20:55:55 UTC
[couchdb] 24/33: WIP - add test suite
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch COUCHDB-3326-clustered-purge-davisp-refactor
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5b14d1bb319e3da93bcdb0334b5206610ba92c05
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Mar 26 13:21:43 2018 -0500
WIP - add test suite
---
src/couch/src/test_engine_compaction.erl | 8 ++++----
...urged_docs.erl => test_engine_fold_purge_infos.erl} | 14 +++++++-------
src/couch/src/test_engine_purge_docs.erl | 18 +++++++++---------
src/couch/src/test_engine_util.erl | 8 ++++----
src/couch/test/couch_db_purge_docs_tests.erl | 14 +++++++-------
5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/couch/src/test_engine_compaction.erl b/src/couch/src/test_engine_compaction.erl
index 665b7d8..18bf938 100644
--- a/src/couch/src/test_engine_compaction.erl
+++ b/src/couch/src/test_engine_compaction.erl
@@ -95,7 +95,7 @@ cet_compact_with_everything() ->
{<<"foo">>, [FooRev#rev_info.rev]}
],
- {ok, PIdRevs6} = Engine:fold_purged_docs(St6, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs6} = Engine:fold_purge_infos(St6, 0, fun fold_fun/2, [], []),
?assertEqual(PurgedIdRevs, PIdRevs6),
{ok, St7} = try
@@ -130,7 +130,7 @@ cet_compact_with_everything() ->
end),
{ok, St10, undefined} = Engine:finish_compaction(St9, DbName, [], Term),
- {ok, PIdRevs11} = Engine:fold_purged_docs(St10, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs11} = Engine:fold_purge_infos(St10, 0, fun fold_fun/2, [], []),
?assertEqual(PurgedIdRevs, PIdRevs11),
Db2 = test_engine_util:db_as_term(Engine, St10),
@@ -248,7 +248,7 @@ ignore_cet_compact_purged_docs_limit() ->
% check that before compaction all NumDocs of purge_requests
% are in purge_tree,
% even if NumDocs=1200 is greater than purged_docs_limit=1000
- {ok, PurgedIdRevs} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(1, Engine:get_oldest_purge_seq(St3)),
?assertEqual(NumDocs, length(PurgedIdRevs)),
@@ -260,7 +260,7 @@ ignore_cet_compact_purged_docs_limit() ->
% are in purge_tree
PurgedDocsLimit = Engine:get_purged_docs_limit(St5),
OldestPSeq = Engine:get_oldest_purge_seq(St5),
- {ok, PurgedIdRevs2} = Engine:fold_purged_docs(
+ {ok, PurgedIdRevs2} = Engine:fold_purge_infos(
St5, OldestPSeq - 1, fun fold_fun/2, [], []),
ExpectedOldestPSeq = NumDocs - PurgedDocsLimit + 1,
?assertEqual(ExpectedOldestPSeq, OldestPSeq),
diff --git a/src/couch/src/test_engine_fold_purged_docs.erl b/src/couch/src/test_engine_fold_purge_infos.erl
similarity index 91%
rename from src/couch/src/test_engine_fold_purged_docs.erl
rename to src/couch/src/test_engine_fold_purge_infos.erl
index 1dc0885..07131e4 100644
--- a/src/couch/src/test_engine_fold_purged_docs.erl
+++ b/src/couch/src/test_engine_fold_purge_infos.erl
@@ -10,7 +10,7 @@
% License for the specific language governing permissions and limitations under
% the License.
--module(test_engine_fold_purged_docs).
+-module(test_engine_fold_purge_infos).
-compile(export_all).
@@ -23,7 +23,7 @@
cet_empty_purged_docs() ->
{ok, Engine, St} = test_engine_util:init_engine(),
- ?assertEqual({ok, []}, Engine:fold_purged_docs(St, 0, fun fold_fun/2, [], [])).
+ ?assertEqual({ok, []}, Engine:fold_purge_infos(St, 0, fun fold_fun/2, [], [])).
cet_all_purged_docs() ->
@@ -49,7 +49,7 @@ cet_all_purged_docs() ->
{Actions2, IdsRevs} = {lists:reverse(RevActions2), lists:reverse(RevIdRevs)},
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
- {ok, PurgedIdRevs} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(IdsRevs, lists:reverse(PurgedIdRevs)).
@@ -77,7 +77,7 @@ cet_start_seq() ->
StartSeq = 3,
StartSeqIdRevs = lists:nthtail(StartSeq, lists:reverse(RIdRevs)),
- {ok, PurgedIdRevs} = Engine:fold_purged_docs(St3, StartSeq, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs} = Engine:fold_purge_infos(St3, StartSeq, fun fold_fun/2, [], []),
?assertEqual(StartSeqIdRevs, lists:reverse(PurgedIdRevs)).
@@ -98,13 +98,13 @@ cet_id_rev_repeated() ->
],
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
PurgedIdRevs0 = [{<<"foo">>, [Rev1]}],
- {ok, PurgedIdRevs1} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs1} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(PurgedIdRevs0, PurgedIdRevs1),
?assertEqual(1, Engine:get_purge_seq(St3)),
% purge the same Id,Rev when the doc still exists
{ok, St4} = test_engine_util:apply_actions(Engine, St3, Actions2),
- {ok, PurgedIdRevs2} = Engine:fold_purged_docs(St4, 0, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs2} = Engine:fold_purge_infos(St4, 0, fun fold_fun/2, [], []),
?assertEqual(PurgedIdRevs0, PurgedIdRevs2),
?assertEqual(1, Engine:get_purge_seq(St4)),
@@ -119,7 +119,7 @@ cet_id_rev_repeated() ->
% purge the same Id,Rev when the doc was completely purged
{ok, St6} = test_engine_util:apply_actions(Engine, St5, Actions3),
- {ok, PurgedIdRevs3} = Engine:fold_purged_docs(St6, 0, fun fold_fun/2, [], []),
+ {ok, PurgedIdRevs3} = Engine:fold_purge_infos(St6, 0, fun fold_fun/2, [], []),
?assertEqual(PurgedIdRevs00, lists:reverse(PurgedIdRevs3)),
?assertEqual(2, Engine:get_purge_seq(St6)).
diff --git a/src/couch/src/test_engine_purge_docs.erl b/src/couch/src/test_engine_purge_docs.erl
index a1dbae7..268011b 100644
--- a/src/couch/src/test_engine_purge_docs.erl
+++ b/src/couch/src/test_engine_purge_docs.erl
@@ -25,7 +25,7 @@ cet_purge_simple() ->
{create, {<<"foo">>, [{<<"vsn">>, 1}]}}
],
{ok, St2} = test_engine_util:apply_actions(Engine, St1, Actions1),
- {ok, PIdRevs2} = Engine:fold_purged_docs(St2, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs2} = Engine:fold_purge_infos(St2, 0, fun fold_fun/2, [], []),
?assertEqual(1, Engine:get_doc_count(St2)),
?assertEqual(0, Engine:get_del_doc_count(St2)),
@@ -41,7 +41,7 @@ cet_purge_simple() ->
{purge, {<<"foo">>, Rev}}
],
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
- {ok, PIdRevs3} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs3} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(0, Engine:get_doc_count(St3)),
?assertEqual(0, Engine:get_del_doc_count(St3)),
@@ -58,7 +58,7 @@ cet_purge_conflicts() ->
{conflict, {<<"foo">>, [{<<"vsn">>, 2}]}}
],
{ok, St2} = test_engine_util:apply_actions(Engine, St1, Actions1),
- {ok, PIdRevs2} = Engine:fold_purged_docs(St2, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs2} = Engine:fold_purge_infos(St2, 0, fun fold_fun/2, [], []),
?assertEqual(1, Engine:get_doc_count(St2)),
?assertEqual(0, Engine:get_del_doc_count(St2)),
@@ -74,7 +74,7 @@ cet_purge_conflicts() ->
{purge, {<<"foo">>, Rev1}}
],
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
- {ok, PIdRevs3} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs3} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(1, Engine:get_doc_count(St3)),
?assertEqual(0, Engine:get_del_doc_count(St3)),
@@ -90,7 +90,7 @@ cet_purge_conflicts() ->
{purge, {<<"foo">>, Rev2}}
],
{ok, St4} = test_engine_util:apply_actions(Engine, St3, Actions3),
- {ok, PIdRevs4} = Engine:fold_purged_docs(St4, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs4} = Engine:fold_purge_infos(St4, 0, fun fold_fun/2, [], []),
?assertEqual(0, Engine:get_doc_count(St4)),
?assertEqual(0, Engine:get_del_doc_count(St4)),
@@ -108,7 +108,7 @@ cet_add_delete_purge() ->
],
{ok, St2} = test_engine_util:apply_actions(Engine, St1, Actions1),
- {ok, PIdRevs2} = Engine:fold_purged_docs(St2, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs2} = Engine:fold_purge_infos(St2, 0, fun fold_fun/2, [], []),
?assertEqual(0, Engine:get_doc_count(St2)),
?assertEqual(1, Engine:get_del_doc_count(St2)),
@@ -124,7 +124,7 @@ cet_add_delete_purge() ->
{purge, {<<"foo">>, Rev}}
],
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
- {ok, PIdRevs3} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs3} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(0, Engine:get_doc_count(St3)),
?assertEqual(0, Engine:get_del_doc_count(St3)),
@@ -142,7 +142,7 @@ cet_add_two_purge_one() ->
],
{ok, St2} = test_engine_util:apply_actions(Engine, St1, Actions1),
- {ok, PIdRevs2} = Engine:fold_purged_docs(St2, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs2} = Engine:fold_purge_infos(St2, 0, fun fold_fun/2, [], []),
?assertEqual(2, Engine:get_doc_count(St2)),
?assertEqual(0, Engine:get_del_doc_count(St2)),
@@ -158,7 +158,7 @@ cet_add_two_purge_one() ->
{purge, {<<"foo">>, Rev}}
],
{ok, St3} = test_engine_util:apply_actions(Engine, St2, Actions2),
- {ok, PIdRevs3} = Engine:fold_purged_docs(St3, 0, fun fold_fun/2, [], []),
+ {ok, PIdRevs3} = Engine:fold_purge_infos(St3, 0, fun fold_fun/2, [], []),
?assertEqual(1, Engine:get_doc_count(St3)),
?assertEqual(0, Engine:get_del_doc_count(St3)),
diff --git a/src/couch/src/test_engine_util.erl b/src/couch/src/test_engine_util.erl
index 745e00f..3e6d2d6 100644
--- a/src/couch/src/test_engine_util.erl
+++ b/src/couch/src/test_engine_util.erl
@@ -24,7 +24,7 @@
test_engine_attachments,
test_engine_fold_docs,
test_engine_fold_changes,
- test_engine_fold_purged_docs,
+ test_engine_fold_purge_infos,
test_engine_purge_docs,
test_engine_compaction,
test_engine_ref_counting
@@ -238,7 +238,7 @@ gen_write(Engine, St, {purge, {DocId, PrevRevs0, _}}, UpdateSeq) ->
_ -> false
end
end,
- {ok, IsPurgedBefore} = Engine:fold_purged_docs(
+ {ok, IsPurgedBefore} = Engine:fold_purge_infos(
St, 0, FoldFun, false, []),
case IsPurgedBefore of
true -> {{}, UpdateSeq, purged_before};
@@ -263,7 +263,7 @@ gen_write(Engine, St, {purge, {DocId, PrevRevs0, _}}, UpdateSeq) ->
_ -> Acc
end
end,
- {ok, PurgedRevs} = Engine:fold_purged_docs(St, 0, FoldFun, [], []),
+ {ok, PurgedRevs} = Engine:fold_purge_infos(St, 0, FoldFun, [], []),
case lists:subtract(PrevRevs, PurgedRevs) of [] -> ok; _ ->
% If we didn't purge all the requested revisions
% and they haven't been purged before
@@ -498,7 +498,7 @@ db_purged_docs_as_term(Engine, St) ->
FoldFun = fun({PSeq, UUID, Id, Revs}, Acc) ->
[{PSeq, UUID, Id, Revs} | Acc]
end,
- {ok, PDocs} = Engine:fold_purged_docs(St, StartPSeq, FoldFun, [], []),
+ {ok, PDocs} = Engine:fold_purge_infos(St, StartPSeq, FoldFun, [], []),
lists:reverse(PDocs).
diff --git a/src/couch/test/couch_db_purge_docs_tests.erl b/src/couch/test/couch_db_purge_docs_tests.erl
index 1608957..070fb24 100644
--- a/src/couch/test/couch_db_purge_docs_tests.erl
+++ b/src/couch/test/couch_db_purge_docs_tests.erl
@@ -81,7 +81,7 @@ purge_simple(DbName) ->
?assertEqual([Rev2], PRevs2),
{ok, Db3} = couch_db:reopen(Db2),
- {ok, PIdsRevs} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs} = couch_db:fold_purge_infos(
Db3, 0, fun fold_fun/2, [], []),
?assertEqual(0, couch_db_engine:get_doc_count(Db3)),
?assertEqual(0, couch_db_engine:get_del_doc_count(Db3)),
@@ -109,7 +109,7 @@ add_delete_purge(DbName) ->
couch_db:ensure_full_commit(Db1),
{ok, Db2} = couch_db:reopen(Db1),
- {ok, PIdsRevs1} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs1} = couch_db:fold_purge_infos(
Db2, 0, fun fold_fun/2, [], []),
?assertEqual(0, couch_db_engine:get_doc_count(Db2)),
?assertEqual(1, couch_db_engine:get_del_doc_count(Db2)),
@@ -123,7 +123,7 @@ add_delete_purge(DbName) ->
?assertEqual([Rev2], PRevs),
{ok, Db3} = couch_db:reopen(Db2),
- {ok, PIdsRevs2} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs2} = couch_db:fold_purge_infos(
Db3, 0, fun fold_fun/2, [], []),
?assertEqual(0, couch_db_engine:get_doc_count(Db3)),
?assertEqual(0, couch_db_engine:get_del_doc_count(Db3)),
@@ -155,7 +155,7 @@ add_two_purge_one(DbName) ->
?assertEqual([Rev], PRevs),
{ok, Db3} = couch_db:reopen(Db2),
- {ok, PIdsRevs} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs} = couch_db:fold_purge_infos(
Db3, 0, fun fold_fun/2, [], []),
?assertEqual(1, couch_db_engine:get_doc_count(Db3)),
?assertEqual(0, couch_db_engine:get_del_doc_count(Db3)),
@@ -175,7 +175,7 @@ purge_id_not_exist(DbName) ->
?assertEqual([], PRevs),
{ok, Db2} = couch_db:reopen(Db),
- {ok, PIdsRevs} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs} = couch_db:fold_purge_infos(
Db2, 0, fun fold_fun/2, [], []),
?assertEqual(0, couch_db_engine:get_doc_count(Db2)),
?assertEqual(0, couch_db_engine:get_del_doc_count(Db2)),
@@ -208,7 +208,7 @@ purge_non_leaf_rev(DbName) ->
?assertEqual([], PRevs),
{ok, Db4} = couch_db:reopen(Db3),
- {ok, PIdsRevs} = couch_db:fold_purged_docs(Db4, 0, fun fold_fun/2, [], []),
+ {ok, PIdsRevs} = couch_db:fold_purge_infos(Db4, 0, fun fold_fun/2, [], []),
?assertEqual(1, couch_db_engine:get_doc_count(Db4)),
?assertEqual(2, couch_db_engine:get_update_seq(Db4)),
?assertEqual(0, couch_db_engine:get_purge_seq(Db4)),
@@ -241,7 +241,7 @@ purge_conflicts(DbName) ->
?assertEqual([Rev], PRevs),
{ok, Db4} = couch_db:reopen(Db3),
- {ok, PIdsRevs} = couch_db:fold_purged_docs(
+ {ok, PIdsRevs} = couch_db:fold_purge_infos(
Db4, 0, fun fold_fun/2, [], []),
% still has one doc
?assertEqual(1, couch_db_engine:get_doc_count(Db4)),
--
To stop receiving notification emails like this one, please contact
davisp@apache.org.