Add rtdev:copy_conf function

This new utility function copies config from one devrel to another. This
is particularly useful when the first thing a test does is downgrade to
a previous release which doesn't support some new config option that's
been recently added. By copying the old config into the new devrel
before we start up the nodes, we can automatically avoid specifying any
new, incompatible config keys for that particular test.
This commit is contained in:
Nick Marino 2016-09-14 10:47:53 -04:00
parent a604a3186a
commit a75a3811b8

View File

@ -178,6 +178,21 @@ upgrade(Node, NewVersion, Config, UpgradeCallback) ->
rt:wait_until_pingable(Node),
ok.
-spec copy_conf(integer(), atom() | string(), atom() | string()) -> ok.
copy_conf(NumNodes, FromVersion, ToVersion) ->
lager:info("Copying config from ~p to ~p", [FromVersion, ToVersion]),
FromPath = relpath(FromVersion),
ToPath = relpath(ToVersion),
[copy_node_conf(N, FromPath, ToPath) || N <- lists:seq(1, NumNodes)].
copy_node_conf(NodeNum, FromPath, ToPath) ->
Command = io_lib:format("cp -p -P -R \"~s/dev/dev~b/etc\" \"~s/dev/dev~b\"",
[FromPath, NodeNum, ToPath, NodeNum]),
os:cmd(Command),
ok.
-spec set_conf(atom() | string(), [{string(), string()}]) -> ok.
set_conf(all, NameValuePairs) ->
lager:info("rtdev:set_conf(all, ~p)", [NameValuePairs]),