diff --git a/apps/emqx_connector/src/emqx_connector_resource.erl b/apps/emqx_connector/src/emqx_connector_resource.erl index 8611ba744..74c167b32 100644 --- a/apps/emqx_connector/src/emqx_connector_resource.erl +++ b/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(<>, Opts) -> +parse_connector_id(<>, 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}}}, diff --git a/apps/emqx_resource/src/emqx_resource_manager.erl b/apps/emqx_resource/src/emqx_resource_manager.erl index 4fd566f26..b16520d3d 100644 --- a/apps/emqx_resource/src/emqx_resource_manager.erl +++ b/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