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 2022/12/06 19:52:02 UTC

[couchdb] branch main updated: Fix flaky checkpointing smoosh test

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

vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new 33a5be503 Fix flaky checkpointing smoosh test
33a5be503 is described below

commit 33a5be50339eb40dd3950a425c6fbfc7839ce6f9
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Tue Dec 6 14:12:33 2022 -0500

    Fix flaky checkpointing smoosh test
    
    This may not be a 100% fix just doing extra asserts that file operations have
    succeeded and making to wait for the compactor to exit and match the exit
    reason exactly, to make sure we killed and it does as expected.
---
 src/smoosh/test/smoosh_tests.erl | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/smoosh/test/smoosh_tests.erl b/src/smoosh/test/smoosh_tests.erl
index 9c0bcb075..cf8c9dc2e 100644
--- a/src/smoosh/test/smoosh_tests.erl
+++ b/src/smoosh/test/smoosh_tests.erl
@@ -37,6 +37,7 @@ smoosh_test_() ->
 setup_all() ->
     meck:new(smoosh_server, [passthrough]),
     meck:new(smoosh_channel, [passthrough]),
+    meck:new(file, [unstick, passthrough]),
     meck:new(fabric, [passthrough]),
     meck:new(couch_emsort, [passthrough]),
     Ctx = test_util:start_couch([fabric]),
@@ -239,23 +240,24 @@ t_checkpointing_works(DbName) ->
     setup_db_compactor_intercept(),
     {ok, _} = delete_doc(DbName, <<"doc1">>),
     ok = wait_to_enqueue(DbName),
-    ?debugHere,
     CompPid = wait_db_compactor_pid(),
-    ?debugHere,
     ChanPid = get_channel_pid("ratio_dbs"),
     config:set("smoosh", "persist", "true", false),
     meck:reset(smoosh_channel),
+    meck:reset(file),
     ChanPid ! checkpoint,
     % Wait for checkpoint process to exit
-    ?debugHere,
     ok = wait_normal_down(),
-    ?debugHere,
+    meck:wait(1, file, write_file, 3, 2000),
+    meck:wait(1, file, rename, 2, 2000),
     % Stop smoosh and then crash the compaction
     ok = application:stop(smoosh),
-    CompPid ! {raise, error, kapow},
-    % Smoosh should resume job and continue compacting
-    setup_db_compactor_intercept(),
-    meck:reset(smoosh_channel),
+    Ref = erlang:monitor(process, CompPid),
+    CompPid ! {raise, exit, kapow},
+    receive
+        {'DOWN', Ref, _, _, kapow} ->
+            ok
+    end,
     ok = application:start(smoosh),
     ?debugHere,
     CompPid2 = wait_db_compactor_pid(),