aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rlx_archive_SUITE.erl22
-rw-r--r--test/rlx_command_SUITE.erl16
-rw-r--r--test/rlx_depsolver_tester.erl500
-rw-r--r--test/rlx_depsolver_tests.erl2
-rw-r--r--test/rlx_discover_SUITE.erl2
-rw-r--r--test/rlx_eunit_SUITE.erl2
-rw-r--r--test/rlx_extended_bin_SUITE.erl152
-rw-r--r--test/rlx_prv_release_alias.erl27
-rw-r--r--test/rlx_release_SUITE.erl156
9 files changed, 562 insertions, 317 deletions
diff --git a/test/rlx_archive_SUITE.erl b/test/rlx_archive_SUITE.erl
index 5122c11..8d30915 100644
--- a/test/rlx_archive_SUITE.erl
+++ b/test/rlx_archive_SUITE.erl
@@ -18,7 +18,7 @@
-include_lib("kernel/include/file.hrl").
suite() ->
- [{timetrap, {seconds, 30}}].
+ [{timetrap, {seconds, 120}}].
init_per_suite(Config) ->
Config.
@@ -55,11 +55,19 @@ basic_tar(Config) ->
rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+ SysConfigSrc = filename:join([LibDir1, "config", "sys.config.src"]),
+ rlx_test_utils:write_config(SysConfigSrc, [{this_is_a_test, "yup it is"}]),
+
+ VmArgsSrc = filename:join([LibDir1, "config", "vm.args.src"]),
+ ec_file:write(VmArgsSrc, ""),
+
ConfigFile = filename:join([LibDir1, "relx.config"]),
rlx_test_utils:write_config(ConfigFile,
[{release, {foo, "0.0.1"},
[goal_app_1,
- goal_app_2]}]),
+ goal_app_2]},
+ {sys_config_src, SysConfigSrc},
+ {vm_args_src, VmArgsSrc}]),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
rlx_test_utils:create_random_name("relx-output")]),
{ok, State} = relx:do([{relname, foo},
@@ -84,6 +92,16 @@ basic_tar(Config) ->
{ok, Files} = erl_tar:table(TarFile, [compressed]),
?assert(lists:any(fun(X) -> re:run(X, "lib/stdlib-.*/ebin/.*") =/= nomatch end, Files)),
?assert(lists:any(fun(X) -> re:run(X, "lib/kernel-.*/ebin/.*") =/= nomatch end, Files)),
+
+ %% only works in otp-21 and above
+ case erlang:system_info(otp_release) of
+ R when R =:= "21" orelse R =:= "22" ->
+ ?assert(lists:member("releases/0.0.1/vm.args.src", Files)),
+ ?assert(lists:member("releases/0.0.1/sys.config.src", Files));
+ _ ->
+ ok
+ end,
+
?assert(filelib:is_regular(TarFile)).
exclude_erts(Config) ->
diff --git a/test/rlx_command_SUITE.erl b/test/rlx_command_SUITE.erl
index e0beec1..8dd2da8 100644
--- a/test/rlx_command_SUITE.erl
+++ b/test/rlx_command_SUITE.erl
@@ -27,13 +27,14 @@
lib_expansion_case/1,
lib_fail_case/1,
spec_parse_fail_case/1,
- config_fail_case/1]).
+ config_fail_case/1,
+ provider_case/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
suite() ->
- [{timetrap,{seconds,30}}].
+ [{timetrap,{seconds,120}}].
init_per_suite(Config) ->
Config.
@@ -42,7 +43,7 @@ end_per_suite(_Config) ->
ok.
all() ->
- [normal_passing_case, lib_expansion_case, lib_fail_case, config_fail_case].
+ [normal_passing_case, lib_expansion_case, lib_fail_case, config_fail_case, provider_case].
normal_passing_case(Config) ->
DataDir = filename:join(proplists:get_value(priv_dir, Config), ?MODULE),
@@ -111,3 +112,12 @@ config_fail_case(_Config) ->
{ok, {Opts, Targets}} = getopt:parse(relx:opt_spec_list(), CmdLine),
?assertMatch({error, {_, {invalid_config_file, ConfigFile}}},
rlx_cmd_args:args2state(Opts, Targets)).
+
+provider_case(_Config) ->
+ CmdLine = ["--provider", "relx_provider_1",
+ "--provider", "relx_provider_2"],
+ {ok, {Opts, Targets}} = getopt:parse(relx:opt_spec_list(), CmdLine),
+ {ok, State} = rlx_cmd_args:args2state(Opts, Targets),
+ ?assertEqual(
+ [relx_provider_1, relx_provider_2],
+ proplists:get_value(add_providers, rlx_state:cli_args(State))).
diff --git a/test/rlx_depsolver_tester.erl b/test/rlx_depsolver_tester.erl
index 9defd91..b3bc146 100644
--- a/test/rlx_depsolver_tester.erl
+++ b/test/rlx_depsolver_tester.erl
@@ -1,5 +1,5 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 92 -*-
-%% ex: ts=4 sx=4 et
+%% ex: ts=4 sw=4 et
%%-------------------------------------------------------------------
%%
%% Copyright 2012 Opscode, Inc. All Rights Reserved.
@@ -49,153 +49,167 @@ run_log(FileName) ->
run_log_file(Device).
data1_test() ->
- ExpectedResult = versionify([{"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg1","0.0.2"},
+ ExpectedResult = versionify([
+ {"app9","0.0.1"},
{"dep_pkg7","0.1.2"},
- {"app9","0.0.1"}]),
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg2","0.0.5"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"}
+ ]),
?assertMatch({ok, ExpectedResult},
run_data(fix_rebar_brokenness("data1.txt"))).
data2_test() ->
- ExpectedResult = versionify([{"app18","0.0.1"},
- {"app4","0.0.7"},
- {"app1","0.0.1"},
- {"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg5","0.0.3"},
- {"dep_pkg1","0.0.2"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg7","0.1.2"},
+ ExpectedResult = versionify([
+ {"dep_pkg16","1.0.2"},
{"app9","0.0.1"},
- {"dep_pkg16","1.0.2"}]),
+ {"dep_pkg7","0.1.2"},
+ {"dep_pkg2","0.0.5"},
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg5","0.0.3"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"},
+ {"app1","0.0.1"},
+ {"app4","0.0.7"},
+ {"app18","0.0.1"}
+ ]),
?assertMatch({ok, ExpectedResult},
run_data(fix_rebar_brokenness("data2.txt"))).
-
+
data3_test() ->
- ExpectedResult = versionify([{"app68","0.0.1"},
- {"app58","0.0.1"},
- {"app48","0.0.7"},
- {"app38","0.0.1"},
- {"app28","0.0.1"},
- {"app18","0.0.1"},
- {"app4","0.0.7"},
- {"app1","0.0.1"},
- {"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg5","0.0.3"},
- {"dep_pkg1","0.0.2"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg7","0.1.2"},
+ ExpectedResult = versionify([
+ {"dep_pkg16","1.0.2"},
{"app9","0.0.1"},
- {"dep_pkg16","1.0.2"}]),
+ {"dep_pkg7","0.1.2"},
+ {"dep_pkg2","0.0.5"},
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg5","0.0.3"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"},
+ {"app1","0.0.1"},
+ {"app4","0.0.7"},
+ {"app18","0.0.1"},
+ {"app28","0.0.1"},
+ {"app38","0.0.1"},
+ {"app48","0.0.7"},
+ {"app58","0.0.1"},
+ {"app68","0.0.1"}
+ ]),
?assertMatch({ok,ExpectedResult}, run_data(fix_rebar_brokenness("data3.txt"))).
data4_test() ->
- ExpectedResult = versionify([{"dep_pkg20","0.0.2"},
- {"app78","0.0.1"},
- {"app68","0.0.1"},
- {"app58","0.0.1"},
- {"app48","0.0.7"},
- {"app38","0.0.1"},
- {"app28","0.0.1"},
- {"app18","0.0.1"},
- {"app4","0.0.7"},
- {"app1","0.0.1"},
- {"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg5","0.0.3"},
- {"dep_pkg1","0.0.2"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg7","0.1.2"},
+ ExpectedResult = versionify([
+ {"dep_pkg16","1.0.2"},
{"app9","0.0.1"},
- {"dep_pkg16","1.0.2"}]),
+ {"dep_pkg7","0.1.2"},
+ {"dep_pkg2","0.0.5"},
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg5","0.0.3"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"},
+ {"app1","0.0.1"},
+ {"app4","0.0.7"},
+ {"app18","0.0.1"},
+ {"app28","0.0.1"},
+ {"app38","0.0.1"},
+ {"app48","0.0.7"},
+ {"app58","0.0.1"},
+ {"app68","0.0.1"},
+ {"app78","0.0.1"},
+ {"dep_pkg20","0.0.2"}
+ ]),
?assertMatch({ok, ExpectedResult},
run_data(fix_rebar_brokenness("data4.txt"))).
data5_test() ->
- ExpectedResult = versionify([{"dep_pkg14","0.0.2"},
- {"dep_pkg22","0.0.2"},
- {"dep_pkg20","0.0.2"},
- {"app78","0.0.1"},
- {"app68","0.0.1"},
- {"app58","0.0.1"},
- {"app48","0.0.7"},
- {"app38","0.0.1"},
- {"app28","0.0.1"},
- {"app18","0.0.1"},
- {"app4","0.0.7"},
- {"app1","0.0.1"},
- {"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg5","0.0.3"},
- {"dep_pkg1","0.0.2"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg7","0.1.2"},
+ ExpectedResult = versionify([
+ {"dep_pkg16","1.0.2"},
{"app9","0.0.1"},
- {"dep_pkg16","1.0.2"}]),
+ {"dep_pkg7","0.1.2"},
+ {"dep_pkg2","0.0.5"},
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg5","0.0.3"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"},
+ {"app1","0.0.1"},
+ {"app4","0.0.7"},
+ {"app18","0.0.1"},
+ {"app28","0.0.1"},
+ {"app38","0.0.1"},
+ {"app48","0.0.7"},
+ {"app58","0.0.1"},
+ {"app68","0.0.1"},
+ {"app78","0.0.1"},
+ {"dep_pkg20","0.0.2"},
+ {"dep_pkg22","0.0.2"},
+ {"dep_pkg14","0.0.2"}
+ ]),
?assertMatch({ok, ExpectedResult},
run_data(fix_rebar_brokenness("data5.txt"))).
data6_test() ->
- ExpectedResult = versionify([{"app108","0.0.1"},
- {"app98","0.0.1"},
- {"app88","0.0.1"},
- {"dep_pkg14","0.0.2"},
- {"dep_pkg22","0.0.2"},
- {"dep_pkg20","0.0.2"},
- {"app78","0.0.1"},
- {"app68","0.0.1"},
- {"app58","0.0.1"},
- {"app48","0.0.7"},
- {"app38","0.0.1"},
- {"app28","0.0.1"},
- {"app18","0.0.1"},
- {"app4","0.0.7"},
- {"app1","0.0.1"},
- {"app6","0.0.1"},
- {"dep_pkg13","0.0.2"},
- {"app13","0.0.1"},
- {"dep_pkg5","0.0.3"},
- {"dep_pkg1","0.0.2"},
- {"dep_pkg2","0.0.5"},
- {"dep_pkg7","0.1.2"},
+ ExpectedResult = versionify([
+ {"dep_pkg16","1.0.2"},
{"app9","0.0.1"},
- {"dep_pkg16","1.0.2"}]),
+ {"dep_pkg7","0.1.2"},
+ {"dep_pkg2","0.0.5"},
+ {"dep_pkg1","0.0.2"},
+ {"dep_pkg5","0.0.3"},
+ {"app13","0.0.1"},
+ {"dep_pkg13","0.0.2"},
+ {"app6","0.0.1"},
+ {"app1","0.0.1"},
+ {"app4","0.0.7"},
+ {"app18","0.0.1"},
+ {"app28","0.0.1"},
+ {"app38","0.0.1"},
+ {"app48","0.0.7"},
+ {"app58","0.0.1"},
+ {"app68","0.0.1"},
+ {"app78","0.0.1"},
+ {"dep_pkg20","0.0.2"},
+ {"dep_pkg22","0.0.2"},
+ {"dep_pkg14","0.0.2"},
+ {"app88","0.0.1"},
+ {"app98","0.0.1"},
+ {"app108","0.0.1"}
+ ]),
?assertMatch({ok, ExpectedResult},
run_data(fix_rebar_brokenness("data6.txt"))).
log_07be9e47_test() ->
Data = run_log(fix_rebar_brokenness("log-07be9e47-6f42-4a5d-b8b5-1d2eae1ad83b.txt")),
- ExpectedResult = versionify([{"0","0"},
- {"1","0"},
- {"3","0"},
- {"4","0"},
- {"5","0"},
- {"6","0"},
- {"7","0"},
- {"8","0"},
- {"9","0"},
- {"10","0"},
- {"11","0"},
- {"12","0"},
- {"13","0"},
- {"14","0"},
- {"15","0"},
- {"16","0"},
- {"18","0"},
- {"19","0"},
- {"21","0"},
- {"22","0"},
- {"23","0"},
+ ExpectedResult = versionify([
+ {"25","0"},
{"24","0"},
- {"25","0"}]),
+ {"23","0"},
+ {"22","0"},
+ {"21","0"},
+ {"19","0"},
+ {"18","0"},
+ {"16","0"},
+ {"15","0"},
+ {"14","0"},
+ {"13","0"},
+ {"12","0"},
+ {"11","0"},
+ {"10","0"},
+ {"9","0"},
+ {"8","0"},
+ {"7","0"},
+ {"6","0"},
+ {"5","0"},
+ {"4","0"},
+ {"3","0"},
+ {"1","0"},
+ {"0","0"}
+ ]),
?assertMatch({ok, ExpectedResult},
Data).
@@ -206,144 +220,152 @@ log_183998c1_test() ->
log_311a15e7_test() ->
{ok, Data} = run_log(fix_rebar_brokenness("log-311a15e7-3378-4c5b-beb7-86a1b9cf0ea9.txt")),
- ExpectedResult = lists:sort(versionify([{"45", "22"},
- {"40","1"},
- {"3","5"},
- {"9","0"},
- {"8","0"},
- {"7","0"},
- {"6","2"},
- {"1","5"},
- {"0","2"},
- {"61","1"},
- {"60","0"},
- {"35","4"},
- {"39","0"},
- {"38","2"},
- {"37","2"},
- {"36","3"},
- {"32","24"},
- {"30","0"},
- {"19","1"},
- {"18","0"},
- {"17","2"},
- {"16","0"},
- {"15","0"},
- {"14","1"},
- {"13","0"},
- {"12","1"},
- {"11","0"},
- {"10","1"},
- {"59","0"},
- {"58","1"},
- {"57","0"},
- {"56","0"},
- {"55","4"},
- {"29","2"},
- {"27","2"},
- {"26","0"},
- {"25","5"},
- {"24","3"},
- {"23","1"},
- {"22","3"},
+ ExpectedResult = lists:sort(versionify([
+ {"20","0"},
{"21","2"},
- {"20","0"}])),
+ {"22","3"},
+ {"23","1"},
+ {"24","3"},
+ {"25","5"},
+ {"26","0"},
+ {"27","2"},
+ {"29","2"},
+ {"55","4"},
+ {"56","0"},
+ {"57","0"},
+ {"58","1"},
+ {"59","0"},
+ {"10","1"},
+ {"11","0"},
+ {"12","1"},
+ {"13","0"},
+ {"14","1"},
+ {"15","0"},
+ {"16","0"},
+ {"17","2"},
+ {"18","0"},
+ {"19","1"},
+ {"30","0"},
+ {"32","24"},
+ {"36","3"},
+ {"37","2"},
+ {"38","2"},
+ {"39","0"},
+ {"35","4"},
+ {"60","0"},
+ {"61","1"},
+ {"0","2"},
+ {"1","5"},
+ {"6","2"},
+ {"7","0"},
+ {"8","0"},
+ {"9","0"},
+ {"3","5"},
+ {"40","1"},
+ {"45", "22"}
+ ])),
?assertMatch(ExpectedResult, lists:sort(Data)).
log_382cfe5b_test() ->
{ok, Data} =
run_log(fix_rebar_brokenness("log-382cfe5b-0ac2-48b8-83d1-717cb4620990.txt")),
- ExpectedResult = lists:sort(versionify([{"18","0"},
- {"17","0"},
- {"15","1"},
- {"14","0"},
- {"10","0"},
- {"7","0"},
- {"6","0"},
- {"5","0"},
- {"4","0"},
- {"3","0"},
- {"2","1"},
+ ExpectedResult = lists:sort(versionify([
+ {"0","0"},
{"1","0"},
- {"0","0"}])),
+ {"2","1"},
+ {"3","0"},
+ {"4","0"},
+ {"5","0"},
+ {"6","0"},
+ {"7","0"},
+ {"10","0"},
+ {"14","0"},
+ {"15","1"},
+ {"17","0"},
+ {"18","0"}
+ ])),
?assertMatch(ExpectedResult, lists:sort(Data)).
log_d3564ef6_test() ->
{ok, Data} = run_log(fix_rebar_brokenness("log-d3564ef6-6437-41e7-90b6-dbdb849551a6_mod.txt")),
- ExpectedResult = lists:sort(versionify([{"57","5"},
- {"56","3"},
- {"55","4"},
- {"54","0"},
- {"53","1"},
- {"82","0"},
- {"81","0"},
- {"80","1"},
- {"29","0"},
- {"28","5"},
- {"27","3"},
- {"26","1"},
- {"25","3"},
- {"24","2"},
- {"23","0"},
- {"22","1"},
- {"21","0"},
- {"20","2"},
- {"75","32"},
- {"79","2"},
- {"78","4"},
- {"74","7"},
- {"73","11"},
- {"72","0"},
- {"70","1"},
- {"47","4"},
- {"45","1"},
- {"44","1"},
- {"43","7"},
- {"42","1"},
- {"41","2"},
- {"40","2"},
- {"19","0"},
- {"18","0"},
- {"17","1"},
- {"16","0"},
- {"15","1"},
- {"14","0"},
- {"13","1"},
- {"12","0"},
- {"11","0"},
- {"10","0"},
- {"9","2"},
- {"4","5"},
- {"3","2"},
- {"0","3"},
- {"69","0"},
- {"68","1"},
- {"67","7"},
- {"39","3"},
- {"35","24"},
- {"33","0"},
+ ExpectedResult = lists:sort(versionify([
+ {"30","2"},
{"32","2"},
- {"30","2"}])),
+ {"33","0"},
+ {"35","24"},
+ {"39","3"},
+ {"67","7"},
+ {"68","1"},
+ {"69","0"},
+ {"0","3"},
+ {"3","2"},
+ {"4","5"},
+ {"9","2"},
+ {"10","0"},
+ {"11","0"},
+ {"12","0"},
+ {"13","1"},
+ {"14","0"},
+ {"15","1"},
+ {"16","0"},
+ {"17","1"},
+ {"18","0"},
+ {"19","0"},
+ {"40","2"},
+ {"41","2"},
+ {"42","1"},
+ {"43","7"},
+ {"44","1"},
+ {"45","1"},
+ {"47","4"},
+ {"70","1"},
+ {"72","0"},
+ {"73","11"},
+ {"74","7"},
+ {"78","4"},
+ {"79","2"},
+ {"75","32"},
+ {"20","2"},
+ {"21","0"},
+ {"22","1"},
+ {"23","0"},
+ {"24","2"},
+ {"25","3"},
+ {"26","1"},
+ {"27","3"},
+ {"28","5"},
+ {"29","0"},
+ {"80","1"},
+ {"81","0"},
+ {"82","0"},
+ {"53","1"},
+ {"54","0"},
+ {"55","4"},
+ {"56","3"},
+ {"57","5"}
+ ])),
?assertMatch(ExpectedResult, lists:sort(Data)).
log_ea2d264b_test() ->
{ok, Data} = run_log(fix_rebar_brokenness("log-ea2d264b-003e-4611-94ed-14efc7732083.txt")),
- ExpectedResult = lists:sort(versionify([{"18","1"},
- {"17","0"},
- {"16","0"},
- {"15","0"},
- {"14","0"},
- {"13","1"},
- {"10","1"},
- {"9","1"},
- {"8","2"},
- {"6","0"},
- {"5","0"},
- {"4","0"},
- {"3","0"},
- {"2","0"},
+ ExpectedResult = lists:sort(versionify([
+ {"0","1"},
{"1","0"},
- {"0","1"}])),
+ {"2","0"},
+ {"3","0"},
+ {"4","0"},
+ {"5","0"},
+ {"6","0"},
+ {"8","2"},
+ {"9","1"},
+ {"10","1"},
+ {"13","1"},
+ {"14","0"},
+ {"15","0"},
+ {"16","0"},
+ {"17","0"},
+ {"18","1"}
+ ])),
?assertMatch(ExpectedResult, lists:sort(Data)).
%%============================================================================
diff --git a/test/rlx_depsolver_tests.erl b/test/rlx_depsolver_tests.erl
index 206bad4..b1c8228 100644
--- a/test/rlx_depsolver_tests.erl
+++ b/test/rlx_depsolver_tests.erl
@@ -1,5 +1,5 @@
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*-
-%% ex: ts=4 sx=4 et
+%% ex: ts=4 sw=4 et
%%
%%-------------------------------------------------------------------
%% Copyright 2012 Opscode, Inc. All Rights Reserved.
diff --git a/test/rlx_discover_SUITE.erl b/test/rlx_discover_SUITE.erl
index 36d77ae..9385229 100644
--- a/test/rlx_discover_SUITE.erl
+++ b/test/rlx_discover_SUITE.erl
@@ -34,7 +34,7 @@
-include_lib("eunit/include/eunit.hrl").
suite() ->
- [{timetrap,{seconds,30}}].
+ [{timetrap,{seconds,120}}].
init_per_suite(Config) ->
Config.
diff --git a/test/rlx_eunit_SUITE.erl b/test/rlx_eunit_SUITE.erl
index 874e5a6..c7c0751 100644
--- a/test/rlx_eunit_SUITE.erl
+++ b/test/rlx_eunit_SUITE.erl
@@ -30,7 +30,7 @@
-include_lib("eunit/include/eunit.hrl").
suite() ->
- [{timetrap,{seconds,30}}].
+ [{timetrap,{seconds,120}}].
init_per_suite(Config) ->
Config.
diff --git a/test/rlx_extended_bin_SUITE.erl b/test/rlx_extended_bin_SUITE.erl
index d8e74f2..710d2c4 100644
--- a/test/rlx_extended_bin_SUITE.erl
+++ b/test/rlx_extended_bin_SUITE.erl
@@ -49,6 +49,7 @@
replace_os_vars_dev_mode/1,
replace_os_vars_twice/1,
custom_start_script_hooks/1,
+ custom_start_script_hooks_console/1,
builtin_wait_for_vm_start_script_hook/1,
builtin_pid_start_script_hook/1,
builtin_wait_for_process_start_script_hook/1,
@@ -62,8 +63,10 @@
-include_lib("eunit/include/eunit.hrl").
-include_lib("kernel/include/file.hrl").
+-define(SLEEP_TIME, 2500).
+
suite() ->
- [{timetrap,{seconds,30}}].
+ [{timetrap,{seconds,300}}].
init_per_suite(Config) ->
Config.
@@ -83,12 +86,13 @@ init_per_testcase(_, Config) ->
all() ->
[start_sname_in_other_argsfile, start_preserves_arguments, start_nodetool_with_data_from_argsfile,
start_upgrade_escript_with_argsfile_data, start_fail_when_no_name, start_fail_when_multiple_names,
- start_fail_when_missing_argsfile, start_fail_when_nonreadable_argsfile,
+ start_fail_when_missing_argsfile, %% start_fail_when_nonreadable_argsfile,
start_fail_when_relative_argsfile, start_fail_when_circular_argsfiles,
ping, shortname_ping, longname_ping, attach, pid, restart, reboot, escript,
remote_console, shortname_remote_console, replace_os_vars, replace_os_vars_sys_config_vm_args_src, replace_os_vars_multi_node,
replace_os_vars_included_config,
- replace_os_vars_custom_location, replace_os_vars_dev_mode, replace_os_vars_twice, custom_start_script_hooks,
+ replace_os_vars_custom_location, replace_os_vars_dev_mode, replace_os_vars_twice,
+ custom_start_script_hooks, custom_start_script_hooks_console,
builtin_wait_for_vm_start_script_hook, builtin_pid_start_script_hook,
builtin_wait_for_process_start_script_hook, mixed_custom_and_builtin_start_script_hooks,
builtin_status_script, custom_status_script,
@@ -122,7 +126,7 @@ ping(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -145,7 +149,7 @@ shortname_ping(Config) ->
{extended_start_script, true}
]),
- ec_file:write(VmArgs, "-sname foo\n\n"
+ ec_file:write(VmArgs, "-sname foo@localhost\n\n"
"-setcookie cookie\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -161,7 +165,7 @@ shortname_ping(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -184,7 +188,7 @@ longname_ping(Config) ->
{extended_start_script, true}
]),
- ec_file:write(VmArgs, "-name foo\n\n"
+ ec_file:write(VmArgs, "-name [email protected]\n\n"
"-setcookie cookie\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -200,7 +204,7 @@ longname_ping(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -233,10 +237,10 @@ attach(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo attach", "&"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
{error, 1, _} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])).
@@ -267,7 +271,7 @@ pid(Config) ->
%% check for a valid pid
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _Pid} = sh(filename:join([OutputDir, "foo", "bin", "foo pid"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
@@ -301,11 +305,11 @@ restart(Config) ->
%% a restart is a gracious operation that does not involve the
%% death of the VM, so the pid should be the same
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, Pid1} = sh(filename:join([OutputDir, "foo", "bin", "foo pid"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo restart"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, Pid2} = sh(filename:join([OutputDir, "foo", "bin", "foo pid"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
{error, 1, _} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
@@ -339,13 +343,13 @@ reboot(Config) ->
%% a reboot involves stopping the emulator, it needs to be restarted
%% though
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, Pid1} = sh(filename:join([OutputDir, "foo", "bin", "foo pid"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo reboot"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, Pid2} = sh(filename:join([OutputDir, "foo", "bin", "foo pid"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
{error, 1, _} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
@@ -381,7 +385,7 @@ escript(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
[ExpectedOutput] = io_lib:format("~s",
[filename:join([OutputDir, "foo"])]),
@@ -415,10 +419,10 @@ remote_console(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo remote_console &"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, NodesStr} = sh(filename:join([OutputDir, "foo", "bin", "foo eval 'nodes(connected).'"])),
Nodes = rlx_test_utils:list_to_term(NodesStr),
?assertEqual(1, length(Nodes)),
@@ -432,7 +436,7 @@ shortname_remote_console(Config) ->
ConfigFile = filename:join([LibDir1, "relx.config"]),
VmArgs = filename:join([LibDir1, "vm.args"]),
- ec_file:write(VmArgs, "-sname foo\n\n"
+ ec_file:write(VmArgs, "-sname foo@localhost\n\n"
"-setcookie cookie\n"),
rlx_test_utils:write_config(ConfigFile,
@@ -457,10 +461,10 @@ shortname_remote_console(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo remote_console &"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, NodesStr} = sh(filename:join([OutputDir, "foo", "bin", "foo eval 'nodes(connected).'"])),
Nodes = rlx_test_utils:list_to_term(NodesStr),
?assertEqual(1, length(Nodes)),
@@ -489,7 +493,7 @@ replace_os_vars(Config) ->
[[{goal_app,
[{var1, "${VAR1}"},
{var2, "${VAR2}"}]}]]),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -508,7 +512,7 @@ replace_os_vars(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node1"},
@@ -547,7 +551,7 @@ replace_os_vars(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "v2"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node2"},
@@ -604,7 +608,7 @@ replace_os_vars_sys_config_vm_args_src(Config) ->
%% new with sys.config.src it doesn't have to be valid Erlang
%% until after var replacemen at runtime.
ec_file:write(SysConfigSrc, "[{goal_app, [{var1, ${VAR1}}]}]."),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -623,7 +627,7 @@ replace_os_vars_sys_config_vm_args_src(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "101"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node1"},
@@ -662,7 +666,7 @@ replace_os_vars_sys_config_vm_args_src(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "201"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node2"},
@@ -717,7 +721,7 @@ replace_os_vars_multi_node(Config) ->
rlx_test_utils:write_config(SysConfig,
[[{goal_app, [{var1, "${VAR1}"}]}]]),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -737,7 +741,7 @@ replace_os_vars_multi_node(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"RELX_MULTI_NODE", "1"},
@@ -785,7 +789,7 @@ replace_os_vars_multi_node(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "v2"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"RELX_MULTI_NODE", "1"},
@@ -862,7 +866,7 @@ replace_os_vars_included_config(Config) ->
},
"releases/0.0.1/config/included.config"]
]),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -881,7 +885,7 @@ replace_os_vars_included_config(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node1"},
@@ -920,7 +924,7 @@ replace_os_vars_included_config(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "v2"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node2"},
@@ -975,7 +979,7 @@ replace_os_vars_custom_location(Config) ->
rlx_test_utils:write_config(SysConfig,
[[{goal_app, [{var1, "${VAR1}"}]}]]),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -995,7 +999,7 @@ replace_os_vars_custom_location(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"RELX_OUT_FILE_PATH", "/tmp"},
@@ -1041,7 +1045,7 @@ replace_os_vars_custom_location(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "v2"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"RELX_OUT_FILE_PATH", "/tmp"},
@@ -1102,7 +1106,7 @@ replace_os_vars_twice(Config) ->
rlx_test_utils:write_config(SysConfig,
[[{goal_app, [{var1, "${VAR1}"}]}]]),
- ec_file:write(VmArgs, "-sname node\n\n"
+ ec_file:write(VmArgs, "-sname node@localhost\n\n"
"-setcookie cookie\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -1119,7 +1123,7 @@ replace_os_vars_twice(Config) ->
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"}]),
{ok, "\"v1\""} = sh(filename:join([OutputDir, "foo", "bin",
@@ -1142,7 +1146,7 @@ replace_os_vars_twice(Config) ->
%% start the node again but this time don't replace env variables
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, "\"${VAR1}\""} = sh(filename:join([OutputDir, "foo", "bin",
"foo eval '{ok, V} = application:get_env(goal_app, var1), V.'"])),
@@ -1175,7 +1179,7 @@ replace_os_vars_dev_mode(Config) ->
rlx_test_utils:write_config(SysConfig,
[[{goal_app, [{var1, "${VAR1}"}]}]]),
- ec_file:write(VmArgs, "-sname ${NODENAME}\n\n"
+ ec_file:write(VmArgs, "-sname ${NODENAME}@localhost\n\n"
"-setcookie ${COOKIE}\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -1194,7 +1198,7 @@ replace_os_vars_dev_mode(Config) ->
{"NODENAME", "node1"},
{"COOKIE", "cookie1"},
{"VAR1", "v1"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node1"},
@@ -1233,7 +1237,7 @@ replace_os_vars_dev_mode(Config) ->
{"NODENAME", "node2"},
{"COOKIE", "cookie2"},
{"VAR1", "v2"}]),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"]),
[{"RELX_REPLACE_OS_VARS", "1"},
{"NODENAME", "node2"},
@@ -1315,7 +1319,7 @@ custom_start_script_hooks(Config) ->
%% now start/stop the release to make sure the script hooks are really getting
%% executed
os:cmd(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
os:cmd(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% now check that the output file contains the expected format
{ok,[{pre_start, foo, _, foo},
@@ -1356,6 +1360,42 @@ builtin_pid_start_script_hook(Config) ->
os:cmd(filename:join([OutputDir, "foo", "bin", "foo stop"])),
ok.
+custom_start_script_hooks_console(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+
+ rlx_test_utils:create_app(LibDir1, "goal_app", "0.0.1", [stdlib,kernel], []),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+ rlx_test_utils:write_config(ConfigFile,
+ [{release, {foo, "0.0.1"},
+ [goal_app]},
+ {lib_dirs, [filename:join(LibDir1, "*")]},
+ {generate_start_script, true},
+ {extended_start_script, true},
+ {extended_start_script_hooks, [
+ {pre_start, [
+ {custom, "hooks/pre_start"}
+ ]}
+ ]},
+ {mkdir, "scripts"},
+ {overlay, [{copy, "./pre_start", "bin/hooks/pre_start"}]}
+ ]),
+
+ %% write the hook scripts, each of them will write an erlang term to a file
+ %% that will later be consulted
+ ok = file:write_file(filename:join([LibDir1, "./pre_start"]),
+ "#!/bin/bash\n# $*\necho \\{pre_start, $REL_NAME, \\'$NAME\\', $COOKIE\\}. >> test"),
+
+ OutputDir = filename:join([proplists:get_value(priv_dir, Config),
+ rlx_test_utils:create_random_name("relx-output")]),
+ {ok, _State} = relx:do(foo, undefined, [], [LibDir1], 3,
+ OutputDir, ConfigFile),
+ %% now start/stop the release to make sure the script hooks are really getting
+ %% executed
+ {ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo console &"])),
+ %% now check that the output file contains the expected format
+ {ok,[{pre_start, foo, _, foo}]} = file:consult(filename:join([OutputDir, "foo", "test"])).
+
builtin_wait_for_vm_start_script_hook(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
@@ -1382,7 +1422,7 @@ builtin_wait_for_vm_start_script_hook(Config) ->
os:cmd(filename:join([OutputDir, "foo", "bin", "foo start"])),
% this run doesn't need the sleep because the wait_for_vm_start
% start script makes it unnecessary
- %timer:sleep(2000),
+ %timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
os:cmd(filename:join([OutputDir, "foo", "bin", "foo stop"])),
ok.
@@ -1518,7 +1558,7 @@ builtin_status_script(Config) ->
{ok, _State} = relx:do(foo, undefined, [], [LibDir1], 3,
OutputDir, ConfigFile),
os:cmd(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
%% write the status to a file
{ok, ""} = sh(filename:join([OutputDir, "foo", "bin", "foo status"])).
@@ -1555,7 +1595,7 @@ custom_status_script(Config) ->
{ok, _State} = relx:do(foo, undefined, [], [LibDir1], 3,
OutputDir, ConfigFile),
os:cmd(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
%% write the status to a file
{ok, StatusStr} = sh(filename:join([OutputDir, "foo", "bin", "foo status"])),
@@ -1585,7 +1625,7 @@ start_sname_in_other_argsfile(Config) ->
ec_file:write(VmArgs, "-args_file " ++ VmArgs2 ++ "\n\n"
"-setcookie cookie\n"),
- ec_file:write(VmArgs2, "-sname foo\n"),
+ ec_file:write(VmArgs2, "-sname foo@localhost\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
rlx_test_utils:create_random_name("relx-output")]),
@@ -1600,7 +1640,7 @@ start_sname_in_other_argsfile(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -1636,7 +1676,7 @@ start_preserves_arguments(Config) ->
%% and preserving the "tricky" argument that contains a string with a space
%% in it
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start -goal_app baz '\"bat zing\"'"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
BinFile = filename:join([PrivDir, "goal_app.bin"]),
Eval = io_lib:format("{ok,Env}=application:get_env(goal_app,baz),file:write_file(\"~s\",term_to_binary(Env)).",
[BinFile]),
@@ -1667,7 +1707,7 @@ start_nodetool_with_data_from_argsfile(Config) ->
]),
ec_file:write(VmArgs, "-setcookie cookie\n"
- "-sname foo\n\n"
+ "-sname foo@localhost\n\n"
"-proto_dist inet_tcp\n\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -1683,7 +1723,7 @@ start_nodetool_with_data_from_argsfile(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -1707,7 +1747,7 @@ start_upgrade_escript_with_argsfile_data(Config) ->
]),
ec_file:write(VmArgs, "-setcookie cookie\n"
- "-sname foo\n\n"
+ "-sname foo@localhost\n\n"
"-proto_dist inet_tcp\n\n"),
OutputDir = filename:join([proplists:get_value(priv_dir, Config),
@@ -1723,7 +1763,7 @@ start_upgrade_escript_with_argsfile_data(Config) ->
%% now start/stop the release to make sure the extended script is working
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, _Ver} = sh(filename:join([OutputDir, "foo", "bin", "foo versions"])),
{ok, _} = sh(filename:join([OutputDir, "foo", "bin", "foo stop"])),
%% a ping should fail after stopping a node
@@ -1755,7 +1795,7 @@ start_fail_when_nonreadable_argsfile(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
VmArgs = filename:join([LibDir1, "vm.args"]),
VmArgs2 = VmArgs ++ ".nonreadable",
- ec_file:write(VmArgs, "-name foo\n\n"
+ ec_file:write(VmArgs, "-name [email protected]\n\n"
"-args_file " ++ VmArgs2 ++ "\n\n"
"-setcookie cookie\n"),
ec_file:write(VmArgs2, ""),
@@ -1791,7 +1831,7 @@ extension_script(Config) ->
proplists:get_value(priv_dir, Config),
ExtensionScript),
os:cmd(filename:join([OutputDir, "foo", "bin", "foo start"])),
- timer:sleep(2000),
+ timer:sleep(?SLEEP_TIME),
{ok, "pong"} = sh(filename:join([OutputDir, "foo", "bin", "foo ping"])),
%% write the extension script output to a file
{ok, Str} = sh(filename:join([OutputDir, "foo", "bin", "foo bar"])),
diff --git a/test/rlx_prv_release_alias.erl b/test/rlx_prv_release_alias.erl
new file mode 100644
index 0000000..523940c
--- /dev/null
+++ b/test/rlx_prv_release_alias.erl
@@ -0,0 +1,27 @@
+-module(rlx_prv_release_alias).
+
+-behaviour(provider).
+
+-export([init/1, do/1, format_error/1]).
+
+-define(PROVIDER, test_release_alias).
+-define(DEPS, [app_discover]).
+
+%%============================================================================
+%% API
+%%============================================================================
+
+-spec init(rlx_state:t()) -> {ok, rlx_state:t()}.
+init(State) ->
+ State1 = rlx_state:add_provider(State, providers:create([{name, ?PROVIDER},
+ {module, ?MODULE},
+ {deps, ?DEPS}])),
+ {ok, State1}.
+
+-spec do(rlx_state:t()) -> {ok, rlx_state:t()} | relx:error().
+do(State) ->
+ rlx_prv_release:do(State).
+
+-spec format_error(ErrorDetail::term()) -> iolist().
+format_error(ErrorDetail) ->
+ rlx_prv_release:format_error(ErrorDetail).
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index eca5f78..a582526 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -25,7 +25,9 @@
init_per_testcase/2,
all/0,
providers/1,
+ providers_via_api_options/1,
add_providers/1,
+ add_providers_via_api_options/1,
make_release/1,
make_config_release/1,
make_extend_release/1,
@@ -40,6 +42,7 @@
make_implicit_config_release/1,
overlay_release/1,
make_goalless_release/1,
+ make_external_goal_release/1,
make_depfree_release/1,
make_invalid_config_release/1,
make_relup_release/1,
@@ -64,7 +67,7 @@
-include_lib("kernel/include/file.hrl").
suite() ->
- [{timetrap,{seconds,30}}].
+ [{timetrap,{seconds,120}}].
init_per_suite(Config) ->
Config.
@@ -82,19 +85,18 @@ init_per_testcase(_, Config) ->
{state, State1} | Config].
all() ->
- [providers, add_providers, make_release, make_config_release,
- make_extend_release, make_extend_config_release, make_scriptless_release,
- make_overridden_release, make_auto_skip_empty_app_release,
+ [providers, providers_via_api_options, add_providers, add_providers_via_api_options,
+ make_release, make_config_release, make_extend_release, make_extend_config_release,
+ make_scriptless_release, make_overridden_release, make_auto_skip_empty_app_release,
make_skip_app_release, make_exclude_app_release, make_app_type_none_release,
- make_implicit_config_release, make_rerun_overridden_release,
- overlay_release, make_goalless_release, make_depfree_release,
- make_invalid_config_release, make_relup_release, make_relup_release2,
- make_one_app_top_level_release, make_dev_mode_release, make_dev_mode_template_release,
- make_config_script_release, make_release_twice, make_release_twice_dev_mode,
- make_erts_release, make_erts_config_release,
- make_included_nodetool_release, make_not_included_nodetool_release,
- make_src_release, make_excluded_src_release, make_exclude_modules_release,
- make_release_with_sys_config_vm_args_src].
+ make_implicit_config_release, make_rerun_overridden_release, overlay_release,
+ make_goalless_release, make_external_goal_release, make_depfree_release, make_invalid_config_release,
+ make_relup_release, make_relup_release2, make_one_app_top_level_release,
+ make_dev_mode_release, make_dev_mode_template_release, make_config_script_release,
+ make_release_twice, make_release_twice_dev_mode, make_erts_release,
+ make_erts_config_release, make_included_nodetool_release,
+ make_not_included_nodetool_release, make_src_release, make_excluded_src_release,
+ make_exclude_modules_release, make_release_with_sys_config_vm_args_src].
add_providers(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
@@ -133,6 +135,52 @@ add_providers(Config) ->
?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+add_providers_via_api_options(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+
+ [(fun({Name, Vsn}) ->
+ rlx_test_utils:create_app(LibDir1, Name, Vsn, [kernel, stdlib], [])
+ end)(App)
+ ||
+ App <-
+ [{rlx_test_utils:create_random_name("lib_app1_"), rlx_test_utils:create_random_vsn()}
+ || _ <- lists:seq(1, 100)]],
+
+ rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
+ rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
+ rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
+ rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+ rlx_test_utils:write_config(ConfigFile,
+ [{release, {foo, "0.0.1"},
+ [goal_app_1,
+ goal_app_2]}]),
+ OutputDir = filename:join([proplists:get_value(priv_dir, Config),
+ rlx_test_utils:create_random_name("relx-output")]),
+ {ok, Cwd} = file:get_cwd(),
+ Opts = [{relname, undefined},
+ {relvsn, undefined},
+ {goals, []},
+ {overrides, []},
+ {output_dir, OutputDir},
+ {lib_dirs, [LibDir1]},
+ {root_dir, Cwd},
+ {log_level, 3},
+ {config, ConfigFile},
+ {add_providers, [rlx_prv_release_alias]}],
+ {ok, State} = relx:do(Opts, ["test_release_alias"]),
+ [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rlx_state:realized_releases(State)),
+ AppSpecs = rlx_release:applications(Release),
+ ?assert(lists:keymember(stdlib, 1, AppSpecs)),
+ ?assert(lists:keymember(kernel, 1, AppSpecs)),
+ ?assert(lists:member({non_goal_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({non_goal_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+
providers(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
@@ -170,6 +218,52 @@ providers(Config) ->
?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+providers_via_api_options(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+
+ [(fun({Name, Vsn}) ->
+ rlx_test_utils:create_app(LibDir1, Name, Vsn, [kernel, stdlib], [])
+ end)(App)
+ ||
+ App <-
+ [{rlx_test_utils:create_random_name("lib_app1_"), rlx_test_utils:create_random_vsn()}
+ || _ <- lists:seq(1, 100)]],
+
+ rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
+ rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
+ rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
+ rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+ rlx_test_utils:write_config(ConfigFile,
+ [{release, {foo, "0.0.1"},
+ [goal_app_1,
+ goal_app_2]}]),
+ OutputDir = filename:join([proplists:get_value(priv_dir, Config),
+ rlx_test_utils:create_random_name("relx-output")]),
+ {ok, Cwd} = file:get_cwd(),
+ Opts = [{relname, undefined},
+ {relvsn, undefined},
+ {goals, []},
+ {overrides, []},
+ {output_dir, OutputDir},
+ {lib_dirs, [LibDir1]},
+ {root_dir, Cwd},
+ {log_level, 3},
+ {config, ConfigFile},
+ {providers, [rlx_prv_release_alias]}],
+ {ok, State} = relx:do(Opts, ["test_release_alias"]),
+ [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rlx_state:realized_releases(State)),
+ AppSpecs = rlx_release:applications(Release),
+ ?assert(lists:keymember(stdlib, 1, AppSpecs)),
+ ?assert(lists:keymember(kernel, 1, AppSpecs)),
+ ?assert(lists:member({non_goal_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({non_goal_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+
make_release(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
@@ -665,8 +759,10 @@ overlay_release(Config) ->
TestFileFull = filename:join(TestDirFull, TestFile),
SecondTestDir = "second_test_dir",
rlx_test_utils:write_config(ConfigFile,
- [{overlay_vars, [OverlayVars1, OverlayVars2, OverlayVars4]},
+ [{overlay_vars, [{var_list_dir, "non-file-variable-list"},
+ OverlayVars1, OverlayVars2, OverlayVars4]},
{overlay, [{mkdir, "{{target_dir}}/fooo"},
+ {mkdir, "{{target_dir}}/{{var_list_dir}}"},
{copy, OverlayVars1,
"{{target_dir}}/{{foo_dir}}/vars1.config"},
{copy, filename:join([LibDir1, "vars1*.config"]),
@@ -727,6 +823,7 @@ overlay_release(Config) ->
?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)),
+ ?assert(ec_file:exists(filename:join([OutputDir, "foo", "non-file-variable-list"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "fooo"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "foodir", "vars1.config"]))),
?assert(ec_file:exists(filename:join([OutputDir, "foo", "yahoo", "vars1.config"]))),
@@ -781,6 +878,37 @@ make_goalless_release(Config) ->
relx:do(undefined, undefined, [], [LibDir1], 3,
OutputDir, ConfigFile)).
+make_external_goal_release(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+
+ rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
+ rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [], []),
+ rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
+ rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+ rlx_test_utils:write_config(ConfigFile,
+ [{goals, [{goal_app_2, "0.0.1"}]},
+ {release, {foo, "0.0.1"},
+ [goal_app_1]}]),
+ OutputDir = filename:join([proplists:get_value(priv_dir, Config),
+ rlx_test_utils:create_random_name("relx-output")]),
+ {ok, State} = relx:do(undefined, undefined, [], [LibDir1], 3,
+ OutputDir, ConfigFile),
+ [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rlx_state:realized_releases(State)),
+ AppSpecs = rlx_release:applications(Release),
+ ?assert(lists:keymember(stdlib, 1, AppSpecs)),
+ ?assert(lists:keymember(kernel, 1, AppSpecs)),
+ ?assert(lists:member({non_goal_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({non_goal_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+
+
make_depfree_release(Config) ->
LibDir1 = proplists:get_value(lib1, Config),