diff options
author | Eric Avdey <eiri@eiri.ca> | 2017-06-16 16:20:02 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 16:20:02 -0300 |
commit | f1a1d7f1c855d1196317c837e775d4b05d3ba9d0 (patch) | |
tree | 3129cbbf9c1aaa1cdb20417c4a6c4355571685db | |
parent | a00d6834ea0f614cc59276b4421bf306feeb4573 (diff) | |
parent | 3f37ec15ea8cefb895418b13e481a4bd6d27ae6a (diff) | |
download | couchdb-f1a1d7f1c855d1196317c837e775d4b05d3ba9d0.tar.gz |
Merge pull request #590 from cloudant/fix-couch_log_config_listener_test
Wait for listener's exit during restart test
-rw-r--r-- | src/couch_log/test/couch_log_config_listener_test.erl | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/couch_log/test/couch_log_config_listener_test.erl b/src/couch_log/test/couch_log_config_listener_test.erl index e3680b881..07abae1ff 100644 --- a/src/couch_log/test/couch_log_config_listener_test.erl +++ b/src/couch_log/test/couch_log_config_listener_test.erl @@ -16,6 +16,7 @@ -include_lib("couch_log/include/couch_log.hrl"). -include_lib("eunit/include/eunit.hrl"). +-define(TIMEOUT, 1000). couch_log_config_test_() -> {setup, @@ -34,13 +35,27 @@ check_restart_listener() -> Handler1 = get_handler(), ?assertNotEqual(not_found, Handler1), + Ref = erlang:monitor(process, Listener1), ok = gen_event:delete_handler(config_event, get_handler(), testing), - ?assertEqual(not_found, get_handler()), - timer:sleep(100), - ?assertNot(is_process_alive(Listener1)), + receive + {'DOWN', Ref, process, _, _} -> + ?assertNot(is_process_alive(Listener1)) + after ?TIMEOUT -> + erlang:error({timeout, config_listener_mon_death}) + end, + + NewHandler = test_util:wait(fun() -> + case get_handler() of + not_found -> wait; + Reply -> Reply + end + end, ?TIMEOUT, 20), + ?assertEqual(Handler1, NewHandler), - ?assert(is_process_alive(get_listener())), + Listener2 = get_listener(), + ?assert(is_process_alive(Listener2)), + ?assertNotEqual(Listener1, Listener2), ok. check_ignore_non_log() -> |