chore: add `$events.message_transformation_failed` to rule engine tester
Fixes https://emqx.atlassian.net/browse/EMQX-12679
This commit is contained in:
parent
5f595966d8
commit
2816170e9d
|
@ -326,6 +326,13 @@ fields("ctx_schema_validation_failed") ->
|
||||||
{"event_type", event_type_sc(Event)},
|
{"event_type", event_type_sc(Event)},
|
||||||
{"validation", sc(binary(), #{desc => ?DESC("event_validation")})}
|
{"validation", sc(binary(), #{desc => ?DESC("event_validation")})}
|
||||||
| msg_event_common_fields()
|
| msg_event_common_fields()
|
||||||
|
];
|
||||||
|
fields("ctx_message_transformation_failed") ->
|
||||||
|
Event = 'message.transformation_failed',
|
||||||
|
[
|
||||||
|
{"event_type", event_type_sc(Event)},
|
||||||
|
{"transformation", sc(binary(), #{desc => ?DESC("event_transformation")})}
|
||||||
|
| msg_event_common_fields()
|
||||||
].
|
].
|
||||||
|
|
||||||
rule_input_message_context() ->
|
rule_input_message_context() ->
|
||||||
|
@ -345,7 +352,8 @@ rule_input_message_context() ->
|
||||||
ref("ctx_check_authn_complete"),
|
ref("ctx_check_authn_complete"),
|
||||||
ref("ctx_bridge_mqtt"),
|
ref("ctx_bridge_mqtt"),
|
||||||
ref("ctx_delivery_dropped"),
|
ref("ctx_delivery_dropped"),
|
||||||
ref("ctx_schema_validation_failed")
|
ref("ctx_schema_validation_failed"),
|
||||||
|
ref("ctx_message_transformation_failed")
|
||||||
]),
|
]),
|
||||||
#{
|
#{
|
||||||
desc => ?DESC("test_context"),
|
desc => ?DESC("test_context"),
|
||||||
|
|
|
@ -206,6 +206,8 @@ is_test_runtime_env() ->
|
||||||
%% is different from `topic'.
|
%% is different from `topic'.
|
||||||
get_in_topic(#{event_type := schema_validation_failed}) ->
|
get_in_topic(#{event_type := schema_validation_failed}) ->
|
||||||
<<"$events/schema_validation_failed">>;
|
<<"$events/schema_validation_failed">>;
|
||||||
|
get_in_topic(#{event_type := message_transformation_failed}) ->
|
||||||
|
<<"$events/message_transformation_failed">>;
|
||||||
get_in_topic(Context) ->
|
get_in_topic(Context) ->
|
||||||
case maps:find(event_topic, Context) of
|
case maps:find(event_topic, Context) of
|
||||||
{ok, EventTopic} ->
|
{ok, EventTopic} ->
|
||||||
|
|
|
@ -257,6 +257,21 @@ t_ctx_schema_validation_failed(_) ->
|
||||||
Expected = check_result([validation], [], Context),
|
Expected = check_result([validation], [], Context),
|
||||||
do_test(SQL, Context, Expected).
|
do_test(SQL, Context, Expected).
|
||||||
|
|
||||||
|
t_ctx_message_transformation_failed(_) ->
|
||||||
|
SQL =
|
||||||
|
<<"SELECT transformation FROM \"$events/message_transformation_failed\"">>,
|
||||||
|
Context = #{
|
||||||
|
<<"clientid">> => <<"c_emqx">>,
|
||||||
|
<<"event_type">> => <<"message_transformation_failed">>,
|
||||||
|
<<"payload">> => <<"{\"msg\": \"hello\"}">>,
|
||||||
|
<<"qos">> => 1,
|
||||||
|
<<"topic">> => <<"t/a">>,
|
||||||
|
<<"username">> => <<"u_emqx">>,
|
||||||
|
<<"transformation">> => <<"m">>
|
||||||
|
},
|
||||||
|
Expected = check_result([transformation], [], Context),
|
||||||
|
do_test(SQL, Context, Expected).
|
||||||
|
|
||||||
t_mongo_date_function_should_return_string_in_test_env(_) ->
|
t_mongo_date_function_should_return_string_in_test_env(_) ->
|
||||||
SQL =
|
SQL =
|
||||||
<<"SELECT mongo_date() as mongo_date FROM \"$events/client_check_authz_complete\"">>,
|
<<"SELECT mongo_date() as mongo_date FROM \"$events/client_check_authz_complete\"">>,
|
||||||
|
|
|
@ -366,6 +366,12 @@ event_validation.desc:
|
||||||
event_validation.label:
|
event_validation.label:
|
||||||
"""Validation"""
|
"""Validation"""
|
||||||
|
|
||||||
|
event_transformation.desc:
|
||||||
|
"""Transformation"""
|
||||||
|
|
||||||
|
event_transformation.label:
|
||||||
|
"""Transformation"""
|
||||||
|
|
||||||
root_rule_info.desc:
|
root_rule_info.desc:
|
||||||
"""Schema for rule info"""
|
"""Schema for rule info"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue