summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2021-01-18 11:27:38 +0100
committerLukas Larsson <lukas@erlang.org>2021-01-18 11:27:38 +0100
commit6378a0c825db64df91e01ee39e3a268f4ba050b7 (patch)
tree8dac444466d29cff263c89aebb9c779570ee0f08
parentbb3162f131dad817a61643c427dba8ef2f727c7e (diff)
parent12696630d64d95cfaf150d3c29e675650d77ae57 (diff)
downloaderlang-6378a0c825db64df91e01ee39e3a268f4ba050b7.tar.gz
Merge branch 'maint'
-rw-r--r--lib/common_test/src/test_server_node.erl33
-rw-r--r--lib/sasl/src/systools_relup.erl14
-rw-r--r--lib/sasl/test/systools_SUITE.erl64
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/ebin/db.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db1.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db2.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.appup14
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db1.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db2.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/ebin/fe.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe1.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe2.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe3.erl2
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/ebin/gh.app8
-rw-r--r--lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/src/gh1.erl2
16 files changed, 163 insertions, 10 deletions
diff --git a/lib/common_test/src/test_server_node.erl b/lib/common_test/src/test_server_node.erl
index 8deea353d7..edfb1fbd92 100644
--- a/lib/common_test/src/test_server_node.erl
+++ b/lib/common_test/src/test_server_node.erl
@@ -645,7 +645,38 @@ find_release(latest) ->
find_release(previous) ->
"kaka";
find_release(Rel) ->
- find_release(os:type(), Rel).
+ case find_release(os:type(), Rel) of
+ none ->
+ find_release_path(Rel);
+ Else ->
+ Else
+ end.
+
+find_release_path(Rel) ->
+ Paths = string:lexemes(os:getenv("PATH"), ":"),
+ find_release_path(Paths, Rel).
+find_release_path([Path|T], Rel) ->
+ case os:find_executable("erl", Path) of
+ false ->
+ find_release_path(T, Rel);
+ ErlExec ->
+ Pattern = filename:join([Path,"..","releases","*","OTP_VERSION"]),
+ case filelib:wildcard(Pattern) of
+ [VersionFile] ->
+ {ok, VsnBin} = file:read_file(VersionFile),
+ [MajorVsn|_] = string:lexemes(VsnBin, "."),
+ case unicode:characters_to_list(MajorVsn) of
+ Rel ->
+ ErlExec;
+ _Else ->
+ find_release_path(T, Rel)
+ end;
+ _Else ->
+ find_release_path(T, Rel)
+ end
+ end;
+find_release_path([], _) ->
+ none.
find_release({unix,sunos}, Rel) ->
case os:cmd("uname -p") of
diff --git a/lib/sasl/src/systools_relup.erl b/lib/sasl/src/systools_relup.erl
index 63e18d394b..19d25fef6e 100644
--- a/lib/sasl/src/systools_relup.erl
+++ b/lib/sasl/src/systools_relup.erl
@@ -290,9 +290,9 @@ foreach_baserel_up(TopRel, TopApps, [BaseRelDc|BaseRelDcs], Path, Opts,
%%
{RUs1, Ws1} = collect_appup_scripts(up, TopApps, BaseRel, Ws0++Ws, []),
- {RUs2, Ws2} = create_add_app_scripts(BaseRel, TopRel, RUs1, Ws1),
+ {RUs2, Ws2} = prepend_add_app_scripts(BaseRel, TopRel, RUs1, Ws1),
- {RUs3, Ws3} = create_remove_app_scripts(BaseRel, TopRel, RUs2, Ws2),
+ {RUs3, Ws3} = append_remove_app_scripts(BaseRel, TopRel, RUs2, Ws2),
{RUs4, Ws4} = check_for_emulator_restart(TopRel, BaseRel, RUs3, Ws3, Opts),
@@ -342,9 +342,9 @@ foreach_baserel_dn(TopRel, TopApps, [BaseRelDc|BaseRelDcs], Path, Opts,
%%
{RUs1, Ws1} = collect_appup_scripts(dn, TopApps, BaseRel, Ws0++Ws, []),
- {RUs2, Ws2} = create_add_app_scripts(TopRel, BaseRel, RUs1, Ws1),
+ {RUs2, Ws2} = prepend_add_app_scripts(TopRel, BaseRel, RUs1, Ws1),
- {RUs3, Ws3} = create_remove_app_scripts(TopRel, BaseRel, RUs2, Ws2),
+ {RUs3, Ws3} = append_remove_app_scripts(TopRel, BaseRel, RUs2, Ws2),
{RUs4, Ws4} = check_for_emulator_restart(TopRel, BaseRel, RUs3, Ws3, Opts),
@@ -439,7 +439,7 @@ collect_appup_scripts(_, [], _, Ws, RUs) -> {RUs, Ws}.
%% FromRel = ToRel = #release
%% ToApps = [#application]
%%
-create_add_app_scripts(FromRel, ToRel, RU0s, W0s) ->
+prepend_add_app_scripts(FromRel, ToRel, RU0s, W0s) ->
AddedNs = [{N, T} || {N, _V, T} <- ToRel#release.applications,
not lists:keymember(N, 1, FromRel#release.applications)],
%% io:format("Added apps: ~p~n", [AddedNs]),
@@ -454,12 +454,12 @@ create_add_app_scripts(FromRel, ToRel, RU0s, W0s) ->
%%
%% XXX ToApps not used.
%%
-create_remove_app_scripts(FromRel, ToRel, RU0s, W0s) ->
+append_remove_app_scripts(FromRel, ToRel, RU0s, W0s) ->
RemovedNs = [N || {N, _V, _T} <- FromRel#release.applications,
not lists:keymember(N, 1, ToRel#release.applications)],
%% io:format("Removed apps: ~p~n", [RemovedNs]),
RUs = [[{remove_application, N}] || N <- RemovedNs],
- {RUs ++ RU0s, W0s}.
+ { RU0s ++ RUs, W0s}.
%% get_script_from_appup(Mode, TopApp, BaseVsn, Ws, RUs) -> {NRUs, NWs}
%% Mode = up | dn
diff --git a/lib/sasl/test/systools_SUITE.erl b/lib/sasl/test/systools_SUITE.erl
index f3b039569b..53ce272b17 100644
--- a/lib/sasl/test/systools_SUITE.erl
+++ b/lib/sasl/test/systools_SUITE.erl
@@ -72,7 +72,8 @@ groups() ->
otp_9507_path_ebin, additional_files_tar, erts_tar]},
{relup, [],
[normal_relup, restart_relup, abnormal_relup, no_sasl_relup,
- no_appup_relup, bad_appup_relup, app_start_type_relup, regexp_relup
+ no_appup_relup, bad_appup_relup, app_start_type_relup, regexp_relup,
+ replace_app_relup
]},
{hybrid, [], [normal_hybrid,hybrid_no_old_sasl,hybrid_no_new_sasl]},
{options, [], [otp_6226_outdir,app_file_defaults]}].
@@ -1929,6 +1930,59 @@ regexp_relup(Config) ->
ok.
+%% make_relup: Replace an application dependency with another
+%% The key part here is that the new application should be
+%% started before the old one is stopped.
+replace_app_relup(Config) when is_list(Config) ->
+ {ok, OldDir} = file:get_cwd(),
+
+ {LatestDir,LatestName} = create_script(replace_app0,Config),
+ {_LatestDir1,LatestName1} = create_script(replace_app1,Config),
+
+ DataDir = filename:absname(?copydir),
+ LibDir = [fname([DataDir, d_replace_app, lib])],
+ P = [fname([LibDir, '*', ebin]),
+ fname([DataDir, lib, kernel, ebin]),
+ fname([DataDir, lib, stdlib, ebin]),
+ fname([DataDir, lib, sasl, ebin])],
+
+ ok = file:set_cwd(LatestDir),
+
+ ok = systools:make_relup(LatestName, [LatestName1], [LatestName1],
+ [{path, P}]),
+
+ check_start_stop_order([{start,gh},{stop,fe}], [{start,fe},{stop,gh}]),
+
+ ok = file:set_cwd(OldDir),
+ ok.
+
+
+check_start_stop_order(UpOrder, DownOrder) ->
+
+ {ok, [{_V0, [{_V1, [], Up}],
+ [{_V1, [], Down}]
+ }]} = file:consult(relup),
+
+ GetAppStartStop = fun(Instr) ->
+ [{Action,App} || {apply,{application,Action,[App|_]}} <- Instr,
+ lists:member(Action,[start,stop])]
+ end,
+
+ case GetAppStartStop(Up) of
+ UpOrder -> ok;
+ ActualUpOrder ->
+ ct:fail("Incorrect upgrade order.~nExpected: ~p~nGot:~p",
+ [UpOrder,ActualUpOrder])
+ end,
+
+ case GetAppStartStop(Down) of
+ DownOrder -> ok;
+ ActualDownOrder ->
+ ct:fail("Incorrect down order.~nExpected: ~p~nGot:~p",
+ [DownOrder,ActualDownOrder])
+ end,
+
+ ok.
%% make_hybrid_boot: Normal case.
%% For upgrade of erts - create a boot file which is a hybrid between
@@ -2484,7 +2538,13 @@ create_script({unicode,RelVsn},Config) ->
do_create_script(unicode,RelVsn,Config,current,Apps);
create_script(duplicate_modules,Config) ->
Apps = core_apps(current) ++ [{app1,"1.0"},{app2,"1.0"}],
- do_create_script(duplicate_modules,Config,current,Apps).
+ do_create_script(duplicate_modules,Config,current,Apps);
+create_script(replace_app0,Config) ->
+ Apps = core_apps(current) ++ [{db,"1.1"},{gh,"1.0"}],
+ do_create_script(repace_app0,Config,current,Apps);
+create_script(replace_app1,Config) ->
+ Apps = core_apps(current) ++ [{db,"1.0"},{fe,"2.1"}],
+ do_create_script(repace_app1,Config,current,Apps).
do_create_script(Id,Config,ErtsVsn,AppVsns) ->
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/ebin/db.app b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/ebin/db.app
new file mode 100644
index 0000000000..d12fcfaf7d
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/ebin/db.app
@@ -0,0 +1,8 @@
+{application, db,
+ [{description, "ERICSSON NR FOR DB"},
+ {vsn, "1.0"},
+ {modules, [db1, db2]},
+ {registered, []},
+ {applications, [fe]},
+ {env, []},
+ {start, {db1, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db1.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db1.erl
new file mode 100644
index 0000000000..a17640316e
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db1.erl
@@ -0,0 +1,2 @@
+-module(db2).
+-vsn("1.0").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db2.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db2.erl
new file mode 100644
index 0000000000..a17640316e
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db2.erl
@@ -0,0 +1,2 @@
+-module(db2).
+-vsn("1.0").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.app b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.app
new file mode 100644
index 0000000000..517a0810f9
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.app
@@ -0,0 +1,8 @@
+{application, db,
+ [{description, "ERICSSON NR FOR DB"},
+ {vsn, "1.1"},
+ {modules, [db1, db2]},
+ {registered, []},
+ {applications, [gh]},
+ {env, []},
+ {start, {db1, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.appup b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.appup
new file mode 100644
index 0000000000..12d7ad4c9c
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.appup
@@ -0,0 +1,14 @@
+{
+ "1.1",
+%%% Upgrade from:
+ [
+ {"1.0", [{update, db1, soft, soft_purge, soft_purge, []},
+ {update, db2, soft, soft_purge, soft_purge, [db1]}]}
+ ],
+
+%%% Downgrade to:
+ [
+ {"1.0", [{update, db1, soft, soft_purge, soft_purge, []},
+ {update, db2, soft, soft_purge, soft_purge, [db1]}]}
+ ]
+}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db1.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db1.erl
new file mode 100644
index 0000000000..ee7497f5c1
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db1.erl
@@ -0,0 +1,2 @@
+-module(db2).
+-vsn("1.1").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db2.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db2.erl
new file mode 100644
index 0000000000..ee7497f5c1
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db2.erl
@@ -0,0 +1,2 @@
+-module(db2).
+-vsn("1.1").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/ebin/fe.app b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/ebin/fe.app
new file mode 100644
index 0000000000..717d30cf45
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/ebin/fe.app
@@ -0,0 +1,8 @@
+{application, fe,
+ [{description, "ERICSSON NR FOR FE"},
+ {vsn, "2.1"},
+ {modules, [fe1, fe2, fe3]},
+ {registered, []},
+ {applications, []},
+ {env, []},
+ {start, {fe2, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe1.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe1.erl
new file mode 100644
index 0000000000..aa5bfa8098
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe1.erl
@@ -0,0 +1,2 @@
+-module(fe1).
+-vsn("1.0").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe2.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe2.erl
new file mode 100644
index 0000000000..869f3b93c8
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe2.erl
@@ -0,0 +1,2 @@
+-module(fe2).
+-vsn("1.0").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe3.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe3.erl
new file mode 100644
index 0000000000..6473342f52
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe3.erl
@@ -0,0 +1,2 @@
+-module(fe3).
+-vsn("2.0").
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/ebin/gh.app b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/ebin/gh.app
new file mode 100644
index 0000000000..2823a7e592
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/ebin/gh.app
@@ -0,0 +1,8 @@
+{application, gh,
+ [{description, "ERICSSON NR FOR GH"},
+ {vsn, "1.0"},
+ {modules, [gh1]},
+ {registered, []},
+ {applications, []},
+ {env, []},
+ {start, {gh1, start, []}}]}.
diff --git a/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/src/gh1.erl b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/src/gh1.erl
new file mode 100644
index 0000000000..acd0f43d6a
--- /dev/null
+++ b/lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/src/gh1.erl
@@ -0,0 +1,2 @@
+-module(gh1).
+-vsn("1.0").