Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
1088-sasl-Fix-release-upgrade-when-replacing-de...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1088-sasl-Fix-release-upgrade-when-replacing-dependency.patch of Package erlang
From 0e5abe4a858e371e8543724469148703ff16d8b5 Mon Sep 17 00:00:00 2001 From: Lukas Larsson <lukas@erlang.org> Date: Tue, 24 Nov 2020 10:55:41 +0100 Subject: [PATCH 1/2] sasl: Fix release upgrade when replacing dependency --- lib/sasl/src/systools_relup.erl | 14 ++-- lib/sasl/test/systools_SUITE.erl | 64 ++++++++++++++++++- .../d_replace_app/lib/db-1.0/ebin/db.app | 8 +++ .../d_replace_app/lib/db-1.0/src/db1.erl | 2 + .../d_replace_app/lib/db-1.0/src/db2.erl | 2 + .../d_replace_app/lib/db-1.1/ebin/db.app | 8 +++ .../d_replace_app/lib/db-1.1/ebin/db.appup | 14 ++++ .../d_replace_app/lib/db-1.1/src/db1.erl | 2 + .../d_replace_app/lib/db-1.1/src/db2.erl | 2 + .../d_replace_app/lib/fe-2.1/ebin/fe.app | 8 +++ .../d_replace_app/lib/fe-2.1/src/fe1.erl | 2 + .../d_replace_app/lib/fe-2.1/src/fe2.erl | 2 + .../d_replace_app/lib/fe-2.1/src/fe3.erl | 2 + .../d_replace_app/lib/gh-1.0/ebin/gh.app | 8 +++ .../d_replace_app/lib/gh-1.0/src/gh1.erl | 2 + 15 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/ebin/db.app create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db1.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.0/src/db2.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.app create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/ebin/db.appup create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db1.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/db-1.1/src/db2.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/ebin/fe.app create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe1.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe2.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/fe-2.1/src/fe3.erl create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/ebin/gh.app create mode 100644 lib/sasl/test/systools_SUITE_data/d_replace_app/lib/gh-1.0/src/gh1.erl 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 3c60c0fa21..4b67d406a6 100644 --- a/lib/sasl/test/systools_SUITE.erl +++ b/lib/sasl/test/systools_SUITE.erl @@ -72,7 +72,8 @@ groups() -> otp_9507_path_ebin]}, {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]}]. @@ -1734,6 +1735,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 @@ -2258,7 +2312,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"). -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor