From 48c1d0983d17cb901647f84c6e3885978e95ffc5 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 21 May 2021 09:24:39 +0200 Subject: [PATCH 1/4] chore(emqx_ctl): do not print application --- apps/emqx_management/src/emqx_mgmt_cli.erl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_cli.erl b/apps/emqx_management/src/emqx_mgmt_cli.erl index 252ac3857..77fe96182 100644 --- a/apps/emqx_management/src/emqx_mgmt_cli.erl +++ b/apps/emqx_management/src/emqx_mgmt_cli.erl @@ -116,13 +116,7 @@ mgmt(_) -> status([]) -> {InternalStatus, _ProvidedStatus} = init:get_status(), - emqx_ctl:print("Node ~p ~s is ~p~n", [node(), emqx_app:get_release(), InternalStatus]), - case lists:keysearch(?APP, 1, application:which_applications()) of - false -> - emqx_ctl:print("Application ~s is not running~n", [?APP]); - {value, {?APP, _Desc, Vsn}} -> - emqx_ctl:print("Application ~s ~s is running~n", [?APP, Vsn]) - end; + emqx_ctl:print("Node ~p ~s is ~p~n", [node(), emqx_app:get_release(), InternalStatus]); status(_) -> emqx_ctl:usage("status", "Show broker status"). From 5fe395cee52f51fdb2d47d5fa81adbc532cfbe16 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 21 May 2021 10:25:04 +0200 Subject: [PATCH 2/4] test: fix emqx_ctl printout test --- apps/emqx_management/test/emqx_mgmt_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/emqx_management/test/emqx_mgmt_SUITE.erl b/apps/emqx_management/test/emqx_mgmt_SUITE.erl index 42578baf7..6bac9b4c7 100644 --- a/apps/emqx_management/test/emqx_mgmt_SUITE.erl +++ b/apps/emqx_management/test/emqx_mgmt_SUITE.erl @@ -133,7 +133,8 @@ t_mgmt_cmd(_) -> t_status_cmd(_) -> % ct:pal("start testing status command"), mock_print(), - ?assertMatch({match, _}, re:run(emqx_mgmt_cli:status([]), "is running")), + %% init internal status seem to be always 'starting' when running ct tests + ?assertMatch({match, _}, re:run(emqx_mgmt_cli:status([]), "Node\s.*@.*\sis\sstart(ed|ing)")), meck:unload(). t_broker_cmd(_) -> From ce2739ef3d6a461a28922818f82bdb81ccf9dfe9 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 21 May 2021 10:38:39 +0200 Subject: [PATCH 3/4] chore(emqx_management): update appup --- apps/emqx_management/src/emqx_management.appup.src | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/emqx_management/src/emqx_management.appup.src b/apps/emqx_management/src/emqx_management.appup.src index 9ad23381e..3206ce31b 100644 --- a/apps/emqx_management/src/emqx_management.appup.src +++ b/apps/emqx_management/src/emqx_management.appup.src @@ -2,11 +2,13 @@ {"4.3.2", [ {<<"4.3.[0-1]">>, [ {load_module, emqx_mgmt_data_backup, brutal_purge, soft_purge, []} + , {load_module, emqx_mgmt_cli, brutal_purge, soft_purge, []} ]} ], [ {<<"4.3.[0-1]">>, [ {load_module, emqx_mgmt_data_backup, brutal_purge, soft_purge, []} + , {load_module, emqx_mgmt_cli, brutal_purge, soft_purge, []} ]} ] }. From e7e87837e5c833f84eb71442235ea633c3eaebd6 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Fri, 21 May 2021 11:07:50 +0200 Subject: [PATCH 4/4] test: fix emqx_ctl status grep pattern --- .ci/build_packages/tests.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/build_packages/tests.sh b/.ci/build_packages/tests.sh index 1f9ca2651..bbc107d37 100755 --- a/.ci/build_packages/tests.sh +++ b/.ci/build_packages/tests.sh @@ -31,7 +31,7 @@ emqx_test(){ echo "running ${packagename} start" "${PACKAGE_PATH}"/emqx/bin/emqx start || ( tail "${PACKAGE_PATH}"/emqx/log/emqx.log.1 && exit 1 ) IDLE_TIME=0 - while [ -z "$("${PACKAGE_PATH}"/emqx/bin/emqx_ctl status |grep 'is running'|awk '{print $1}')" ] + while ! "${PACKAGE_PATH}"/emqx/bin/emqx_ctl status | grep -qE 'Node\s.*@.*\sis\sstarted' do if [ $IDLE_TIME -gt 10 ] then @@ -103,7 +103,7 @@ running_test(){ emqx start || ( tail /var/log/emqx/emqx.log.1 && exit 1 ) IDLE_TIME=0 - while [ -z "$(emqx_ctl status |grep 'is running'|awk '{print $1}')" ] + while ! emqx_ctl status | grep -qE 'Node\s.*@.*\sis\sstarted' do if [ $IDLE_TIME -gt 10 ] then @@ -121,7 +121,7 @@ running_test(){ || [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = debian ] ;then service emqx start || ( tail /var/log/emqx/emqx.log.1 && exit 1 ) IDLE_TIME=0 - while [ -z "$(emqx_ctl status |grep 'is running'|awk '{print $1}')" ] + while ! emqx_ctl status | grep -E 'Node\s.*@.*\sis\sstarted' do if [ $IDLE_TIME -gt 10 ] then