fix(mysql_bridge): allow deleting bridge when sql contains undefined fields

Fixes https://emqx.atlassian.net/browse/EMQX-11655
This commit is contained in:
Thales Macedo Garitezi 2024-01-09 14:46:01 -03:00
parent d0588b86b5
commit abd4873091
4 changed files with 40 additions and 1 deletions

View File

@ -184,6 +184,15 @@ update_bridge_api(Config, Overrides) ->
ct:pal("bridge update result: ~p", [Res]), ct:pal("bridge update result: ~p", [Res]),
Res. Res.
delete_bridge_http_api_v1(Opts) ->
#{type := Type, name := Name} = Opts,
BridgeId = emqx_bridge_resource:bridge_id(Type, Name),
Path = emqx_mgmt_api_test_util:api_path(["bridges", BridgeId]),
ct:pal("deleting bridge (http v1)"),
Res = emqx_bridge_v2_testlib:request(delete, Path, _Params = []),
ct:pal("bridge delete (http v1) result:\n ~p", [Res]),
Res.
op_bridge_api(Op, BridgeType, BridgeName) -> op_bridge_api(Op, BridgeType, BridgeName) ->
BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName), BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName),
Path = emqx_mgmt_api_test_util:api_path(["bridges", BridgeId, Op]), Path = emqx_mgmt_api_test_util:api_path(["bridges", BridgeId, Op]),

View File

@ -51,6 +51,7 @@ groups() ->
t_write_timeout, t_write_timeout,
t_uninitialized_prepared_statement, t_uninitialized_prepared_statement,
t_non_batch_update_is_allowed, t_non_batch_update_is_allowed,
t_delete_with_undefined_field_in_sql,
t_undefined_field_in_sql t_undefined_field_in_sql
], ],
OnlyBatchCases = [ OnlyBatchCases = [
@ -989,3 +990,30 @@ t_undefined_field_in_sql(Config) ->
[] []
), ),
ok. ok.
t_delete_with_undefined_field_in_sql(Config) ->
?check_trace(
begin
Name = ?config(bridge_name, Config),
Type = ?config(bridge_type, Config),
Overrides = #{
<<"sql">> =>
<<
"INSERT INTO mqtt_test(wrong_column, arrived) "
"VALUES (${payload}, FROM_UNIXTIME(${timestamp}/1000))"
>>
},
?assertMatch(
{ok, {{_, 201, _}, _, #{<<"status">> := Status}}} when
Status =:= <<"connecting">> orelse Status =:= <<"disconnected">>,
emqx_bridge_testlib:create_bridge_api(Config, Overrides)
),
?assertMatch(
{ok, {{_, 204, _}, _, _}},
emqx_bridge_testlib:delete_bridge_http_api_v1(#{type => Type, name => Name})
),
ok
end,
[]
),
ok.

View File

@ -1 +0,0 @@
Improved HTTP API error message when the creation of a MySQL bridge fails.

View File

@ -0,0 +1,3 @@
Improved HTTP API error message when the creation of a MySQL bridge fails.
Fixed an issue that prevented removing a MySQL bridge when its SQL contained undefined columns.