diff options
Diffstat (limited to 'lib/common_test')
-rw-r--r-- | lib/common_test/src/ct_gen_conn.erl | 17 | ||||
-rw-r--r-- | lib/common_test/test/ct_netconfc_SUITE.erl | 67 |
2 files changed, 27 insertions, 57 deletions
diff --git a/lib/common_test/src/ct_gen_conn.erl b/lib/common_test/src/ct_gen_conn.erl index 6b183110c6..72937e747c 100644 --- a/lib/common_test/src/ct_gen_conn.erl +++ b/lib/common_test/src/ct_gen_conn.erl @@ -204,16 +204,13 @@ do_start(Address,InitData,CallbackMod,Opts0) -> Opts = check_opts(Opts0,#gen_opts{callback=CallbackMod, address=Address, init_data=InitData}), - case Opts#gen_opts.use_existing of - true -> - case ct_util:does_connection_exist(Opts#gen_opts.name, - Address,CallbackMod) of - {ok,Pid} -> - log("ct_gen_conn:start","Using existing connection!\n",[]), - {ok,Pid}; - false -> - do_start(Opts) - end; + case ct_util:does_connection_exist(Opts#gen_opts.name, + Address,CallbackMod) of + {ok,Pid} when Opts#gen_opts.use_existing -> + log("ct_gen_conn:start","Using existing connection!\n",[]), + {ok,Pid}; + {ok,Pid} when not Opts#gen_opts.use_existing -> + {error,{connection_exists,Pid}}; false -> do_start(Opts) end. diff --git a/lib/common_test/test/ct_netconfc_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE.erl index a7df38108f..317ed3a3c5 100644 --- a/lib/common_test/test/ct_netconfc_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE.erl @@ -68,6 +68,7 @@ all() -> hello_configured, hello_configured_extraopts, hello_required, + hello_required_exists, hello_global_pwd, hello_no_session_id, hello_incomp_base_vsn, @@ -93,9 +94,6 @@ all() -> lock, unlock, kill_session, - get_required, - get_config_required, - edit_config_required, get_no_such_client, action, send_any_rpc, @@ -206,6 +204,25 @@ hello_required(Config) -> ?ok = ct_netconfc:close_session(my_named_connection), ok. +hello_required_exists() -> + [{require, my_named_connection, netconf1}]. +hello_required_exists(Config) -> + DataDir = ?config(data_dir,Config), + {ok,_Client1} = open_configured_success(my_named_connection,DataDir), + + %% Check that same name can not be used twice + {error,{connection_exists,_Client1}} = + ct_netconfc:open(my_named_connection,[{user_dir,DataDir}]), + + ?NS:expect_do_reply('close-session',close,ok), + ?ok = ct_netconfc:close_session(my_named_connection), + + %% Then check that it can be used again after the first is closed + {ok,_Client2} = open_configured_success(my_named_connection,DataDir), + ?NS:expect_do_reply('close-session',close,ok), + ?ok = ct_netconfc:close_session(my_named_connection), + ok. + hello_global_pwd(Config) -> DataDir = ?config(data_dir,Config), {ok,Client} = open_success(DataDir,[{user,"any-user"}, @@ -429,50 +446,6 @@ kill_session(Config) -> ok. -%% get_required, get_config_required and edit_config_required shall -%% test that the same named connection can be used in multiple test -%% cases. Earlier, there was a bug in ct_gen_conn related to this: -%% Connections were not unregistered on close-connection, so -%% ct_netconfc would not find the correct pid for a named connection -%% the second time the name was used. -get_required() -> - [{require, my_named_connection, netconf1}]. -get_required(Config) -> - DataDir = ?config(data_dir,Config), - {ok,_Client} = open_configured_success(my_named_connection,DataDir), - Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}], - ?NS:expect_reply('get',{data,Data}), - {ok,Data} = ct_netconfc:get(my_named_connection,{server,[{xmlns,"myns"}],[]}), - ?NS:expect_do_reply('close-session',close,ok), - ?ok = ct_netconfc:close_session(my_named_connection), - ok. - -get_config_required() -> - [{require, my_named_connection, netconf1}]. -get_config_required(Config) -> - DataDir = ?config(data_dir,Config), - {ok,_Client} = open_configured_success(my_named_connection,DataDir), - Data = [{server,[{xmlns,"myns"}],[{name,[],["myserver"]}]}], - ?NS:expect_reply('get-config',{data,Data}), - {ok,Data} = ct_netconfc:get_config(my_named_connection,running, - {server,[{xmlns,"myns"}],[]}), - ?NS:expect_do_reply('close-session',close,ok), - ?ok = ct_netconfc:close_session(my_named_connection), - ok. - -edit_config_required() -> - [{require, my_named_connection, netconf1}]. -edit_config_required(Config) -> - DataDir = ?config(data_dir,Config), - {ok,_Client} = open_configured_success(my_named_connection,DataDir), - ?NS:expect_reply('edit-config',ok), - ?ok = ct_netconfc:edit_config(my_named_connection,running, - {server,[{xmlns,"myns"}], - [{name,["myserver"]}]}), - ?NS:expect_do_reply('close-session',close,ok), - ?ok = ct_netconfc:close_session(my_named_connection), - ok. - get_no_such_client(Config) -> DataDir = ?config(data_dir,Config), {ok,Client} = open_success(DataDir), |