diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2020-04-08 18:36:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-08 18:36:05 +0300 |
| commit | 485ee7185204e4bb9278c453e0b56e588e0b8848 (patch) | |
| tree | 6fbe5a38a82db0da930bb60fd011b65f74740c40 | |
| parent | 2092730359a59742fd6b76ff086665e507bdeed6 (diff) | |
| parent | cf30cb864a4d47d3d81209b6b29d2deda65c9cac (diff) | |
| download | rabbitmq-server-git-485ee7185204e4bb9278c453e0b56e588e0b8848.tar.gz | |
Merge pull request #2306 from rabbitmq/test-unit-connection-tracking
Fix flaky test - connection tracking is asynchronous
| -rw-r--r-- | test/unit_connection_tracking_SUITE.erl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/unit_connection_tracking_SUITE.erl b/test/unit_connection_tracking_SUITE.erl index de30e4fdf2..16c27ce3a3 100644 --- a/test/unit_connection_tracking_SUITE.erl +++ b/test/unit_connection_tracking_SUITE.erl @@ -93,10 +93,18 @@ queue_count(Config) -> rabbit_ct_client_helpers:close_connection(Conn), ok. +%% connection_count/1 has been failing on Travis. This seems a legit failure, as the registering +%% of connections in the tracker is async. `rabbit_connection_tracking_handler` receives a rabbit +%% event with `connection_created`, which then forwards as a cast to `rabbit_connection_tracker` +%% for register. We should wait a reasonable amount of time for the counter to increase before +%% failing. connection_count(Config) -> Conn = rabbit_ct_client_helpers:open_connection(Config, 0), - ?assertEqual(1, rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_connection_tracking, count, [])), + rabbit_ct_helpers:await_condition( + fun() -> + rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_connection_tracking, count, []) == 1 + end, 30000), rabbit_ct_client_helpers:close_connection(Conn), ok. @@ -104,6 +112,13 @@ connection_count(Config) -> connection_lookup(Config) -> Conn = rabbit_ct_client_helpers:open_connection(Config, 0), + %% Let's wait until the connection is registered, otherwise this test could fail in a slow + %% machine as connection tracking is asynchronous + rabbit_ct_helpers:await_condition( + fun() -> + rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_connection_tracking, count, []) == 1 + end, 30000), + [Connection] = rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_connection_tracking, list, []), ?assertMatch(Connection, rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_connection_tracking, lookup, |
