From 40758fb6933ab76f2765bcd47620b83ce7b8cb10 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 9 Jan 2020 11:53:20 +0800 Subject: [PATCH] Workflow (#3163) Add workflows --- .github/workflows/run_test_case.yaml | 29 ++++++++++++++++++++++++++++ Makefile | 2 +- test/emqx_SUITE.erl | 3 +-- test/emqx_banned_SUITE.erl | 1 + test/emqx_flapping_SUITE.erl | 5 +++-- test/emqx_mod_acl_internal_SUITE.erl | 4 ++-- test/emqx_mod_presence_SUITE.erl | 4 ++-- test/emqx_mod_rewrite_SUITE.erl | 4 ++-- test/emqx_mod_subscription_SUITE.erl | 4 ++-- test/emqx_router_helper_SUITE.erl | 8 ++++---- test/emqx_shared_sub_SUITE.erl | 1 + 11 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/run_test_case.yaml diff --git a/.github/workflows/run_test_case.yaml b/.github/workflows/run_test_case.yaml new file mode 100644 index 000000000..54fe6afea --- /dev/null +++ b/.github/workflows/run_test_case.yaml @@ -0,0 +1,29 @@ +name: Run test case + +on: [push, pull_request] + +jobs: + + run_test_case: + + runs-on: ubuntu-latest + + container: + image: erlang:22.1 + + steps: + - uses: actions/checkout@v1 + - name: Run tests + run: | + make eunit + make ct + make cover + - uses: actions/upload-artifact@v1 + if: always() + with: + name: logs + path: _build/test/logs + - uses: actions/upload-artifact@v1 + with: + name: cover + path: _build/test/cover \ No newline at end of file diff --git a/Makefile b/Makefile index 774aaaba2..ea73928cd 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ REBAR_GIT_CLONE_OPTIONS += --depth 1 export REBAR_GIT_CLONE_OPTIONS -SUITES_FILES := $(shell find test -name '*_SUITE.erl') +SUITES_FILES := $(shell find test -name '*_SUITE.erl' | sort) CT_SUITES := $(foreach value,$(SUITES_FILES),$(shell val=$$(basename $(value) .erl); echo $${val%_*})) diff --git a/test/emqx_SUITE.erl b/test/emqx_SUITE.erl index a2d8ec4e0..24ef77753 100644 --- a/test/emqx_SUITE.erl +++ b/test/emqx_SUITE.erl @@ -60,7 +60,6 @@ t_get_env(_) -> application:unset_env(emqx, undefined_key). t_emqx_pubsub_api(_) -> - emqx:start(), true = emqx:is_running(node()), {ok, C} = emqtt:start_link([{host, "localhost"}, {clientid, "myclient"}]), {ok, _} = emqtt:connect(C), @@ -190,4 +189,4 @@ hook_filter2(_, _Acc, _IntArg) -> false. hook_filter2_1(arg, _Acc, init_arg) -> true; hook_filter2_1(arg1, _Acc, init_arg) -> true; -hook_filter2_1(_, _Acc, _IntArg) -> false. \ No newline at end of file +hook_filter2_1(_, _Acc, _IntArg) -> false. diff --git a/test/emqx_banned_SUITE.erl b/test/emqx_banned_SUITE.erl index a4201cdc1..d99530e12 100644 --- a/test/emqx_banned_SUITE.erl +++ b/test/emqx_banned_SUITE.erl @@ -45,6 +45,7 @@ t_add_delete(_) -> }, ok = emqx_banned:create(Banned), ?assertEqual(1, emqx_banned:info(size)), + ok = emqx_banned:delete({clientid, <<"TestClient">>}), ?assertEqual(0, emqx_banned:info(size)). diff --git a/test/emqx_flapping_SUITE.erl b/test/emqx_flapping_SUITE.erl index ed0ff7567..4d9fd5907 100644 --- a/test/emqx_flapping_SUITE.erl +++ b/test/emqx_flapping_SUITE.erl @@ -37,6 +37,7 @@ set_special_configs(_App) -> ok. end_per_suite(_Config) -> emqx_ct_helpers:stop_apps([]), + ekka_mnesia:delete_schema(), %% Clean emqx_banned table ok. t_detect_check(_) -> @@ -55,8 +56,8 @@ t_detect_check(_) -> false = emqx_banned:check(ClientInfo), Childrens = supervisor:which_children(emqx_cm_sup), {flapping, Pid, _, _} = lists:keyfind(flapping, 1, Childrens), - gen_server:call(Pid, test), - gen_server:cast(Pid, test), + gen_server:call(Pid, unexpected_msg), + gen_server:cast(Pid, unexpected_msg), Pid ! test, ok = emqx_flapping:stop(). diff --git a/test/emqx_mod_acl_internal_SUITE.erl b/test/emqx_mod_acl_internal_SUITE.erl index d92e45f1e..4849fab7d 100644 --- a/test/emqx_mod_acl_internal_SUITE.erl +++ b/test/emqx_mod_acl_internal_SUITE.erl @@ -26,11 +26,11 @@ all() -> emqx_ct:all(?MODULE). init_per_suite(Config) -> emqx_ct_helpers:boot_modules(all), - emqx_ct_helpers:start_apps([emqx]), + emqx_ct_helpers:start_apps([]), Config. end_per_suite(_Config) -> - emqx_ct_helpers:stop_apps([emqx]). + emqx_ct_helpers:stop_apps([]). t_load_unload(_) -> ?assertEqual({error,already_exists}, emqx_mod_acl_internal:load([])), diff --git a/test/emqx_mod_presence_SUITE.erl b/test/emqx_mod_presence_SUITE.erl index 580eacb2d..afa7a4312 100644 --- a/test/emqx_mod_presence_SUITE.erl +++ b/test/emqx_mod_presence_SUITE.erl @@ -26,13 +26,13 @@ all() -> emqx_ct:all(?MODULE). init_per_suite(Config) -> emqx_ct_helpers:boot_modules(all), - emqx_ct_helpers:start_apps([emqx]), + emqx_ct_helpers:start_apps([]), %% Ensure all the modules unloaded. ok = emqx_modules:unload(), Config. end_per_suite(_Config) -> - emqx_ct_helpers:stop_apps([emqx]). + emqx_ct_helpers:stop_apps([]). %% Test case for emqx_mod_presence t_mod_presence(_) -> diff --git a/test/emqx_mod_rewrite_SUITE.erl b/test/emqx_mod_rewrite_SUITE.erl index 8ebeaf245..74397b843 100644 --- a/test/emqx_mod_rewrite_SUITE.erl +++ b/test/emqx_mod_rewrite_SUITE.erl @@ -30,13 +30,13 @@ all() -> emqx_ct:all(?MODULE). init_per_suite(Config) -> emqx_ct_helpers:boot_modules(all), - emqx_ct_helpers:start_apps([emqx]), + emqx_ct_helpers:start_apps([]), %% Ensure all the modules unloaded. ok = emqx_modules:unload(), Config. end_per_suite(_Config) -> - emqx_ct_helpers:stop_apps([emqx]). + emqx_ct_helpers:stop_apps([]). %% Test case for emqx_mod_write t_mod_rewrite(_Config) -> diff --git a/test/emqx_mod_subscription_SUITE.erl b/test/emqx_mod_subscription_SUITE.erl index 65a9b4db0..1b0e98f40 100644 --- a/test/emqx_mod_subscription_SUITE.erl +++ b/test/emqx_mod_subscription_SUITE.erl @@ -26,11 +26,11 @@ all() -> emqx_ct:all(?MODULE). init_per_suite(Config) -> emqx_ct_helpers:boot_modules(all), - emqx_ct_helpers:start_apps([emqx]), + emqx_ct_helpers:start_apps([]), Config. end_per_suite(_Config) -> - emqx_ct_helpers:stop_apps([emqx]). + emqx_ct_helpers:stop_apps([]). t_on_client_connected(_) -> ?assertEqual(ok, emqx_mod_subscription:load([{<<"connected/%c/%u">>, ?QOS_0}])), diff --git a/test/emqx_router_helper_SUITE.erl b/test/emqx_router_helper_SUITE.erl index 87fe5c600..338a7ba65 100644 --- a/test/emqx_router_helper_SUITE.erl +++ b/test/emqx_router_helper_SUITE.erl @@ -25,12 +25,12 @@ all() -> emqx_ct:all(?MODULE). -init_per_testcase(_TestCase, Config) -> - emqx_ct_helpers:start_apps([emqx]), +init_per_suite(Config) -> + emqx_ct_helpers:start_apps([]), Config. -end_per_testcase(_TestCase, Config) -> - Config. +end_per_suite(_Config) -> + emqx_ct_helpers:stop_apps([]). t_monitor(_) -> ok = emqx_router_helper:monitor({undefined, node()}), diff --git a/test/emqx_shared_sub_SUITE.erl b/test/emqx_shared_sub_SUITE.erl index bbc335687..22382df6c 100644 --- a/test/emqx_shared_sub_SUITE.erl +++ b/test/emqx_shared_sub_SUITE.erl @@ -293,3 +293,4 @@ recv_msgs(Count, Msgs) -> after 100 -> Msgs end. +