|
|
@@ -41,6 +41,7 @@ all() ->
|
|
|
, {group, test_grp_5_write_attr}
|
|
|
, {group, test_grp_6_observe}
|
|
|
, {group, test_grp_8_object_19}
|
|
|
+ , {group, test_grp_bugs}
|
|
|
].
|
|
|
|
|
|
suite() -> [{timetrap, {seconds, 90}}].
|
|
|
@@ -106,6 +107,9 @@ groups() ->
|
|
|
{test_grp_9_psm_queue_mode, [RepeatOpt], [
|
|
|
case90_psm_mode,
|
|
|
case90_queue_mode
|
|
|
+ ]},
|
|
|
+ {test_grp_bugs, [RepeatOpt], [
|
|
|
+ case_bug_emqx_4989
|
|
|
]}
|
|
|
].
|
|
|
|
|
|
@@ -145,6 +149,56 @@ end_per_testcase(_AllTestCase, Config) ->
|
|
|
%% Cases
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
+case_bug_emqx_4989(Config) ->
|
|
|
+ %% https://github.com/emqx/emqx/issues/4989
|
|
|
+ % step 1, device register ...
|
|
|
+ Epn = "urn:oma:lwm2m:oma:3",
|
|
|
+ MsgId1 = 15,
|
|
|
+ UdpSock = ?config(sock, Config),
|
|
|
+ ObjectList = <<"</1>, </2>, </3/0>, </4>, </5>">>,
|
|
|
+ RespTopic = list_to_binary("lwm2m/"++Epn++"/up/resp"),
|
|
|
+ emqtt:subscribe(?config(emqx_c, Config), RespTopic, qos0),
|
|
|
+ timer:sleep(200),
|
|
|
+
|
|
|
+ std_register(UdpSock, Epn, ObjectList, MsgId1, RespTopic),
|
|
|
+
|
|
|
+ % step2, send a WRITE command to device
|
|
|
+ CommandTopic = <<"lwm2m/", (list_to_binary(Epn))/binary, "/dn/dm">>,
|
|
|
+ CmdId = 307,
|
|
|
+ Command = #{<<"requestID">> => CmdId, <<"cacheID">> => CmdId,
|
|
|
+ <<"msgType">> => <<"write">>,
|
|
|
+ <<"data">> => #{
|
|
|
+ <<"path">> => <<"/1/0/2">>,
|
|
|
+ <<"type">> => <<"Integer">>,
|
|
|
+ <<"value">> => 129
|
|
|
+ }
|
|
|
+ },
|
|
|
+ CommandJson = emqx_json:encode(Command),
|
|
|
+ test_mqtt_broker:publish(CommandTopic, CommandJson, 0),
|
|
|
+ timer:sleep(50),
|
|
|
+ Request2 = test_recv_coap_request(UdpSock),
|
|
|
+ #coap_message{method = Method2, options=Options2, payload=Payload2} = Request2,
|
|
|
+ Path2 = get_coap_path(Options2),
|
|
|
+ ?assertEqual(put, Method2),
|
|
|
+ ?assertEqual(<<"/1/0/2">>, Path2),
|
|
|
+ ?assertMatch([#{value := 129}], emqx_lwm2m_message:tlv_to_json(Path2, Payload2)),
|
|
|
+
|
|
|
+ timer:sleep(50),
|
|
|
+
|
|
|
+ test_send_coap_response(UdpSock, "127.0.0.1", ?PORT, {ok, changed}, #coap_content{}, Request2, true),
|
|
|
+ timer:sleep(100),
|
|
|
+
|
|
|
+ ReadResult = emqx_json:encode(#{
|
|
|
+ <<"requestID">> => CmdId, <<"cacheID">> => CmdId,
|
|
|
+ <<"data">> => #{
|
|
|
+ <<"reqPath">> => <<"/1/0/2">>,
|
|
|
+ <<"code">> => <<"2.04">>,
|
|
|
+ <<"codeMsg">> => <<"changed">>
|
|
|
+ },
|
|
|
+ <<"msgType">> => <<"write">>
|
|
|
+ }),
|
|
|
+ ?assertEqual(ReadResult, test_recv_mqtt_response(RespTopic)).
|
|
|
+
|
|
|
case01_register(Config) ->
|
|
|
% ----------------------------------------
|
|
|
% REGISTER command
|