diff options
author | Andrey Pampukha <[email protected]> | 2010-03-18 16:48:27 +0100 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-06-09 16:19:14 +0200 |
commit | d7c10478a2287ce3f0c9ac077d835919e2745f91 (patch) | |
tree | eb208e8ee31c54bd83ec695ea67a6943bf8b331a /lib/common_test/test/ct_config_SUITE_data | |
parent | eda9f3c82d3241549352969c59488b232e902d69 (diff) | |
download | otp-d7c10478a2287ce3f0c9ac077d835919e2745f91.tar.gz otp-d7c10478a2287ce3f0c9ac077d835919e2745f91.tar.bz2 otp-d7c10478a2287ce3f0c9ac077d835919e2745f91.zip |
Rename suites for ct_config and add tests for disappearing variables
Tests for disappearing variables added to ct_dynamic_SUITE.
Diffstat (limited to 'lib/common_test/test/ct_config_SUITE_data')
-rw-r--r-- | lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl (renamed from lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl) | 41 | ||||
-rw-r--r-- | lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl | 16 | ||||
-rw-r--r-- | lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl (renamed from lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl) | 0 |
3 files changed, 51 insertions, 6 deletions
diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl index 86fd300a77..1013c46c7d 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_2_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_dynamic_SUITE.erl @@ -38,6 +38,8 @@ %% now = erlang:now() - easier to compare than localtime() %% config_server_pid - pid of the config server, should NOT change! %% config_server_vsn - .19 +%% config_server_iteration - a number of iteration config_server's loop done +%% disappearable_variable - hereAmI - will be absent on even iterations suite() -> [ @@ -77,7 +79,8 @@ end_per_suite(_) -> ok. all() -> [test_get_known_variable, test_localtime_update, - test_server_pid]. + test_server_pid, test_disappearable_variable, + test_disappearable_variable_alias]. init_per_testcase(_, Config) -> %{Module, Cfg} = get_all_config(), @@ -118,6 +121,42 @@ test_server_pid(_)-> Vsn = ct:get_config(cfvsn), ok. +% test that variables may disappear from the config_2_SUITE +test_disappearable_variable(_)-> + % ask CT for config_server_iteration variable + Iter = ct:reload_config(config_server_iteration), + % here we should reload this variable in case it's odd + if Iter rem 2 == 1-> + Iter2 = ct:reload_config(config_server_iteration), + Iter2 = Iter+1; + true->ok + end, + % now disappearable_variable should be in place + hereAmI = ct:get_config(disappearable_variable), + % and now it should disappear + undefined = ct:reload_config(disappearable_variable). + +% alias of disappearable_variable should disappear too +test_disappearable_variable_alias(_)-> + % the same rules apply for this testcase as for previous one + Iter = ct:reload_config(config_server_iteration), + Iter2 = if + Iter rem 2 == 1 -> + NewIter = ct:reload_config(config_server_iteration), + NewIter = Iter+1; + true-> + Iter + end, + ct:require(diav, disappearable_variable), + hereAmI = ct:get_config(disappearable_variable), + hereAmI = ct:get_config(diav), + undefined = ct:reload_config(disappearable_variable), + % after reloading, it's even again + Iter3=ct:get_config(config_server_iteration), + Iter3 = Iter2+1, + % and alias does not exist + undefined = ct:get_config(diav). + my_dt_to_datetime([{date, D},{time, T}])-> {D, T}. diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl index 0ee0bcfc22..f56bdf15ad 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_server.erl @@ -24,7 +24,7 @@ %%% Config server used in the CT's tests (config_2_SUITE) %%%------------------------------------------------------------------- -module(config_server). --export([start/0, stop/0, init/1, get_config/0, loop/0]). +-export([start/0, stop/0, loop/1, init/1, get_config/0]). -define(REGISTERED_NAME, ct_test_config_server). -define(vsn, 0.19). @@ -41,7 +41,7 @@ start()-> init(Name)-> register(Name, self()), - loop(). + loop(0). get_config()-> call(self(), get_config). @@ -63,19 +63,25 @@ call(Client, Request)-> end end. -loop()-> +loop(Iteration)-> receive {Pid, stop}-> Pid ! ok; {Pid, get_config}-> {D,T} = erlang:localtime(), - Pid ! + Config = [{localtime, [{date, D}, {time, T}]}, {node, erlang:node()}, + {config_server_iteration, Iteration}, {now, erlang:now()}, {config_server_pid, self()}, {config_server_vsn, ?vsn}], - ?MODULE:loop() + Config2 = if Iteration rem 2 == 0-> + Config ++ [{disappearable_variable, hereAmI}]; + true-> Config + end, + Pid ! Config2, + ?MODULE:loop(Iteration+1) end. wait()-> diff --git a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl index e102c69d3d..e102c69d3d 100644 --- a/lib/common_test/test/ct_config_SUITE_data/config/test/config_1_SUITE.erl +++ b/lib/common_test/test/ct_config_SUITE_data/config/test/config_static_SUITE.erl |