Просмотр исходного кода

test(emqx_bridge_v2_api_SUITE): fix broken test case

Kjell Winblad 2 лет назад
Родитель
Сommit
dd8085d3a4
1 измененных файлов с 29 добавлено и 7 удалено
  1. 29 7
      apps/emqx_bridge/test/emqx_bridge_v2_api_SUITE.erl

+ 29 - 7
apps/emqx_bridge/test/emqx_bridge_v2_api_SUITE.erl

@@ -601,13 +601,9 @@ do_start_bridge(TestType, Config) ->
         fun(_, _, _ResId, _Channel) -> {error, <<"my_error">>} end,
         fun(_, _, _ResId, _Channel) -> {error, <<"my_error">>} end,
         Config
         Config
     ),
     ),
-    ConnectorID = emqx_connector_resource:connector_id(?BRIDGE_TYPE, ?CONNECTOR_NAME),
-    {ok, 204, <<>>} = emqx_connector_api_SUITE:request(
-        post, {operation, TestType, stop, ConnectorID}, Config
-    ),
-    {ok, 204, <<>>} = emqx_connector_api_SUITE:request(
-        post, {operation, TestType, start, ConnectorID}, Config
-    ),
+
+    connector_operation(Config, ?BRIDGE_TYPE, ?CONNECTOR_NAME, stop),
+    connector_operation(Config, ?BRIDGE_TYPE, ?CONNECTOR_NAME, start),
 
 
     {ok, 400, _} = request(post, {operation, TestType, start, BridgeID}, Config),
     {ok, 400, _} = request(post, {operation, TestType, start, BridgeID}, Config),
 
 
@@ -642,6 +638,32 @@ expect_on_all_nodes(Mod, Function, Fun, Config) ->
     end,
     end,
     ok.
     ok.
 
 
+connector_operation(Config, ConnectorType, ConnectorName, OperationName) ->
+    case ?config(group, Config) of
+        cluster ->
+            case ?config(cluster_nodes, Config) of
+                undefined ->
+                    Node = ?config(node, Config),
+                    ok = rpc:call(
+                        Node,
+                        emqx_connector_resource,
+                        OperationName,
+                        [ConnectorType, ConnectorName],
+                        500
+                    );
+                Nodes ->
+                    erpc:multicall(
+                        Nodes,
+                        emqx_connector_resource,
+                        OperationName,
+                        [ConnectorType, ConnectorName],
+                        500
+                    )
+            end;
+        _ ->
+            ok = emqx_connector_resource:OperationName(ConnectorType, ConnectorName)
+    end.
+
 %% t_start_stop_inconsistent_bridge_node(Config) ->
 %% t_start_stop_inconsistent_bridge_node(Config) ->
 %%     start_stop_inconsistent_bridge(node, Config).
 %%     start_stop_inconsistent_bridge(node, Config).