Skip to content

Commit a192971

Browse files
ansdmichaelklishin
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 743b3c3 commit a192971

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
@@ -1020,17 +1020,27 @@ session_upgrade_v3_v5_qos0(Config) ->
10201020
session_upgrade_v3_v5_qos(Qos, Config) ->
10211021
ClientId = Topic = atom_to_binary(?FUNCTION_NAME),
10221022
Pub = connect(<<"publisher">>, Config),
1023-
Subv3 = connect(ClientId, Config, [{proto_ver, v3} | non_clean_sess_opts()]),
1023+
Subv3 = connect(ClientId, Config,
1024+
[{proto_ver, v3},
1025+
{auto_ack, false}] ++
1026+
non_clean_sess_opts()),
10241027
?assertEqual(3, proplists:get_value(proto_ver, emqtt:info(Subv3))),
10251028
{ok, _, [Qos]} = emqtt:subscribe(Subv3, Topic, Qos),
10261029
Sender = spawn_link(?MODULE, send, [self(), Pub, Topic, 0]),
10271030
receive {publish, #{payload := <<"1">>,
1028-
client_pid := Subv3}} -> ok
1031+
client_pid := Subv3,
1032+
packet_id := PacketId}} ->
1033+
case Qos of
1034+
0 -> ok;
1035+
1 -> emqtt:puback(Subv3, PacketId)
1036+
end
10291037
after ?TIMEOUT -> ct:fail("did not receive 1")
10301038
end,
10311039
%% Upgrade session from v3 to v5 while another client is sending messages.
10321040
ok = emqtt:disconnect(Subv3),
1033-
Subv5 = connect(ClientId, Config, [{proto_ver, v5}, {clean_start, false}]),
1041+
Subv5 = connect(ClientId, Config, [{proto_ver, v5},
1042+
{clean_start, false},
1043+
{auto_ack, true}]),
10341044
?assertEqual(5, proplists:get_value(proto_ver, emqtt:info(Subv5))),
10351045
Sender ! stop,
10361046
NumSent = receive {N, Sender} -> N

0 commit comments

Comments
 (0)