Browse Source

fix(connector): make the connector id unique when doing probe testing

firest 2 năm trước cách đây
mục cha
commit
51e8c955ff

+ 3 - 3
apps/emqx_connector/src/emqx_connector_resource.erl

@@ -107,7 +107,7 @@ parse_connector_id(ConnectorId) ->
     {atom(), atom() | binary()}.
 parse_connector_id(<<"connector:", ConnectorId/binary>>, Opts) ->
     parse_connector_id(ConnectorId, Opts);
-parse_connector_id(<<?TEST_ID_PREFIX, ConnectorId/binary>>, Opts) ->
+parse_connector_id(<<?TEST_ID_PREFIX, _:16/binary, ConnectorId/binary>>, Opts) ->
     parse_connector_id(ConnectorId, Opts);
 parse_connector_id(ConnectorId, Opts) ->
     emqx_resource:parse_resource_id(ConnectorId, Opts).
@@ -230,9 +230,9 @@ create_dry_run(Type, Conf0, Callback) ->
     TypeAtom = safe_atom(Type),
     %% We use a fixed name here to avoid creating an atom
     %% to avoid potential race condition, the resource id should be unique
-    UID = integer_to_binary(erlang:unique_integer([monotonic, positive])),
+    Prefix = emqx_resource_manager:make_test_id(),
     TmpName =
-        iolist_to_binary([?TEST_ID_PREFIX, TypeBin, ":", <<"probedryrun">>, UID]),
+        iolist_to_binary([Prefix, TypeBin, ":", <<"probedryrun">>]),
     TmpPath = emqx_utils:safe_filename(TmpName),
     Conf1 = maps:without([<<"name">>], Conf0),
     RawConf = #{<<"connectors">> => #{TypeBin => #{<<"temp_name">> => Conf1}}},

+ 2 - 1
apps/emqx_resource/src/emqx_resource_manager.erl

@@ -50,7 +50,8 @@
 ]).
 
 -export([
-    set_resource_status_connecting/1
+    set_resource_status_connecting/1,
+    make_test_id/0
 ]).
 
 % Server