aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rclt_release_SUITE.erl138
1 files changed, 125 insertions, 13 deletions
diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl
index 97f564e..90d99c9 100644
--- a/test/rclt_release_SUITE.erl
+++ b/test/rclt_release_SUITE.erl
@@ -35,6 +35,7 @@
make_depfree_release/1,
make_invalid_config_release/1,
make_relup_release/1,
+ make_relup_release2/1,
make_one_app_top_level_release/1]).
-include_lib("common_test/include/ct.hrl").
@@ -64,7 +65,7 @@ all() ->
make_skip_app_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_invalid_config_release, make_relup_release, make_relup_release2,
make_one_app_top_level_release].
make_release(Config) ->
@@ -564,24 +565,30 @@ make_relup_release(Config) ->
create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
create_app(LibDir1, "goal_app_1", "0.0.2", [stdlib,kernel,non_goal_1], []),
- create_app(LibDir1, "goal_app_1", "0.0.3", [stdlib,kernel,non_goal_1], []),
+ {ok, GA1} = create_app(LibDir1, "goal_app_1", "0.0.3", [stdlib,kernel,non_goal_1], []),
create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
create_app(LibDir1, "goal_app_2", "0.0.2", [stdlib,kernel,goal_app_1,non_goal_2], []),
- create_app(LibDir1, "goal_app_2", "0.0.3", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ {ok, GA2} = create_app(LibDir1, "goal_app_2", "0.0.3", [stdlib,kernel,goal_app_1,non_goal_2], []),
create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+ write_appup_file(GA1, "0.0.2"),
+ write_appup_file(GA2, "0.0.2"),
+
ConfigFile = filename:join([LibDir1, "relcool.config"]),
write_config(ConfigFile,
[{release, {foo, "0.0.1"},
- [{goal_app_1, "0.0.1"},
+ [sasl,
+ {goal_app_1, "0.0.1"},
{goal_app_2, "0.0.1"}]},
{release, {foo, "0.0.2"},
- [{goal_app_1, "0.0.2"},
+ [sasl,
+ {goal_app_1, "0.0.2"},
{goal_app_2, "0.0.2"}]},
{release, {foo, "0.0.3"},
- [{goal_app_1, "0.0.3"},
+ [sasl,
+ {goal_app_1, "0.0.3"},
{goal_app_2, "0.0.3"}]}]),
OutputDir = filename:join([proplists:get_value(data_dir, Config),
create_random_name("relcool-output")]),
@@ -589,20 +596,116 @@ make_relup_release(Config) ->
OutputDir, ConfigFile),
{ok, _} = relcool:do(foo, "0.0.2", [], [LibDir1], 2,
OutputDir, ConfigFile),
- {ok, State} = relcool:do(foo, "0.0.3", [], [LibDir1], 2,
- OutputDir, ConfigFile),
+ {ok, State} = relcool:do([{relname, foo},
+ {relvsn, "0.0.3"},
+ {goals, []},
+ {lib_dirs, [LibDir1]},
+ {log_level, 2},
+ {output_dir, OutputDir},
+ {config, ConfigFile}], ["relup"]),
+
+ %% we should have one 'resolved' release and three discovered realized_releases.
+ ?assertMatch([{foo, "0.0.1"},
+ {foo, "0.0.2"},
+ {foo, "0.0.3"}],
+ lists:sort(ec_dictionary:keys(rcl_state:realized_releases(State)))),
+ Release = ec_dictionary:get({foo, "0.0.3"}, rcl_state:realized_releases(State)),
+ ?assert(rcl_release:realized(Release)),
+ ?assert(not rcl_release:realized(ec_dictionary:get({foo, "0.0.2"},
+ rcl_state:realized_releases(State)))),
+ ?assert(not rcl_release:realized(ec_dictionary:get({foo, "0.0.1"},
+ rcl_state:realized_releases(State)))),
+
+ ?assertMatch({ok, [{"0.0.3",
+ [{"0.0.2",[],[point_of_no_return]}],
+ [{"0.0.2",[],[point_of_no_return]}]}]},
+ file:consult(filename:join(filename:dirname(rcl_release:relfile(Release)),
+ filename:basename(rcl_release:relfile(Release), ".rel") ++
+ ".relup"))),
+
+ ?assertMatch(foo, rcl_release:name(Release)),
+ ?assertMatch("0.0.3", rcl_release:vsn(Release)),
+ AppSpecs = rcl_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.3"}, AppSpecs)),
+ ?assert(lists:member({goal_app_2, "0.0.3"}, AppSpecs)),
+ ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+
+
+make_relup_release2(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+ [(fun({Name, Vsn}) ->
+ create_app(LibDir1, Name, Vsn, [kernel, stdlib], [])
+ end)(App)
+ ||
+ App <-
+ [{create_random_name("lib_app1_"), create_random_vsn()}
+ || _ <- lists:seq(1, 100)]],
- %% we should have one 'resolved' release and three discovered releases.
+ create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
+ create_app(LibDir1, "goal_app_1", "0.0.2", [stdlib,kernel,non_goal_1], []),
+ {ok, GA1} = create_app(LibDir1, "goal_app_1", "0.0.3", [stdlib,kernel,non_goal_1], []),
+ create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
+ create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ create_app(LibDir1, "goal_app_2", "0.0.2", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ {ok, GA2} = create_app(LibDir1, "goal_app_2", "0.0.3", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
+ create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+
+ write_appup_file(GA1, "0.0.1"),
+ write_appup_file(GA2, "0.0.1"),
+
+ ConfigFile = filename:join([LibDir1, "relcool.config"]),
+ write_config(ConfigFile,
+ [{release, {foo, "0.0.1"},
+ [sasl,
+ {goal_app_1, "0.0.1"},
+ {goal_app_2, "0.0.1"}]},
+ {release, {foo, "0.0.2"},
+ [sasl,
+ {goal_app_1, "0.0.2"},
+ {goal_app_2, "0.0.2"}]},
+ {release, {foo, "0.0.3"},
+ [sasl,
+ {goal_app_1, "0.0.3"},
+ {goal_app_2, "0.0.3"}]}]),
+ OutputDir = filename:join([proplists:get_value(data_dir, Config),
+ create_random_name("relcool-output")]),
+ {ok, _} = relcool:do(foo, "0.0.1", [], [LibDir1], 2,
+ OutputDir, ConfigFile),
+ {ok, _} = relcool:do(foo, "0.0.2", [], [LibDir1], 2,
+ OutputDir, ConfigFile),
+ {ok, State} = relcool:do([{relname, foo},
+ {relvsn, "0.0.3"},
+ {upfrom, "0.0.1"},
+ {goals, []},
+ {lib_dirs, [LibDir1]},
+ {log_level, 2},
+ {output_dir, OutputDir},
+ {config, ConfigFile}], ["relup"]),
+
+ %% we should have one 'resolved' release and three discovered realized_releases.
?assertMatch([{foo, "0.0.1"},
{foo, "0.0.2"},
{foo, "0.0.3"}],
- lists:sort(ec_dictionary:keys(rcl_state:releases(State)))),
- Release = ec_dictionary:get({foo, "0.0.3"}, rcl_state:releases(State)),
+ lists:sort(ec_dictionary:keys(rcl_state:realized_releases(State)))),
+ Release = ec_dictionary:get({foo, "0.0.3"}, rcl_state:realized_releases(State)),
?assert(rcl_release:realized(Release)),
?assert(not rcl_release:realized(ec_dictionary:get({foo, "0.0.2"},
- rcl_state:releases(State)))),
+ rcl_state:realized_releases(State)))),
?assert(not rcl_release:realized(ec_dictionary:get({foo, "0.0.1"},
- rcl_state:releases(State)))),
+ rcl_state:realized_releases(State)))),
+
+ ?assertMatch({ok, [{"0.0.3",
+ [{"0.0.1",[],[point_of_no_return]}],
+ [{"0.0.1",[],[point_of_no_return]}]}]},
+ file:consult(filename:join(filename:dirname(rcl_release:relfile(Release)),
+ filename:basename(rcl_release:relfile(Release), ".rel") ++
+ ".relup"))),
+
?assertMatch(foo, rcl_release:name(Release)),
?assertMatch("0.0.3", rcl_release:vsn(Release)),
AppSpecs = rcl_release:applications(Release),
@@ -642,6 +745,7 @@ make_one_app_top_level_release(Config) ->
%%%===================================================================
%%% Helper Functions
%%%===================================================================
+
create_app(Dir, Name, Vsn, Deps, LibDeps) ->
AppDir = filename:join([Dir, Name ++ "-" ++ Vsn]),
write_app_file(AppDir, Name, Vsn, Deps, LibDeps),
@@ -660,6 +764,14 @@ write_beam_file(Dir, Name) ->
ok = filelib:ensure_dir(Beam),
ok = ec_file:write_term(Beam, testing_purposes_only).
+write_appup_file(AppInfo, DownVsn) ->
+ Dir = rcl_app_info:dir(AppInfo),
+ Name = rcl_util:to_string(rcl_app_info:name(AppInfo)),
+ Vsn = rcl_app_info:vsn_as_string(AppInfo),
+ Filename = filename:join([Dir, "ebin", Name ++ ".appup"]),
+ ok = filelib:ensure_dir(Filename),
+ ok = ec_file:write_term(Filename, {Vsn, [{DownVsn, []}], [{DownVsn, []}]}).
+
write_app_file(Dir, Name, Version, Deps, LibDeps) ->
Filename = filename:join([Dir, "ebin", Name ++ ".app"]),
ok = filelib:ensure_dir(Filename),