test(mysql): slightly simplify bridge testsuite
This commit is contained in:
parent
36e57a479d
commit
f827df2821
|
@ -21,7 +21,6 @@
|
||||||
"DEFAULT CHARSET=utf8MB4;"
|
"DEFAULT CHARSET=utf8MB4;"
|
||||||
).
|
).
|
||||||
-define(SQL_DROP_TABLE, "DROP TABLE mqtt_test").
|
-define(SQL_DROP_TABLE, "DROP TABLE mqtt_test").
|
||||||
-define(SQL_DELETE, "DELETE from mqtt_test").
|
|
||||||
-define(SQL_SELECT, "SELECT payload FROM mqtt_test").
|
-define(SQL_SELECT, "SELECT payload FROM mqtt_test").
|
||||||
|
|
||||||
% DB defaults
|
% DB defaults
|
||||||
|
@ -112,8 +111,8 @@ end_per_suite(_Config) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
init_per_testcase(_Testcase, Config) ->
|
init_per_testcase(_Testcase, Config) ->
|
||||||
|
connect_and_drop_table(Config),
|
||||||
connect_and_create_table(Config),
|
connect_and_create_table(Config),
|
||||||
connect_and_clear_table(Config),
|
|
||||||
delete_bridge(Config),
|
delete_bridge(Config),
|
||||||
snabbkaffe:start_trace(),
|
snabbkaffe:start_trace(),
|
||||||
Config.
|
Config.
|
||||||
|
@ -122,9 +121,7 @@ end_per_testcase(_Testcase, Config) ->
|
||||||
ProxyHost = ?config(proxy_host, Config),
|
ProxyHost = ?config(proxy_host, Config),
|
||||||
ProxyPort = ?config(proxy_port, Config),
|
ProxyPort = ?config(proxy_port, Config),
|
||||||
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
||||||
connect_and_clear_table(Config),
|
|
||||||
ok = snabbkaffe:stop(),
|
ok = snabbkaffe:stop(),
|
||||||
delete_bridge(Config),
|
|
||||||
emqx_common_test_helpers:call_janitor(),
|
emqx_common_test_helpers:call_janitor(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -323,9 +320,6 @@ connect_and_create_table(Config) ->
|
||||||
connect_and_drop_table(Config) ->
|
connect_and_drop_table(Config) ->
|
||||||
query_direct_mysql(Config, ?SQL_DROP_TABLE).
|
query_direct_mysql(Config, ?SQL_DROP_TABLE).
|
||||||
|
|
||||||
connect_and_clear_table(Config) ->
|
|
||||||
query_direct_mysql(Config, ?SQL_DELETE).
|
|
||||||
|
|
||||||
connect_and_get_payload(Config) ->
|
connect_and_get_payload(Config) ->
|
||||||
query_direct_mysql(Config, ?SQL_SELECT).
|
query_direct_mysql(Config, ?SQL_SELECT).
|
||||||
|
|
||||||
|
@ -777,8 +771,6 @@ t_table_removed(Config) ->
|
||||||
Name = ?config(mysql_name, Config),
|
Name = ?config(mysql_name, Config),
|
||||||
BridgeType = ?config(mysql_bridge_type, Config),
|
BridgeType = ?config(mysql_bridge_type, Config),
|
||||||
ResourceID = emqx_bridge_resource:resource_id(BridgeType, Name),
|
ResourceID = emqx_bridge_resource:resource_id(BridgeType, Name),
|
||||||
?check_trace(
|
|
||||||
begin
|
|
||||||
connect_and_create_table(Config),
|
connect_and_create_table(Config),
|
||||||
?assertMatch({ok, _}, create_bridge(Config)),
|
?assertMatch({ok, _}, create_bridge(Config)),
|
||||||
?retry(
|
?retry(
|
||||||
|
@ -792,14 +784,9 @@ t_table_removed(Config) ->
|
||||||
Timeout = 1000,
|
Timeout = 1000,
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
{error,
|
{error,
|
||||||
{unrecoverable_error,
|
{unrecoverable_error, {1146, <<"42S02">>, <<"Table 'mqtt.mqtt_test' doesn't exist">>}}},
|
||||||
{1146, <<"42S02">>, <<"Table 'mqtt.mqtt_test' doesn't exist">>}}},
|
|
||||||
sync_query_resource(Config, {send_message, SentData, [], Timeout})
|
sync_query_resource(Config, {send_message, SentData, [], Timeout})
|
||||||
),
|
),
|
||||||
ok
|
|
||||||
end,
|
|
||||||
[]
|
|
||||||
),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_nested_payload_template(Config) ->
|
t_nested_payload_template(Config) ->
|
||||||
|
@ -807,9 +794,6 @@ t_nested_payload_template(Config) ->
|
||||||
BridgeType = ?config(mysql_bridge_type, Config),
|
BridgeType = ?config(mysql_bridge_type, Config),
|
||||||
ResourceID = emqx_bridge_resource:resource_id(BridgeType, Name),
|
ResourceID = emqx_bridge_resource:resource_id(BridgeType, Name),
|
||||||
Value = integer_to_binary(erlang:unique_integer()),
|
Value = integer_to_binary(erlang:unique_integer()),
|
||||||
?check_trace(
|
|
||||||
begin
|
|
||||||
connect_and_create_table(Config),
|
|
||||||
{ok, _} = create_bridge(
|
{ok, _} = create_bridge(
|
||||||
Config,
|
Config,
|
||||||
#{
|
#{
|
||||||
|
@ -837,8 +821,4 @@ t_nested_payload_template(Config) ->
|
||||||
{ok, [<<"payload">>], [[Value]]},
|
{ok, [<<"payload">>], [[Value]]},
|
||||||
connect_and_get_payload(Config)
|
connect_and_get_payload(Config)
|
||||||
),
|
),
|
||||||
ok
|
|
||||||
end,
|
|
||||||
[]
|
|
||||||
),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
Loading…
Reference in New Issue