iilyak commented on a change in pull request #1368: [3/5] Clustered Purge - 
Rewrite pluggable storage engine tests
URL: https://github.com/apache/couchdb/pull/1368#discussion_r196951923
 
 

 ##########
 File path: src/couch_pse_tests/src/cpse_test_ref_counting.erl
 ##########
 @@ -21,49 +21,59 @@
 -define(NUM_CLIENTS, 1000).
 
 
-cet_empty_monitors() ->
-    {ok, Engine, St} = test_engine_util:init_engine(),
-    Pids = Engine:monitored_by(St),
-    ?assert(is_list(Pids)),
-    ?assertEqual([], Pids -- [self(), whereis(couch_stats_process_tracker)]).
+setup_each() ->
+    {ok, Db} = cpse_util:create_db(),
+    {Db, self()}.
+
 
+teardown_each({Db, _}) ->
+    ok = couch_server:delete(couch_db:name(Db), []).
 
-cet_incref_decref() ->
-    {ok, Engine, St} = test_engine_util:init_engine(),
 
-    {Pid, _} = Client = start_client(Engine, St),
+cpse_empty_monitors({Db, Pid}) ->
+    Pids = couch_db_engine:monitored_by(Db),
+    ?assert(is_list(Pids)),
+    Expected = [
+        Pid,
+        couch_db:get_pid(Db),
+        whereis(couch_stats_process_tracker)
+    ],
+    ?assertEqual([], Pids -- Expected).
+
+
+cpse_incref_decref({Db, _}) ->
+    {Pid, _} = Client = start_client(Db),
     wait_client(Client),
 
-    Pids1 = Engine:monitored_by(St),
+    Pids1 = couch_db_engine:monitored_by(Db),
     ?assert(lists:member(Pid, Pids1)),
 
     close_client(Client),
 
-    Pids2 = Engine:monitored_by(St),
+    Pids2 = couch_db_engine:monitored_by(Db),
     ?assert(not lists:member(Pid, Pids2)).
 
 
-cet_incref_decref_many() ->
-    {ok, Engine, St} = test_engine_util:init_engine(),
+cpse_incref_decref_many({Db, _}) ->
     Clients = lists:map(fun(_) ->
-        start_client(Engine, St)
+        start_client(Db)
     end, lists:seq(1, ?NUM_CLIENTS)),
 
     lists:foreach(fun(C) -> wait_client(C) end, Clients),
 
-    Pids1 = Engine:monitored_by(St),
-    % +2 for db pid and process tracker
-    ?assertEqual(?NUM_CLIENTS + 2, length(Pids1)),
+    Pids1 = couch_db_engine:monitored_by(Db),
+    % +3 for self, db pid, and process tracker
+    ?assertEqual(?NUM_CLIENTS + 3, length(Pids1)),
 
 Review comment:
   We could use `couch_db:monitored_by/1`, which would remove db and process 
tracker. However we probably want to limit functions we use to 
`couch_db_engine` module. I am really not sure which approach is better. Just 
wanted to mention it so I don't forget why I stopped here.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to