aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/test/ct_config_SUITE.erl92
-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.erl16
-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
4 files changed, 96 insertions, 53 deletions
diff --git a/lib/common_test/test/ct_config_SUITE.erl b/lib/common_test/test/ct_config_SUITE.erl
index ad7c521946..a7fa6fe52e 100644
--- a/lib/common_test/test/ct_config_SUITE.erl
+++ b/lib/common_test/test/ct_config_SUITE.erl
@@ -78,31 +78,31 @@ all(suite) ->
%%%
require(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
- run_test(require,
+ run_test(config_static_SUITE,
Config,
{config, filename:join(DataDir, "config/config.txt")},
- ["config_1_SUITE"]).
+ ["config_static_SUITE"]).
userconfig_static(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
- run_test(userconfig_static,
+ run_test(config_static_SUITE,
Config,
{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}},
- ["config_1_SUITE"]).
+ ["config_static_SUITE"]).
userconfig_dynamic(Config) when is_list(Config) ->
- run_test(userconfig_dynamic,
+ run_test(config_dynamic_SUITE,
Config,
{userconfig, {config_driver, "config_server"}},
- ["config_2_SUITE"]).
+ ["config_dynamic_SUITE"]).
testspec_legacy(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
make_spec(DataDir,
"config/spec_legacy.spec",
- [config_1_SUITE],
+ [config_static_SUITE],
[{config, filename:join(DataDir, "config/config.txt")}]),
- run_test(testspec_legacy,
+ run_test(config_static_SUITE,
Config,
{spec, filename:join(DataDir, "config/spec_legacy.spec")},
[]),
@@ -112,9 +112,9 @@ testspec_static(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
make_spec(DataDir,
"config/spec_static.spec",
- [config_1_SUITE],
+ [config_static_SUITE],
[{userconfig, {ct_config_xml, filename:join(DataDir, "config/config.xml")}}]),
- run_test(testspec_static,
+ run_test(config_static_SUITE,
Config,
{spec, filename:join(DataDir, "config/spec_static.spec")},
[]),
@@ -123,9 +123,9 @@ testspec_static(Config) when is_list(Config) ->
testspec_dynamic(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
make_spec(DataDir, "config/spec_dynamic.spec",
- [config_2_SUITE],
+ [config_dynamic_SUITE],
[{userconfig, {config_driver, "config_server"}}]),
- run_test(testspec_dynamic,
+ run_test(config_dynamic_SUITE,
Config,
{spec, filename:join(DataDir, "config/spec_dynamic.spec")},
[]),
@@ -134,7 +134,7 @@ testspec_dynamic(Config) when is_list(Config) ->
%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------
-% {suites, "ct_config_SUITE_data/config/test", config_2_SUITE}.
+% {suites, "ct_config_SUITE_data/config/test", config_dynamic_SUITE}.
make_spec(DataDir, Filename, Suites, Config)->
{ok, Fd} = file:open(filename:join(DataDir, Filename), [write]),
ok = file:write(Fd,
@@ -169,66 +169,64 @@ reformat_events(Events, EH) ->
%%%-----------------------------------------------------------------
%%% TEST EVENTS
%%%-----------------------------------------------------------------
-expected_events(Static) when
- Static == require; Static == testspec_legacy;
- Static == userconfig_static; Static == testspec_static->
+expected_events(config_static_SUITE)->
[
{?eh,start_logging,{'DEF','RUNDIR'}},
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,start_info,{1,1,8}},
- {?eh,tc_start,{config_1_SUITE,init_per_suite}},
- {?eh,tc_done,{config_1_SUITE,init_per_suite,ok}},
- {?eh,tc_start,{config_1_SUITE,test_get_config_simple}},
- {?eh,tc_done,{config_1_SUITE,test_get_config_simple,ok}},
+ {?eh,tc_start,{config_static_SUITE,init_per_suite}},
+ {?eh,tc_done,{config_static_SUITE,init_per_suite,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_get_config_simple}},
+ {?eh,tc_done,{config_static_SUITE,test_get_config_simple,ok}},
{?eh,test_stats,{1,0,{0,0}}},
- {?eh,tc_start,{config_1_SUITE,test_get_config_nested}},
- {?eh,tc_done,{config_1_SUITE,test_get_config_nested,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_get_config_nested}},
+ {?eh,tc_done,{config_static_SUITE,test_get_config_nested,ok}},
{?eh,test_stats,{2,0,{0,0}}},
- {?eh,tc_start,{config_1_SUITE,test_default_suitewide}},
- {?eh,tc_done,{config_1_SUITE,test_default_suitewide,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_default_suitewide}},
+ {?eh,tc_done,{config_static_SUITE,test_default_suitewide,ok}},
{?eh,test_stats,{3,0,{0,0}}},
- {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use1}},
+ {?eh,tc_start,{config_static_SUITE,test_config_name_already_in_use1}},
{?eh,tc_done,
- {config_1_SUITE,test_config_name_already_in_use1,{skipped,{config_name_already_in_use,[x1]}}}},
+ {config_static_SUITE,test_config_name_already_in_use1,{skipped,{config_name_already_in_use,[x1]}}}},
{?eh,test_stats,{3,0,{1,0}}},
- {?eh,tc_start,{config_1_SUITE,test_default_tclocal}},
- {?eh,tc_done,{config_1_SUITE,test_default_tclocal,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_default_tclocal}},
+ {?eh,tc_done,{config_static_SUITE,test_default_tclocal,ok}},
{?eh,test_stats,{4,0,{1,0}}},
- {?eh,tc_start,{config_1_SUITE,test_config_name_already_in_use2}},
+ {?eh,tc_start,{config_static_SUITE,test_config_name_already_in_use2}},
{?eh,tc_done,
- {config_1_SUITE,test_config_name_already_in_use2,
+ {config_static_SUITE,test_config_name_already_in_use2,
{skipped,{config_name_already_in_use,[x1,alias]}}}},
{?eh,test_stats,{4,0,{2,0}}},
- {?eh,tc_start,{config_1_SUITE,test_alias_tclocal}},
- {?eh,tc_done,{config_1_SUITE,test_alias_tclocal,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_alias_tclocal}},
+ {?eh,tc_done,{config_static_SUITE,test_alias_tclocal,ok}},
{?eh,test_stats,{5,0,{2,0}}},
- {?eh,tc_start,{config_1_SUITE,test_get_config_undefined}},
- {?eh,tc_done,{config_1_SUITE,test_get_config_undefined,ok}},
+ {?eh,tc_start,{config_static_SUITE,test_get_config_undefined}},
+ {?eh,tc_done,{config_static_SUITE,test_get_config_undefined,ok}},
{?eh,test_stats,{6,0,{2,0}}},
- {?eh,tc_start,{config_1_SUITE,end_per_suite}},
- {?eh,tc_done,{config_1_SUITE,end_per_suite,ok}},
+ {?eh,tc_start,{config_static_SUITE,end_per_suite}},
+ {?eh,tc_done,{config_static_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
{?eh,stop_logging,[]}
];
-expected_events(Dynamic) when Dynamic == testspec_dynamic; Dynamic == userconfig_dynamic->
+expected_events(config_dynamic_SUITE)->
[
{ct_test_support_eh,start_logging,{'DEF','RUNDIR'}},
{ct_test_support_eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{ct_test_support_eh,start_info,{1,1,3}},
- {ct_test_support_eh,tc_start,{config_2_SUITE,init_per_suite}},
- {ct_test_support_eh,tc_done,{config_2_SUITE,init_per_suite,ok}},
- {ct_test_support_eh,tc_start,{config_2_SUITE,test_get_known_variable}},
- {ct_test_support_eh,tc_done,{config_2_SUITE,test_get_known_variable,ok}},
+ {ct_test_support_eh,tc_start,{config_dynamic_SUITE,init_per_suite}},
+ {ct_test_support_eh,tc_done,{config_dynamic_SUITE,init_per_suite,ok}},
+ {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_get_known_variable}},
+ {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_get_known_variable,ok}},
{ct_test_support_eh,test_stats,{1,0,{0,0}}},
- {ct_test_support_eh,tc_start,{config_2_SUITE,test_localtime_update}},
- {ct_test_support_eh,tc_done,{config_2_SUITE,test_localtime_update,ok}},
+ {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_localtime_update}},
+ {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_localtime_update,ok}},
{ct_test_support_eh,test_stats,{2,0,{0,0}}},
- {ct_test_support_eh,tc_start,{config_2_SUITE,test_server_pid}},
- {ct_test_support_eh,tc_done,{config_2_SUITE,test_server_pid,ok}},
+ {ct_test_support_eh,tc_start,{config_dynamic_SUITE,test_server_pid}},
+ {ct_test_support_eh,tc_done,{config_dynamic_SUITE,test_server_pid,ok}},
{ct_test_support_eh,test_stats,{3,0,{0,0}}},
- {ct_test_support_eh,tc_start,{config_2_SUITE,end_per_suite}},
- {ct_test_support_eh,tc_done,{config_2_SUITE,end_per_suite,ok}},
+ {ct_test_support_eh,tc_start,{config_dynamic_SUITE,end_per_suite}},
+ {ct_test_support_eh,tc_done,{config_dynamic_SUITE,end_per_suite,ok}},
{ct_test_support_eh,test_done,{'DEF','STOP_TIME'}},
{ct_test_support_eh,stop_logging,[]}
]. \ No newline at end of file
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