couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiangp...@apache.org
Subject [couchdb] 01/06: [05/10] Clustered Purge: Add upgrade tests
Date Tue, 10 Jul 2018 06:38:14 GMT
This is an automated email from the ASF dual-hosted git repository.

jiangphcn pushed a commit to branch COUCHDB-3326-clustered-purge-pr5-implementation
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit f291730ac026cc616ec7e34ae2b397d35986f9c1
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
AuthorDate: Wed May 30 17:01:01 2018 -0500

    [05/10] Clustered Purge: Add upgrade tests
    
    These test that we can successfully upgrade old databases that have
    various configurations of purge requests in the legacy format.
    
    COUCHDB-3326
    
    Co-authored-by: Mayya Sharipova <mayyas@ca.ibm.com>
    Co-authored-by: jiangphcn <jiangph@cn.ibm.com>
---
 src/couch/test/couch_bt_engine_upgrade_tests.erl   | 220 +++++++++++++++++++++
 src/couch/test/fixtures/db_with_1_purge_req.couch  | Bin 0 -> 12470 bytes
 .../fixtures/db_with_1_purge_req_for_2_docs.couch  | Bin 0 -> 16557 bytes
 src/couch/test/fixtures/db_with_2_purge_req.couch  | Bin 0 -> 16566 bytes
 src/couch/test/fixtures/db_without_purge_req.couch | Bin 0 -> 61644 bytes
 src/couch_pse_tests/src/cpse_test_purge_docs.erl   |  92 ++++-----
 src/couch_pse_tests/src/cpse_test_purge_seqs.erl   |  28 +--
 src/couch_pse_tests/src/cpse_util.erl              |   6 +-
 8 files changed, 283 insertions(+), 63 deletions(-)

diff --git a/src/couch/test/couch_bt_engine_upgrade_tests.erl b/src/couch/test/couch_bt_engine_upgrade_tests.erl
new file mode 100644
index 0000000..1d2a86d
--- /dev/null
+++ b/src/couch/test/couch_bt_engine_upgrade_tests.erl
@@ -0,0 +1,220 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_bt_engine_upgrade_tests).
+
+-include_lib("couch/include/couch_eunit.hrl").
+-include_lib("couch/include/couch_db.hrl").
+
+
+setup() ->
+    Ctx = test_util:start_couch(),
+    DbDir = config:get("couchdb", "database_dir"),
+    DbFileNames = [
+        "db_without_purge_req.couch",
+        "db_with_1_purge_req.couch",
+        "db_with_2_purge_req.couch",
+        "db_with_1_purge_req_for_2_docs.couch"
+    ],
+    NewPaths = lists:map(fun(DbFileName) ->
+        OldDbFilePath = filename:join([?FIXTURESDIR, DbFileName]),
+        NewDbFilePath = filename:join([DbDir, DbFileName]),
+        ok = filelib:ensure_dir(NewDbFilePath),
+        file:delete(NewDbFilePath),
+        {ok, _} = file:copy(OldDbFilePath, NewDbFilePath),
+        NewDbFilePath
+    end, DbFileNames),
+    {Ctx, NewPaths}.
+
+
+teardown({Ctx, Paths}) ->
+    test_util:stop_couch(Ctx),
+    lists:foreach(fun(Path) ->
+        file:delete(Path)
+    end, Paths).
+
+
+upgrade_test_() ->
+    {
+        "Couch Bt Engine Upgrade tests",
+        {
+            setup,
+            fun setup/0,
+            fun teardown/1,
+            [
+                t_upgrade_without_purge_req(),
+                t_upgrade_with_1_purge_req(),
+                t_upgrade_with_N_purge_req(),
+                t_upgrade_with_1_purge_req_for_2_docs()
+            ]
+        }
+    }.
+
+
+t_upgrade_without_purge_req() ->
+    ?_test(begin
+        % There are three documents in the fixture
+        % db with zero purge entries
+        DbName = <<"db_without_purge_req">>,
+
+        {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual(0, couch_db:get_purge_seq(Db)),
+            couch_db:fold_purge_infos(Db, 0, fun fold_fun/2, [])
+        end),
+        ?assertEqual([], UpgradedPurged),
+
+        {ok, Rev} = save_doc(
+            DbName, {[{<<"_id">>, <<"doc4">>}, {<<"v">>,
1}]}
+        ),
+        {ok, _} = save_doc(DbName, {[{<<"_id">>, <<"doc5">>}, {<<"v">>,
2}]}),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 5}, couch_db:get_doc_count(Db)),
+            ?assertEqual(0, couch_db:get_purge_seq(Db))
+        end),
+
+        PurgeReqs = [
+            {couch_uuids:random(), <<"doc4">>, [Rev]}
+        ],
+
+        {ok, [{ok, PRevs}]} = couch_util:with_db(DbName, fun(Db) ->
+            couch_db:purge_docs(Db, PurgeReqs)
+        end),
+        ?assertEqual(PRevs, [Rev]),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
+            ?assertEqual(1, couch_db:get_purge_seq(Db))
+        end)
+    end).
+
+
+t_upgrade_with_1_purge_req() ->
+    ?_test(begin
+        % There are two documents in the fixture database
+        % with a single purge entry
+        DbName = <<"db_with_1_purge_req">>,
+
+        {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual(1, couch_db:get_purge_seq(Db)),
+            couch_db:fold_purge_infos(Db, 0, fun fold_fun/2, [])
+        end),
+        ?assertEqual([{1, <<"doc1">>}], UpgradedPurged),
+
+        {ok, Rev} = save_doc(
+            DbName, {[{<<"_id">>, <<"doc4">>}, {<<"v">>,
1}]}
+        ),
+        {ok, _} = save_doc(DbName, {[{<<"_id">>, <<"doc5">>}, {<<"v">>,
2}]}),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
+            ?assertEqual(1, couch_db:get_purge_seq(Db))
+        end),
+
+        PurgeReqs = [
+            {couch_uuids:random(), <<"doc4">>, [Rev]}
+        ],
+
+        {ok, [{ok, PRevs}]} = couch_util:with_db(DbName, fun(Db) ->
+            couch_db:purge_docs(Db, PurgeReqs)
+        end),
+        ?assertEqual(PRevs, [Rev]),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
+            ?assertEqual(2, couch_db:get_purge_seq(Db))
+        end)
+    end).
+
+
+t_upgrade_with_N_purge_req() ->
+    ?_test(begin
+        % There is one document in the fixture database
+        % with two docs that have been purged
+        DbName = <<"db_with_2_purge_req">>,
+
+        {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual(2, couch_db:get_purge_seq(Db)),
+            couch_db:fold_purge_infos(Db, 1, fun fold_fun/2, [])
+        end),
+        ?assertEqual([{2, <<"doc2">>}], UpgradedPurged),
+
+        {ok, Rev} = save_doc(DbName, {[{<<"_id">>, <<"doc4">>}, {<<"v">>,
1}]}),
+        {ok, _} = save_doc(DbName, {[{<<"_id">>, <<"doc5">>}, {<<"v">>,
2}]}),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
+            ?assertEqual(2, couch_db:get_purge_seq(Db))
+        end),
+
+        PurgeReqs = [
+            {couch_uuids:random(), <<"doc4">>, [Rev]}
+        ],
+
+        {ok, [{ok, PRevs}]} = couch_util:with_db(DbName, fun(Db) ->
+            couch_db:purge_docs(Db, PurgeReqs)
+        end),
+        ?assertEqual(PRevs, [Rev]),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 2}, couch_db:get_doc_count(Db)),
+            ?assertEqual(3, couch_db:get_purge_seq(Db))
+        end)
+    end).
+
+
+t_upgrade_with_1_purge_req_for_2_docs() ->
+    ?_test(begin
+        % There are two documents (Doc4 and Doc5) in the fixture database
+        % with three docs (Doc1, Doc2 and Doc3) that have been purged, and
+        % with one purge req for Doc1 and another purge req for Doc 2 and Doc3
+        DbName = <<"db_with_1_purge_req_for_2_docs">>,
+
+        {ok, UpgradedPurged} = couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual(3, couch_db:get_purge_seq(Db)),
+            couch_db:fold_purge_infos(Db, 1, fun fold_fun/2, [])
+        end),
+        ?assertEqual([{3,<<"doc2">>},{2,<<"doc3">>}], UpgradedPurged),
+
+        {ok, Rev} = save_doc(DbName, {[{<<"_id">>, <<"doc6">>}, {<<"v">>,
1}]}),
+        {ok, _} = save_doc(DbName, {[{<<"_id">>, <<"doc7">>}, {<<"v">>,
2}]}),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 4}, couch_db:get_doc_count(Db)),
+            ?assertEqual(3, couch_db:get_purge_seq(Db))
+        end),
+
+        PurgeReqs = [
+            {couch_uuids:random(), <<"doc6">>, [Rev]}
+        ],
+
+        {ok, [{ok, PRevs}]} = couch_util:with_db(DbName, fun(Db) ->
+            couch_db:purge_docs(Db, PurgeReqs)
+        end),
+        ?assertEqual(PRevs, [Rev]),
+
+        couch_util:with_db(DbName, fun(Db) ->
+            ?assertEqual({ok, 3}, couch_db:get_doc_count(Db)),
+            ?assertEqual(4, couch_db:get_purge_seq(Db))
+        end)
+    end).
+
+
+save_doc(DbName, Json) ->
+    Doc = couch_doc:from_json_obj(Json),
+    couch_util:with_db(DbName, fun(Db) ->
+        couch_db:update_doc(Db, Doc, [])
+    end).
+
+
+fold_fun({PSeq, _UUID, Id, _Revs}, Acc) ->
+    {ok, [{PSeq, Id} | Acc]}.
diff --git a/src/couch/test/fixtures/db_with_1_purge_req.couch b/src/couch/test/fixtures/db_with_1_purge_req.couch
new file mode 100644
index 0000000..b0d39c9
Binary files /dev/null and b/src/couch/test/fixtures/db_with_1_purge_req.couch differ
diff --git a/src/couch/test/fixtures/db_with_1_purge_req_for_2_docs.couch b/src/couch/test/fixtures/db_with_1_purge_req_for_2_docs.couch
new file mode 100644
index 0000000..b584fce
Binary files /dev/null and b/src/couch/test/fixtures/db_with_1_purge_req_for_2_docs.couch
differ
diff --git a/src/couch/test/fixtures/db_with_2_purge_req.couch b/src/couch/test/fixtures/db_with_2_purge_req.couch
new file mode 100644
index 0000000..ee4e11b
Binary files /dev/null and b/src/couch/test/fixtures/db_with_2_purge_req.couch differ
diff --git a/src/couch/test/fixtures/db_without_purge_req.couch b/src/couch/test/fixtures/db_without_purge_req.couch
new file mode 100644
index 0000000..814feb8
Binary files /dev/null and b/src/couch/test/fixtures/db_without_purge_req.couch differ
diff --git a/src/couch_pse_tests/src/cpse_test_purge_docs.erl b/src/couch_pse_tests/src/cpse_test_purge_docs.erl
index 3378825..34bd34d 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_docs.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_docs.erl
@@ -33,13 +33,13 @@ teardown_each(DbName) ->
 cpse_purge_simple(DbName) ->
     {ok, Rev} = cpse_util:save_doc(DbName, {[{'_id', foo1}, {vsn, 1.1}]}),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 1},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo1">>, [Rev]}
@@ -48,13 +48,13 @@ cpse_purge_simple(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([Rev], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 2},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_simple_info_check(DbName) ->
@@ -80,14 +80,14 @@ cpse_purge_empty_db(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 1},
         {changes, 0},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_single_docid(DbName) ->
@@ -96,14 +96,14 @@ cpse_purge_single_docid(DbName) ->
         {[{'_id', foo2}, {vsn, 2}]}
     ]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]}
@@ -111,14 +111,14 @@ cpse_purge_single_docid(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([Rev1], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 1},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_multiple_docids(DbName) ->
@@ -127,14 +127,14 @@ cpse_purge_multiple_docids(DbName) ->
         {[{'_id', foo2}, {vsn, 1.2}]}
     ]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]},
@@ -146,14 +146,14 @@ cpse_purge_multiple_docids(DbName) ->
     ?assertEqual([Rev1], PRevs1),
     ?assertEqual([Rev2], PRevs2),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 0},
         {purge_seq, 2},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_no_docids(DbName) ->
@@ -162,25 +162,25 @@ cpse_purge_no_docids(DbName) ->
         {[{'_id', foo2}, {vsn, 2}]}
     ]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     {ok, []} = cpse_util:purge(DbName, []),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_rev_path(DbName) ->
@@ -193,14 +193,14 @@ cpse_purge_rev_path(DbName) ->
     ]},
     {ok, Rev2} = cpse_util:save_doc(DbName, Update),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 1},
         {update_seq, 2},
         {changes, 1},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo">>, [Rev2]}
@@ -209,14 +209,14 @@ cpse_purge_rev_path(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([Rev2], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 0},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_deep_revision_path(DbName) ->
@@ -238,14 +238,14 @@ cpse_purge_deep_revision_path(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([LastRev], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, ?REV_DEPTH + 2},
         {changes, 0},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_partial_revs(DbName) ->
@@ -264,14 +264,14 @@ cpse_purge_partial_revs(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([Rev1], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 1},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_missing_docid(DbName) ->
@@ -280,14 +280,14 @@ cpse_purge_missing_docid(DbName) ->
         {[{'_id', foo2}, {vsn, 2}]}
     ]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"baz">>, [Rev1]}
@@ -295,14 +295,14 @@ cpse_purge_missing_docid(DbName) ->
 
     {ok, [{ok, []}]} = cpse_util:purge(DbName, PurgeInfos),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 2},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_duplicate_docids(DbName) ->
@@ -311,14 +311,14 @@ cpse_purge_duplicate_docids(DbName) ->
         {[{'_id', foo2}, {vsn, 2}]}
     ]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {purge_seq, 0},
         {changes, 2},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]},
@@ -328,14 +328,14 @@ cpse_purge_duplicate_docids(DbName) ->
     {ok, Resp} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([{ok, [Rev1]}, {ok, []}], Resp),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {purge_seq, 2},
         {changes, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_internal_revision(DbName) ->
@@ -354,14 +354,14 @@ cpse_purge_internal_revision(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 1},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_missing_revision(DbName) ->
@@ -377,14 +377,14 @@ cpse_purge_missing_revision(DbName) ->
     {ok, [{ok, PRevs}]} = cpse_util:purge(DbName, PurgeInfos),
     ?assertEqual([], PRevs),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 2},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_repeated_revisions(DbName) ->
@@ -396,14 +396,14 @@ cpse_purge_repeated_revisions(DbName) ->
     ]},
     {ok, [Rev2]} = cpse_util:save_docs(DbName, [Update], [replicated_changes]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 1},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos1 = [
         {cpse_util:uuid(), <<"foo">>, [Rev1]},
@@ -414,27 +414,27 @@ cpse_purge_repeated_revisions(DbName) ->
     ?assertEqual([Rev1], PRevs1),
     ?assertEqual([Rev2], PRevs2),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 3},
         {changes, 0},
         {purge_seq, 2},
         {purge_infos, PurgeInfos1}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_purge_repeated_uuid(DbName) ->
     {ok, Rev} = cpse_util:save_doc(DbName, {[{'_id', foo1}, {vsn, 1.1}]}),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 1},
         {changes, 1},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos = [
         {cpse_util:uuid(), <<"foo1">>, [Rev]}
@@ -449,14 +449,14 @@ cpse_purge_repeated_uuid(DbName) ->
     % Although we can replicate it in
     {ok, []} = cpse_util:purge(DbName, PurgeInfos, [replicated_changes]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 2},
         {changes, 0},
         {purge_seq, 1},
         {purge_infos, PurgeInfos}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 fold_all_infos(Info, Acc) ->
diff --git a/src/couch_pse_tests/src/cpse_test_purge_seqs.erl b/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
index b7b49b3..c061747 100644
--- a/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
+++ b/src/couch_pse_tests/src/cpse_test_purge_seqs.erl
@@ -29,13 +29,13 @@ cpse_increment_purge_seq_on_complete_purge(DbName) ->
     {ok, Rev1} = cpse_util:save_doc(DbName, {[{'_id', foo1}, {vsn, 1.1}]}),
     {ok, Rev2} = cpse_util:save_doc(DbName, {[{'_id', foo2}, {vsn, 1.2}]}),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos1 = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]}
@@ -43,13 +43,13 @@ cpse_increment_purge_seq_on_complete_purge(DbName) ->
     {ok, [{ok, PRevs1}]} = cpse_util:purge(DbName, PurgeInfos1),
     ?assertEqual([Rev1], PRevs1),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {purge_seq, 1},
         {purge_infos, PurgeInfos1}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos2 = [
         {cpse_util:uuid(), <<"foo2">>, [Rev2]}
@@ -57,26 +57,26 @@ cpse_increment_purge_seq_on_complete_purge(DbName) ->
     {ok, [{ok, PRevs2}]} = cpse_util:purge(DbName, PurgeInfos2),
     ?assertEqual([Rev2], PRevs2),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 4},
         {purge_seq, 2},
         {purge_infos, PurgeInfos1 ++ PurgeInfos2}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_increment_purge_multiple_times(DbName) ->
     {ok, Rev1} = cpse_util:save_doc(DbName, {[{'_id', foo1}, {vsn, 1.1}]}),
     {ok, Rev2} = cpse_util:save_doc(DbName, {[{'_id', foo2}, {vsn, 1.2}]}),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 2},
         {del_doc_count, 0},
         {update_seq, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos1 = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]},
@@ -86,13 +86,13 @@ cpse_increment_purge_multiple_times(DbName) ->
     ?assertEqual([Rev1], PRevs1),
     ?assertEqual([Rev2], PRevs2),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 0},
         {del_doc_count, 0},
         {update_seq, 3},
         {purge_seq, 2},
         {purge_infos, PurgeInfos1}
-    ], ?MODULE, ?LINE).
+    ]).
 
 
 cpse_increment_purge_seq_on_partial_purge(DbName) ->
@@ -101,13 +101,13 @@ cpse_increment_purge_seq_on_partial_purge(DbName) ->
     {ok, Rev1} = cpse_util:save_doc(DbName, Doc1),
     {ok, Rev2} = cpse_util:save_doc(DbName, Doc2, [replicated_changes]),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 2},
         {purge_seq, 0},
         {purge_infos, []}
-    ], ?MODULE, ?LINE),
+    ]),
 
     PurgeInfos1 = [
         {cpse_util:uuid(), <<"foo1">>, [Rev1]}
@@ -115,10 +115,10 @@ cpse_increment_purge_seq_on_partial_purge(DbName) ->
     {ok, [{ok, PRevs1}]} = cpse_util:purge(DbName, PurgeInfos1),
     ?assertEqual([Rev1], PRevs1),
 
-    cpse_util:assert_db_props(DbName, [
+    cpse_util:assert_db_props(?MODULE, ?LINE, DbName, [
         {doc_count, 1},
         {del_doc_count, 0},
         {update_seq, 3},
         {purge_seq, 1},
         {purge_infos, PurgeInfos1}
-    ], ?MODULE, ?LINE).
+    ]).
diff --git a/src/couch_pse_tests/src/cpse_util.erl b/src/couch_pse_tests/src/cpse_util.erl
index 955a974..9dae9a0 100644
--- a/src/couch_pse_tests/src/cpse_util.erl
+++ b/src/couch_pse_tests/src/cpse_util.erl
@@ -182,10 +182,10 @@ uuid() ->
     couch_uuids:random().
 
 
-assert_db_props(DbName, Props, Module, Line) when is_binary(DbName) ->
+assert_db_props(Module, Line, DbName, Props) when is_binary(DbName) ->
     {ok, Db} = couch_db:open_int(DbName, []),
     try
-        assert_db_props(Db, Props, Module, Line)
+        assert_db_props(Module, Line, Db, Props)
     catch error:{assertEqual, Props} ->
         {_, Rest} = proplists:split(Props, [module, line]),
         erlang:error({assertEqual, [{module, Module}, {line, Line} | Rest]})
@@ -193,7 +193,7 @@ assert_db_props(DbName, Props, Module, Line) when is_binary(DbName) ->
         couch_db:close(Db)
     end;
 
-assert_db_props(Db, Props, Module, Line) ->
+assert_db_props(Module, Line, Db, Props) ->
     try
         assert_each_prop(Db, Props)
     catch error:{assertEqual, Props} ->


Mime
View raw message