test: enable basic plugins API tests

This commit is contained in:
Stefan Strigler 2023-02-02 11:09:40 +01:00
parent a866c995f5
commit e135f8654c
1 changed files with 8 additions and 7 deletions

View File

@ -20,7 +20,7 @@
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-define(EMQX_PLUGIN_TEMPLATE_VSN, "5.0-rc.1"). -define(EMQX_PLUGIN_TEMPLATE_VSN, "5.0.0").
-define(PACKAGE_SUFFIX, ".tar.gz"). -define(PACKAGE_SUFFIX, ".tar.gz").
all() -> all() ->
@ -30,12 +30,11 @@ init_per_suite(Config) ->
WorkDir = proplists:get_value(data_dir, Config), WorkDir = proplists:get_value(data_dir, Config),
ok = filelib:ensure_dir(WorkDir), ok = filelib:ensure_dir(WorkDir),
DemoShDir1 = string:replace(WorkDir, "emqx_mgmt_api_plugins", "emqx_plugins"), DemoShDir1 = string:replace(WorkDir, "emqx_mgmt_api_plugins", "emqx_plugins"),
DemoShDir = string:replace(DemoShDir1, "emqx_management", "emqx_plugins"), DemoShDir = lists:flatten(string:replace(DemoShDir1, "emqx_management", "emqx_plugins")),
OrigInstallDir = emqx_plugins:get_config(install_dir, undefined), OrigInstallDir = emqx_plugins:get_config(install_dir, undefined),
ok = filelib:ensure_dir(DemoShDir), ok = filelib:ensure_dir(DemoShDir),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_plugins]), emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_plugins]),
emqx_plugins:put_config(install_dir, DemoShDir), emqx_plugins:put_config(install_dir, DemoShDir),
[{demo_sh_dir, DemoShDir}, {orig_install_dir, OrigInstallDir} | Config]. [{demo_sh_dir, DemoShDir}, {orig_install_dir, OrigInstallDir} | Config].
end_per_suite(Config) -> end_per_suite(Config) ->
@ -48,18 +47,20 @@ end_per_suite(Config) ->
emqx_mgmt_api_test_util:end_suite([emqx_plugins, emqx_conf]), emqx_mgmt_api_test_util:end_suite([emqx_plugins, emqx_conf]),
ok. ok.
todo_t_plugins(Config) -> t_plugins(Config) ->
DemoShDir = proplists:get_value(demo_sh_dir, Config), DemoShDir = proplists:get_value(demo_sh_dir, Config),
PackagePath = get_demo_plugin_package(DemoShDir), PackagePath = get_demo_plugin_package(DemoShDir),
ct:pal("package_location:~p install dir:~p", [PackagePath, emqx_plugins:install_dir()]), ct:pal("package_location:~p install dir:~p", [PackagePath, emqx_plugins:install_dir()]),
NameVsn = filename:basename(PackagePath, ?PACKAGE_SUFFIX), NameVsn = filename:basename(PackagePath, ?PACKAGE_SUFFIX),
ok = emqx_plugins:ensure_uninstalled(NameVsn),
ok = emqx_plugins:delete_package(NameVsn), ok = emqx_plugins:delete_package(NameVsn),
ok = install_plugin(PackagePath), ok = install_plugin(PackagePath),
{ok, StopRes} = describe_plugins(NameVsn), {ok, StopRes} = describe_plugins(NameVsn),
Node = atom_to_binary(node()),
?assertMatch( ?assertMatch(
#{ #{
<<"running_status">> := [ <<"running_status">> := [
#{<<"node">> := <<"test@127.0.0.1">>, <<"status">> := <<"stopped">>} #{<<"node">> := Node, <<"status">> := <<"stopped">>}
] ]
}, },
StopRes StopRes
@ -70,7 +71,7 @@ todo_t_plugins(Config) ->
?assertMatch( ?assertMatch(
#{ #{
<<"running_status">> := [ <<"running_status">> := [
#{<<"node">> := <<"test@127.0.0.1">>, <<"status">> := <<"running">>} #{<<"node">> := Node, <<"status">> := <<"running">>}
] ]
}, },
StartRes StartRes
@ -80,7 +81,7 @@ todo_t_plugins(Config) ->
?assertMatch( ?assertMatch(
#{ #{
<<"running_status">> := [ <<"running_status">> := [
#{<<"node">> := <<"test@127.0.0.1">>, <<"status">> := <<"stopped">>} #{<<"node">> := Node, <<"status">> := <<"stopped">>}
] ]
}, },
StopRes2 StopRes2