test: fix build demo plugins crash.
This commit is contained in:
parent
141c3adc76
commit
4cde1274c7
|
@ -32,8 +32,9 @@ init_per_suite(Config) ->
|
||||||
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 = 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),
|
||||||
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, WorkDir),
|
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].
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ end_per_suite(Config) ->
|
||||||
t_plugins(Config) ->
|
t_plugins(Config) ->
|
||||||
DemoShDir = proplists:get_value(demo_sh_dir, Config),
|
DemoShDir = proplists:get_value(demo_sh_dir, Config),
|
||||||
PackagePath = build_demo_plugin_package(DemoShDir),
|
PackagePath = build_demo_plugin_package(DemoShDir),
|
||||||
|
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 = install_plugin(PackagePath),
|
ok = install_plugin(PackagePath),
|
||||||
{ok, StopRes} = describe_plugins(NameVsn),
|
{ok, StopRes} = describe_plugins(NameVsn),
|
||||||
|
@ -108,21 +110,10 @@ uninstall_plugin(Name) ->
|
||||||
|
|
||||||
|
|
||||||
build_demo_plugin_package(Dir) ->
|
build_demo_plugin_package(Dir) ->
|
||||||
BuildSh = filename:join([Dir, "build-demo-plugin.sh"]),
|
#{package := Pkg} = emqx_plugins_SUITE:build_demo_plugin_package(),
|
||||||
case emqx_run_sh:do(BuildSh ++ " " ++ ?EMQX_PLUGIN_TEMPLATE_VSN,
|
|
||||||
[{cd, Dir}]) of
|
|
||||||
{ok, _} ->
|
|
||||||
FileName = "emqx_plugin_template-" ++ ?EMQX_PLUGIN_TEMPLATE_VSN ++ ?PACKAGE_SUFFIX,
|
FileName = "emqx_plugin_template-" ++ ?EMQX_PLUGIN_TEMPLATE_VSN ++ ?PACKAGE_SUFFIX,
|
||||||
Pkg = filename:join([Dir, FileName]),
|
|
||||||
case filelib:is_regular(Pkg) of
|
|
||||||
true ->
|
|
||||||
PluginPath = "./" ++ FileName,
|
PluginPath = "./" ++ FileName,
|
||||||
_ = os:cmd("mv " ++ Pkg ++ " " ++ PluginPath),
|
Pkg = filename:join([Dir, FileName]),
|
||||||
|
_ = os:cmd("cp " ++ Pkg ++ " " ++ PluginPath),
|
||||||
true = filelib:is_regular(PluginPath),
|
true = filelib:is_regular(PluginPath),
|
||||||
PluginPath;
|
PluginPath.
|
||||||
false -> error(#{reason => unexpected_build_result, not_found => Pkg})
|
|
||||||
end;
|
|
||||||
{error, {Rc, Output}} ->
|
|
||||||
io:format(user, "failed_to_build_demo_plugin, Exit = ~p, Output:~n~ts\n", [Rc, Output]),
|
|
||||||
error(failed_to_build_demo_plugin)
|
|
||||||
end.
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ build_demo_plugin_package() ->
|
||||||
, git_url => "https://github.com/emqx/emqx-plugin-template.git"
|
, git_url => "https://github.com/emqx/emqx-plugin-template.git"
|
||||||
, vsn => ?EMQX_PLUGIN_TEMPLATE_VSN
|
, vsn => ?EMQX_PLUGIN_TEMPLATE_VSN
|
||||||
, workdir => "demo_src"
|
, workdir => "demo_src"
|
||||||
|
, shdir => emqx_plugins:install_dir()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
build_demo_plugin_package(#{ target_path := TargetPath
|
build_demo_plugin_package(#{ target_path := TargetPath
|
||||||
|
@ -70,8 +71,8 @@ build_demo_plugin_package(#{ target_path := TargetPath
|
||||||
, git_url := GitUrl
|
, git_url := GitUrl
|
||||||
, vsn := PluginVsn
|
, vsn := PluginVsn
|
||||||
, workdir := DemoWorkDir
|
, workdir := DemoWorkDir
|
||||||
|
, shdir := WorkDir
|
||||||
} = Opts) ->
|
} = Opts) ->
|
||||||
WorkDir = emqx_plugins:install_dir(),
|
|
||||||
BuildSh = filename:join([WorkDir, "build-demo-plugin.sh"]),
|
BuildSh = filename:join([WorkDir, "build-demo-plugin.sh"]),
|
||||||
Cmd = string:join([ BuildSh
|
Cmd = string:join([ BuildSh
|
||||||
, PluginVsn
|
, PluginVsn
|
||||||
|
@ -333,6 +334,7 @@ t_elixir_plugin({init, Config}) ->
|
||||||
, git_url => "https://github.com/emqx/emqx-elixir-plugin.git"
|
, git_url => "https://github.com/emqx/emqx-elixir-plugin.git"
|
||||||
, vsn => ?EMQX_ELIXIR_PLUGIN_TEMPLATE_VSN
|
, vsn => ?EMQX_ELIXIR_PLUGIN_TEMPLATE_VSN
|
||||||
, workdir => "demo_src_elixir"
|
, workdir => "demo_src_elixir"
|
||||||
|
, shdir => emqx_plugins:install_dir()
|
||||||
},
|
},
|
||||||
Opts = #{package := Package} = build_demo_plugin_package(Opts0),
|
Opts = #{package := Package} = build_demo_plugin_package(Opts0),
|
||||||
NameVsn = filename:basename(Package, ?PACKAGE_SUFFIX),
|
NameVsn = filename:basename(Package, ?PACKAGE_SUFFIX),
|
||||||
|
|
Loading…
Reference in New Issue