fix(rule engine tester): fix message publish with bridge source in from clause
Fixes https://emqx.atlassian.net/browse/EMQX-12762
This commit is contained in:
parent
9a5d50f26a
commit
3fae704903
|
@ -115,11 +115,13 @@ test(#{sql := Sql, context := Context}) ->
|
||||||
true ->
|
true ->
|
||||||
%% test if the topic matches the topic filters in the rule
|
%% test if the topic matches the topic filters in the rule
|
||||||
case emqx_topic:match_any(InTopic, EventTopics) of
|
case emqx_topic:match_any(InTopic, EventTopics) of
|
||||||
true -> test_rule(Sql, Select, Context, EventTopics);
|
true ->
|
||||||
false -> {error, nomatch}
|
test_rule(Sql, Select, Context, EventTopics);
|
||||||
|
false ->
|
||||||
|
{error, nomatch}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
case lists:member(InTopic, EventTopics) of
|
case emqx_topic:match_any(InTopic, EventTopics) of
|
||||||
true ->
|
true ->
|
||||||
%% the rule is for both publish and events, test it directly
|
%% the rule is for both publish and events, test it directly
|
||||||
test_rule(Sql, Select, Context, EventTopics);
|
test_rule(Sql, Select, Context, EventTopics);
|
||||||
|
|
|
@ -332,6 +332,38 @@ t_rule_test_smoke(_Config) ->
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
MultipleFrom = [
|
MultipleFrom = [
|
||||||
|
#{
|
||||||
|
expected => #{code => 200},
|
||||||
|
input =>
|
||||||
|
#{
|
||||||
|
<<"context">> =>
|
||||||
|
#{
|
||||||
|
<<"clientid">> => <<"c_emqx">>,
|
||||||
|
<<"event_type">> => <<"message_publish">>,
|
||||||
|
<<"qos">> => 1,
|
||||||
|
<<"topic">> => <<"t/a">>,
|
||||||
|
<<"username">> => <<"u_emqx">>
|
||||||
|
},
|
||||||
|
<<"sql">> =>
|
||||||
|
<<"SELECT\n *\nFROM\n \"t/#\", \"$bridges/mqtt:source\" ">>
|
||||||
|
}
|
||||||
|
},
|
||||||
|
#{
|
||||||
|
expected => #{code => 200},
|
||||||
|
input =>
|
||||||
|
#{
|
||||||
|
<<"context">> =>
|
||||||
|
#{
|
||||||
|
<<"clientid">> => <<"c_emqx">>,
|
||||||
|
<<"event_type">> => <<"message_publish">>,
|
||||||
|
<<"qos">> => 1,
|
||||||
|
<<"topic">> => <<"t/a">>,
|
||||||
|
<<"username">> => <<"u_emqx">>
|
||||||
|
},
|
||||||
|
<<"sql">> =>
|
||||||
|
<<"SELECT\n *\nFROM\n \"t/#\", \"$sources/mqtt:source\" ">>
|
||||||
|
}
|
||||||
|
},
|
||||||
#{
|
#{
|
||||||
expected => #{code => 200},
|
expected => #{code => 200},
|
||||||
input =>
|
input =>
|
||||||
|
@ -395,6 +427,7 @@ do_t_rule_test_smoke(#{input := Input, expected := #{code := ExpectedCode}} = Ca
|
||||||
{true, #{
|
{true, #{
|
||||||
expected => ExpectedCode,
|
expected => ExpectedCode,
|
||||||
hint => maps:get(hint, Case, <<>>),
|
hint => maps:get(hint, Case, <<>>),
|
||||||
|
input => Input,
|
||||||
got => Code,
|
got => Code,
|
||||||
resp_body => Body
|
resp_body => Body
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed an issue where running a SQL test in Rule Engine for the Message Publish event when a `$bridges/...` source was included in the `FROM` clause would always yield no results.
|
Loading…
Reference in New Issue