Merge pull request #13527 from thalesmg/20240726-r57-multiple-froms-sql-test
fix(rule engine tester): fix message publish with bridge source in from clause
This commit is contained in:
commit
8913de10c0
|
@ -115,11 +115,13 @@ test(#{sql := Sql, context := Context}) ->
|
|||
true ->
|
||||
%% test if the topic matches the topic filters in the rule
|
||||
case emqx_topic:match_any(InTopic, EventTopics) of
|
||||
true -> test_rule(Sql, Select, Context, EventTopics);
|
||||
false -> {error, nomatch}
|
||||
true ->
|
||||
test_rule(Sql, Select, Context, EventTopics);
|
||||
false ->
|
||||
{error, nomatch}
|
||||
end;
|
||||
false ->
|
||||
case lists:member(InTopic, EventTopics) of
|
||||
case emqx_topic:match_any(InTopic, EventTopics) of
|
||||
true ->
|
||||
%% the rule is for both publish and events, test it directly
|
||||
test_rule(Sql, Select, Context, EventTopics);
|
||||
|
|
|
@ -332,6 +332,38 @@ t_rule_test_smoke(_Config) ->
|
|||
}
|
||||
],
|
||||
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},
|
||||
input =>
|
||||
|
@ -395,6 +427,7 @@ do_t_rule_test_smoke(#{input := Input, expected := #{code := ExpectedCode}} = Ca
|
|||
{true, #{
|
||||
expected => ExpectedCode,
|
||||
hint => maps:get(hint, Case, <<>>),
|
||||
input => Input,
|
||||
got => Code,
|
||||
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