diff options
author | Nick Vatamaniuc <vatamane@gmail.com> | 2022-12-06 14:12:33 -0500 |
---|---|---|
committer | Nick Vatamaniuc <nickva@users.noreply.github.com> | 2022-12-06 14:51:54 -0500 |
commit | 33a5be50339eb40dd3950a425c6fbfc7839ce6f9 (patch) | |
tree | f8bdaf2b87d17179c16e31c1faa056a472032838 | |
parent | 28c3ccc08d8ad97f09738cbec0ce45d30d556d9c (diff) | |
download | couchdb-33a5be50339eb40dd3950a425c6fbfc7839ce6f9.tar.gz |
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.
-rw-r--r-- | src/smoosh/test/smoosh_tests.erl | 18 |
1 files 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(), |