Skip to content

Commit

Permalink
fix(test): fix test case fail
Browse files Browse the repository at this point in the history
  • Loading branch information
turtleDeng committed Jun 23, 2021
1 parent 6645df4 commit f83c96f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/emqx_telemetry/src/emqx_telemetry.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ get_telemetry() ->
init([Opts]) ->
State = #state{url = ?TELEMETRY_URL,
report_interval = timer:seconds(?REPORT_INTERVAR)},
Enabled = proplists:get_value(enabled, Opts, true),
NState = case mnesia:dirty_read(?TELEMETRY, ?UNIQUE_ID) of
[] ->
Enabled = proplists:get_value(enabled, Opts, true),
UUID = generate_uuid(),
mnesia:dirty_write(?TELEMETRY, #telemetry{id = ?UNIQUE_ID,
uuid = UUID,
Expand Down
13 changes: 11 additions & 2 deletions apps/emqx_telemetry/test/emqx_telemetry_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,20 @@ all() -> emqx_ct:all(?MODULE).

init_per_testcase(_, Config) ->
emqx_ct_helpers:boot_modules(all),
emqx_ct_helpers:start_apps([emqx_modules, emqx_telemetry]),
emqx_ct_helpers:start_apps([emqx_telemetry], fun set_special_configs/1),
Config.

end_per_testcase(_, _Config) ->
emqx_ct_helpers:stop_apps([emqx_telemetry, emqx_modules]).
emqx_ct_helpers:stop_apps([emqx_telemetry]).

set_special_configs(emqx_telemetry) ->
application:set_env(emqx, plugins_etc_dir,
emqx_ct_helpers:deps_path(emqx_telemetry, "test")),
Conf = #{<<"emqx_telemetry">> => #{<<"enabled">> => true}},
ok = file:write_file(filename:join(emqx:get_env(plugins_etc_dir), 'emqx_telemetry.conf'), jsx:encode(Conf)),
ok;
set_special_configs(_App) ->
ok.

t_uuid(_) ->
UUID = emqx_telemetry:generate_uuid(),
Expand Down

0 comments on commit f83c96f

Please sign in to comment.