Fix race condition in waiting for compactor in eunit test.
Monitor waiting for replicator will sometimes fail with noproc
error, because there is a race condition between a running
compactor process and setting up its monitor and waiting on it.
This error appears about once or twice in a 100 runs.
It can be made to appear more often by tweaking 50 and 5 values in:
```
should_populate_and_compact(RepPid, Source, Target, 50, 5),
```
to something like 1, 20.
This commit fixes race condition by handling noproc.
diff --git a/test/couch_replicator_compact_tests.erl b/test/couch_replicator_compact_tests.erl
index 459e42a..bd5380f 100644
--- a/test/couch_replicator_compact_tests.erl
+++ b/test/couch_replicator_compact_tests.erl
@@ -263,6 +263,8 @@
receive
{'DOWN', MonRef, process, CompactPid, normal} ->
ok;
+ {'DOWN', MonRef, process, CompactPid, noproc} ->
+ ok;
{'DOWN', MonRef, process, CompactPid, Reason} ->
erlang:error(
{assertion_failed,
@@ -284,11 +286,13 @@
case couch_db:wait_for_compaction(Db) of
ok ->
ok;
+ {error, noproc} ->
+ ok;
{error, Reason} ->
erlang:error(
{assertion_failed,
[{module, ?MODULE}, {line, ?LINE},
- {reason, lists:concat(["Compaction of", Type,
+ {reason, lists:concat(["Compaction of ", Type,
" database failed with: ", Reason])}]})
end.