From 927e0cd25f07993f91c1c978a5858b57f3fa017d Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 12 May 2020 10:36:41 +0100 Subject: [PATCH] Inermittent unit test failures When setting up the sink for a test it might receive a heartbeat before the transport has been setup - soingore the heartbeat in this case. This only seems to be tiggered on Travis CI. In riak_repl2_rtq tests intermittently the Seq2 might race with Seq1? Other such events ahve a sleep in-between of 1200, so added here. --- src/riak_core_cluster_conn.erl | 2 +- src/riak_repl2_rtsink_conn.erl | 3 +++ test/riak_repl2_rtq_tests.erl | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/riak_core_cluster_conn.erl b/src/riak_core_cluster_conn.erl index 641dcb68..7280fb03 100644 --- a/src/riak_core_cluster_conn.erl +++ b/src/riak_core_cluster_conn.erl @@ -346,7 +346,7 @@ handle_sync_event(current_state, _From, StateName, State) -> Reply = {StateName, State}, {reply, Reply, StateName, State}; handle_sync_event(force_stop, _From, _StateName, State) -> - ok = lager:debug("Stopping because I was asked nicely to."), + % ok = lager:debug("Stopping because I was asked nicely to."), {stop, normal, ok, State}; handle_sync_event(_Event, _From, StateName, State) -> Reply = ok, diff --git a/src/riak_repl2_rtsink_conn.erl b/src/riak_repl2_rtsink_conn.erl index 34a05559..3fa549ac 100644 --- a/src/riak_repl2_rtsink_conn.erl +++ b/src/riak_repl2_rtsink_conn.erl @@ -251,6 +251,9 @@ terminate(_Reason, State) -> code_change(_OldVsn, State, _Extra) -> {ok, State}. +send_heartbeat(undefined, _Socket) -> + lager:warning("Heartbeat received but transport undefined"), + ok; send_heartbeat(Transport, Socket) -> Transport:send(Socket, riak_repl2_rtframe:encode(heartbeat, undefined)). diff --git a/test/riak_repl2_rtq_tests.erl b/test/riak_repl2_rtq_tests.erl index ccf00fcc..e3d77be5 100644 --- a/test/riak_repl2_rtq_tests.erl +++ b/test/riak_repl2_rtq_tests.erl @@ -239,6 +239,7 @@ overload_test_() -> % msg queue = 0, totol objects dropped = 5 riak_repl2_rtq:push(1, term_to_binary([<<"object">>])), Seq1 = pull(5), + timer:sleep(1200), Seq2 = pull(1), ?assertEqual(Seq1 + 1 + 5, Seq2), Status = riak_repl2_rtq:status(),