From 4bb24971187ac8695910c15f816cf17040a539d9 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Sun, 12 Apr 2020 11:38:07 +0800 Subject: [PATCH 1/9] Update jiffy to 1.0.4 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 8f9c63b3b..e42f1e4ea 100644 --- a/rebar.config +++ b/rebar.config @@ -2,7 +2,7 @@ {deps, [{gproc, "0.8.0"}, - {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.2"}}}, + {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.4"}}}, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.7.1"}}}, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.6.1"}}}, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.7.2"}}}, From e806a96031c2615df8b4e862960aa82a15558c56 Mon Sep 17 00:00:00 2001 From: terry-xiaoyu <506895667@qq.com> Date: Wed, 15 Apr 2020 09:03:52 +0800 Subject: [PATCH 2/9] Change timestamps to millisecond --- src/emqx_alarm_handler.erl | 4 ++-- src/emqx_channel.erl | 4 ++-- src/emqx_session.erl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/emqx_alarm_handler.erl b/src/emqx_alarm_handler.erl index b57a04380..990f8a76e 100644 --- a/src/emqx_alarm_handler.erl +++ b/src/emqx_alarm_handler.erl @@ -105,7 +105,7 @@ init(_) -> {ok, []}. handle_event({set_alarm, {AlarmId, AlarmDesc = #alarm{timestamp = undefined}}}, State) -> - handle_event({set_alarm, {AlarmId, AlarmDesc#alarm{timestamp = erlang:system_time(second)}}}, State); + handle_event({set_alarm, {AlarmId, AlarmDesc#alarm{timestamp = erlang:system_time(millisecond)}}}, State); handle_event({set_alarm, Alarm = {AlarmId, AlarmDesc}}, State) -> ?LOG(warning, "New Alarm: ~p, Alarm Info: ~p", [AlarmId, AlarmDesc]), case encode_alarm(Alarm) of @@ -199,5 +199,5 @@ clear_alarm_(Id) -> set_alarm_history(Id, Desc) -> His = #alarm_history{id = Id, desc = Desc, - clear_at = erlang:system_time(second)}, + clear_at = erlang:system_time(millisecond)}, mnesia:dirty_write(?ALARM_HISTORY_TAB, His). diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index 4490ca40f..e1fd1b6f3 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -1345,7 +1345,7 @@ enrich_assigned_clientid(AckProps, #channel{conninfo = ConnInfo, ensure_connected(Channel = #channel{conninfo = ConnInfo, clientinfo = ClientInfo}) -> - NConnInfo = ConnInfo#{connected_at => erlang:system_time(second)}, + NConnInfo = ConnInfo#{connected_at => erlang:system_time(millisecond)}, ok = run_hooks('client.connected', [ClientInfo, NConnInfo]), Channel#channel{conninfo = NConnInfo, conn_state = connected @@ -1422,7 +1422,7 @@ parse_topic_filters(TopicFilters) -> ensure_disconnected(Reason, Channel = #channel{conninfo = ConnInfo, clientinfo = ClientInfo}) -> - NConnInfo = ConnInfo#{disconnected_at => erlang:system_time(second)}, + NConnInfo = ConnInfo#{disconnected_at => erlang:system_time(millisecond)}, ok = run_hooks('client.disconnected', [ClientInfo, Reason, NConnInfo]), Channel#channel{conninfo = NConnInfo, conn_state = disconnected}. diff --git a/src/emqx_session.erl b/src/emqx_session.erl index 2b03b7868..684589ff2 100644 --- a/src/emqx_session.erl +++ b/src/emqx_session.erl @@ -168,7 +168,7 @@ init(#{zone := Zone}, #{receive_maximum := MaxInflight}) -> awaiting_rel = #{}, max_awaiting_rel = get_env(Zone, max_awaiting_rel, 100), await_rel_timeout = timer:seconds(get_env(Zone, await_rel_timeout, 300)), - created_at = erlang:system_time(second) + created_at = erlang:system_time(millisecond) }. %% @private init mq From eebc5e4b0afd2297b95b85fa5a38eec3442bd552 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Wed, 15 Apr 2020 18:05:30 +0800 Subject: [PATCH 3/9] Optimize cli print --- src/emqx_ctl.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index d2cbf9b04..4b6c375d1 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -126,7 +126,7 @@ get_commands() -> help() -> print("Usage: ~s~n", [?MODULE]), - [begin print("~80..-s~n", [""]), Mod:Cmd(usage) end + [begin print("~110..-s~n", [""]), Mod:Cmd(usage) end || {_, {Mod, Cmd}, _} <- ets:tab2list(?CMD_TAB)]. -spec(print(io:format()) -> ok). @@ -165,7 +165,7 @@ format_usage(CmdParams, Desc) -> CmdLines = split_cmd(CmdParams), DescLines = split_cmd(Desc), lists:foldl(fun({CmdStr, DescStr}, Usage) -> - Usage ++ format("~-48s# ~s~n", [CmdStr, DescStr]) + Usage ++ format("~-70s# ~s~n", [CmdStr, DescStr]) end, "", zip_cmd(CmdLines, DescLines)). %%-------------------------------------------------------------------- From fb661b1d9231590137232a710ec5bd843c229f72 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Thu, 16 Apr 2020 10:35:35 +0800 Subject: [PATCH 4/9] Support return all registered topics --- src/emqx_mod_topic_metrics.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/emqx_mod_topic_metrics.erl b/src/emqx_mod_topic_metrics.erl index 5deb42b92..4e9b44fa8 100644 --- a/src/emqx_mod_topic_metrics.erl +++ b/src/emqx_mod_topic_metrics.erl @@ -49,6 +49,7 @@ , unregister/1 , unregister_all/0 , is_registered/1 + , all_registered_topics/0 ]). %% gen_server callbacks @@ -194,6 +195,9 @@ unregister_all() -> is_registered(Topic) -> ets:member(?TAB, Topic). +all_registered_topics() -> + [Topic || {Topic, _CRef} <- ets:tab2list(?TAB)]. + %%-------------------------------------------------------------------- %% gen_server callbacks %%-------------------------------------------------------------------- From 973a31a041cf1ef83d708c23057c1a86aa950059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=A5=87=E6=80=AA?= Date: Thu, 16 Apr 2020 11:40:35 +0800 Subject: [PATCH 5/9] Update issue templates --- .github/ISSUE_TEMPLATE/bug-report.md | 27 ++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 14 +++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ .github/ISSUE_TEMPLATE/reporting-a-bug.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/supper.md | 10 ++++++ .github/ISSUE_TEMPLATE/support-needed.md | 10 ++++++ 7 files changed, 157 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/reporting-a-bug.md create mode 100644 .github/ISSUE_TEMPLATE/supper.md create mode 100644 .github/ISSUE_TEMPLATE/support-needed.md diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 000000000..04f4ecb2d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,27 @@ +--- +name: Bug Report +about: Create a report to help us improve +title: '' +labels: BUG +assignees: tigercl + +--- + + +**What happened**: + +**What you expected to happen**: + +**How to reproduce it (as minimally and precisely as possible)**: + +**Anything else we need to know?**: + +**Environment**: + +- EMQ X version (e.g. `emqx_ctl status`): + +- Hardware configuration (e.g. `lscpu`): +- OS (e.g. `cat /etc/os-release`): +- Kernel (e.g. `uname -a`): +- Erlang/OTP version : +- Others: diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..a2010b49a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: BUG +assignees: tigercl + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 000000000..67b1dfa82 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,14 @@ +--- +name: Feature Request +about: Suggest an idea for this project +title: '' +labels: Feature +assignees: tigercl + +--- + + + +**What would you like to be added/modified**: + +**Why is this needed**: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..f96c88a91 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: Feature +assignees: tigercl + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/reporting-a-bug.md b/.github/ISSUE_TEMPLATE/reporting-a-bug.md new file mode 100644 index 000000000..c14d8612a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/reporting-a-bug.md @@ -0,0 +1,38 @@ +--- +name: Reporting a Bug +about: Create a report to help us improve +title: '' +labels: BUG +assignees: tigercl + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/supper.md b/.github/ISSUE_TEMPLATE/supper.md new file mode 100644 index 000000000..73b850db7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/supper.md @@ -0,0 +1,10 @@ +--- +name: Supper +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/support-needed.md b/.github/ISSUE_TEMPLATE/support-needed.md new file mode 100644 index 000000000..80b494077 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support-needed.md @@ -0,0 +1,10 @@ +--- +name: Support Needed +about: Asking a question about usages, docs or anything you're insterested in +title: '' +labels: Support +assignees: tigercl + +--- + +**Please describe your problem in detail, if necessary, you can upload the log file through the attachment**: From dccf3560f03aa38b329447dab3e3637588aa6e93 Mon Sep 17 00:00:00 2001 From: zhanghongtong Date: Thu, 16 Apr 2020 16:07:01 +0800 Subject: [PATCH 6/9] Add hook to auth packet --- src/emqx_channel.erl | 9 +++------ src/emqx_metrics.erl | 11 ++++++----- test/emqx_channel_SUITE.erl | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index e1fd1b6f3..9a3339c65 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -1138,21 +1138,18 @@ do_enhanced_auth(undefined, _AuthData, Channel) -> do_enhanced_auth(_AuthMethod, undefined, Channel) -> {error, emqx_reason_codes:connack_error(not_authorized), Channel}; do_enhanced_auth(AuthMethod, AuthData, Channel = #channel{auth_cache = Cache}) -> - case do_auth_check(AuthMethod, AuthData, Cache) of - ok -> {ok, #{}, Channel#channel{auth_cache = #{}}}; + case run_hooks('client.enhanced_authenticate',[AuthMethod, AuthData, Cache]) of + {ok, <<>>} -> {ok, #{}, Channel#channel{auth_cache = #{}}}; {ok, NAuthData} -> NProperties = #{'Authentication-Method' => AuthMethod, 'Authentication-Data' => NAuthData}, {ok, NProperties, Channel#channel{auth_cache = #{}}}; {continue, NAuthData, NCache} -> NProperties = #{'Authentication-Method' => AuthMethod, 'Authentication-Data' => NAuthData}, {continue, NProperties, Channel#channel{auth_cache = NCache}}; - {error, _Reason} -> + _ -> {error, emqx_reason_codes:connack_error(not_authorized), Channel} end. -do_auth_check(_AuthMethod, _AuthData, _AuthDataCache) -> - {error, not_authorized}. - %%-------------------------------------------------------------------- %% Process Topic Alias diff --git a/src/emqx_metrics.erl b/src/emqx_metrics.erl index 47c2e9a6a..4009ca67c 100644 --- a/src/emqx_metrics.erl +++ b/src/emqx_metrics.erl @@ -520,11 +520,12 @@ reserved_idx('client.connect') -> 200; reserved_idx('client.connack') -> 201; reserved_idx('client.connected') -> 202; reserved_idx('client.authenticate') -> 203; -reserved_idx('client.auth.anonymous') -> 204; -reserved_idx('client.check_acl') -> 205; -reserved_idx('client.subscribe') -> 206; -reserved_idx('client.unsubscribe') -> 207; -reserved_idx('client.disconnected') -> 208; +reserved_idx('client.enhanced_authenticate') -> 204; +reserved_idx('client.auth.anonymous') -> 205; +reserved_idx('client.check_acl') -> 206; +reserved_idx('client.subscribe') -> 207; +reserved_idx('client.unsubscribe') -> 208; +reserved_idx('client.disconnected') -> 209; reserved_idx('session.created') -> 220; reserved_idx('session.resumed') -> 221; diff --git a/test/emqx_channel_SUITE.erl b/test/emqx_channel_SUITE.erl index a94095b2b..0bddae09d 100644 --- a/test/emqx_channel_SUITE.erl +++ b/test/emqx_channel_SUITE.erl @@ -120,7 +120,7 @@ t_handle_in_connect_auth_failed(_) -> clean_start = true, keepalive = 30, properties = #{ - 'Authentication-Method' => "failed_auth_method", + 'Authentication-Method' => <<"failed_auth_method">>, 'Authentication-Data' => <<"failed_auth_data">> }, clientid = <<"clientid">>, @@ -131,7 +131,7 @@ t_handle_in_connect_auth_failed(_) -> t_handle_in_continue_auth(_) -> Properties = #{ - 'Authentication-Method' => "failed_auth_method", + 'Authentication-Method' => <<"failed_auth_method">>, 'Authentication-Data' => <<"failed_auth_data">> }, {shutdown, bad_authentication_method, ?CONNACK_PACKET(?RC_BAD_AUTHENTICATION_METHOD), _} = @@ -141,7 +141,7 @@ t_handle_in_continue_auth(_) -> t_handle_in_re_auth(_) -> Properties = #{ - 'Authentication-Method' => "failed_auth_method", + 'Authentication-Method' => <<"failed_auth_method">>, 'Authentication-Data' => <<"failed_auth_data">> }, {ok, [{outgoing, ?DISCONNECT_PACKET(?RC_BAD_AUTHENTICATION_METHOD)}, {close, bad_authentication_method}], _} = From cc76abdcb3a52d9fb43e932e2f7fe57999e1df67 Mon Sep 17 00:00:00 2001 From: turtleDeng Date: Thu, 16 Apr 2020 17:28:20 +0800 Subject: [PATCH 7/9] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ----------------------- .github/ISSUE_TEMPLATE/feature_request.md | 20 ------------ .github/ISSUE_TEMPLATE/reporting-a-bug.md | 38 ----------------------- .github/ISSUE_TEMPLATE/supper.md | 10 ------ 4 files changed, 106 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/reporting-a-bug.md delete mode 100644 .github/ISSUE_TEMPLATE/supper.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index a2010b49a..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: BUG -assignees: tigercl - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index f96c88a91..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: Feature -assignees: tigercl - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/reporting-a-bug.md b/.github/ISSUE_TEMPLATE/reporting-a-bug.md deleted file mode 100644 index c14d8612a..000000000 --- a/.github/ISSUE_TEMPLATE/reporting-a-bug.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Reporting a Bug -about: Create a report to help us improve -title: '' -labels: BUG -assignees: tigercl - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/supper.md b/.github/ISSUE_TEMPLATE/supper.md deleted file mode 100644 index 73b850db7..000000000 --- a/.github/ISSUE_TEMPLATE/supper.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Supper -about: Describe this issue template's purpose here. -title: '' -labels: '' -assignees: '' - ---- - - From 6cab60b6ab06ceed3c05af98eb85bcdc9d6661cb Mon Sep 17 00:00:00 2001 From: zhouzb Date: Fri, 17 Apr 2020 11:02:40 +0800 Subject: [PATCH 8/9] Export emqx_modules:find_module/1 --- src/emqx_modules.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/emqx_modules.erl b/src/emqx_modules.erl index 948359aa7..75ac35ce5 100644 --- a/src/emqx_modules.erl +++ b/src/emqx_modules.erl @@ -26,6 +26,7 @@ , unload/0 , unload/1 , reload/1 + , find_module/1 , load_module/2 ]). From d5f405259d756a655df5b15dc14f6e9c23dd2564 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Fri, 17 Apr 2020 20:38:13 +0800 Subject: [PATCH 9/9] Fix test case --- test/emqx_ctl_SUITE.erl | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/test/emqx_ctl_SUITE.erl b/test/emqx_ctl_SUITE.erl index 9a310de5c..a73d011bd 100644 --- a/test/emqx_ctl_SUITE.erl +++ b/test/emqx_ctl_SUITE.erl @@ -76,24 +76,9 @@ t_print(_) -> t_usage(_) -> CmdParams1 = "emqx_cmd_1 param1 param2", CmdDescr1 = "emqx_cmd_1 is a test command means nothing", - Output1 = "emqx_cmd_1 param1 param2 # emqx_cmd_1 is a test command means nothing\n", % - usage/1,2 should return ok ok = emqx_ctl:usage([{CmdParams1, CmdDescr1}, {CmdParams1, CmdDescr1}]), - ok = emqx_ctl:usage(CmdParams1, CmdDescr1), - - % - check the output of the usage - mock_print(), - ?assertEqual(Output1, emqx_ctl:usage(CmdParams1, CmdDescr1)), - ?assertEqual([Output1, Output1], emqx_ctl:usage([{CmdParams1, CmdDescr1}, {CmdParams1, CmdDescr1}])), - - % - for the commands or descriptions have multi-lines - CmdParams2 = "emqx_cmd_2 param1 param2", - CmdDescr2 = "emqx_cmd_2 is a test command\nmeans nothing", - Output2 = "emqx_cmd_2 param1 param2 # emqx_cmd_2 is a test command\n" - " ""# means nothing\n", - ?assertEqual(Output2, emqx_ctl:usage(CmdParams2, CmdDescr2)), - ?assertEqual([Output2, Output2], emqx_ctl:usage([{CmdParams2, CmdDescr2}, {CmdParams2, CmdDescr2}])), - unmock_print(). + ok = emqx_ctl:usage(CmdParams1, CmdDescr1). t_unexpected(_) -> with_ctl_server(