Skip to content

Commit f2e1b6a

Browse files
ansddumbbell
authored andcommitted
Fix flake in test case session_upgrade_v3_v5_qos1
CI sometimes failed with the following error: ``` v5_SUITE:session_upgrade_v3_v5_qos failed on line 1068 Reason: {test_case_failed,Received unexpected PUBLISH payload. Expected: <<"2">> Got: <<"3">>} ``` The emqtt client auto acks by default. Therefore, if Subv3 client was able to successfully auto ack message 2 before Subv3 disconnected, Subv5 client did not receive message 2. This commit fixes this flake by making sure that Subv3 does not ack message 2.
1 parent bdfd476 commit f2e1b6a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

deps/rabbitmq_mqtt/test/v5_SUITE.erl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,17 +1037,27 @@ session_upgrade_v3_v5_qos0(Config) ->
10371037
session_upgrade_v3_v5_qos(Qos, Config) ->
10381038
ClientId = Topic = atom_to_binary(?FUNCTION_NAME),
10391039
Pub = connect(<<"publisher">>, Config),
1040-
Subv3 = connect(ClientId, Config, [{proto_ver, v3} | non_clean_sess_opts()]),
1040+
Subv3 = connect(ClientId, Config,
1041+
[{proto_ver, v3},
1042+
{auto_ack, false}] ++
1043+
non_clean_sess_opts()),
10411044
?assertEqual(3, proplists:get_value(proto_ver, emqtt:info(Subv3))),
10421045
{ok, _, [Qos]} = emqtt:subscribe(Subv3, Topic, Qos),
10431046
Sender = spawn_link(?MODULE, send, [self(), Pub, Topic, 0]),
10441047
receive {publish, #{payload := <<"1">>,
1045-
client_pid := Subv3}} -> ok
1048+
client_pid := Subv3,
1049+
packet_id := PacketId}} ->
1050+
case Qos of
1051+
0 -> ok;
1052+
1 -> emqtt:puback(Subv3, PacketId)
1053+
end
10461054
after ?TIMEOUT -> ct:fail("did not receive 1")
10471055
end,
10481056
%% Upgrade session from v3 to v5 while another client is sending messages.
10491057
ok = emqtt:disconnect(Subv3),
1050-
Subv5 = connect(ClientId, Config, [{proto_ver, v5}, {clean_start, false}]),
1058+
Subv5 = connect(ClientId, Config, [{proto_ver, v5},
1059+
{clean_start, false},
1060+
{auto_ack, true}]),
10511061
?assertEqual(5, proplists:get_value(proto_ver, emqtt:info(Subv5))),
10521062
Sender ! stop,
10531063
NumSent = receive {N, Sender} -> N

0 commit comments

Comments
 (0)