aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-11-18 11:45:13 +0100
committerSiri Hansen <[email protected]>2013-11-21 10:28:31 +0100
commit5987cd070b80a0e14905359149af6baeacd3d310 (patch)
treeebab1d6d515c4e4fc284a7fd24a85ea3bc2e2277 /lib
parentfb0006c937e284cefe5217d4c2a4b45ff7dfb758 (diff)
downloadotp-5987cd070b80a0e14905359149af6baeacd3d310.tar.gz
otp-5987cd070b80a0e14905359149af6baeacd3d310.tar.bz2
otp-5987cd070b80a0e14905359149af6baeacd3d310.zip
[common_test] Don't hang netconf client when close-session times out
When the netconf server did not respond to the close-session request, the call to ct_netconfc:close_session/2 would hang forever waiting for the netconf client to terminate. This has been corrected. The client will now always terminate (and take down the connection) if the close-session request times out.
Diffstat (limited to 'lib')
-rw-r--r--lib/common_test/src/ct_netconfc.erl8
-rw-r--r--lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl20
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl
index 7f10e1db09..64fe8b4bb0 100644
--- a/lib/common_test/src/ct_netconfc.erl
+++ b/lib/common_test/src/ct_netconfc.erl
@@ -1129,10 +1129,14 @@ handle_msg({Ref,timeout},
ct_gen_conn:return(Caller,{error,{hello_session_failed,timeout}}),
{stop,State#state{hello_status={error,timeout}}};
handle_msg({Ref,timeout},#state{pending=Pending} = State) ->
- {value,#pending{caller=Caller},Pending1} =
+ {value,#pending{op=Op,caller=Caller},Pending1} =
lists:keytake(Ref,#pending.ref,Pending),
ct_gen_conn:return(Caller,{error,timeout}),
- {noreply,State#state{pending=Pending1}}.
+ R = case Op of
+ close_session -> stop;
+ _ -> noreply
+ end,
+ {R,State#state{pending=Pending1}}.
%% @private
%% Called by ct_util_server to close registered connections before terminate.
diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
index 6ee7fdd6f6..179a900ea5 100644
--- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
+++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl
@@ -84,7 +84,9 @@ all() ->
no_host,
no_port,
invalid_opt,
+ timeout_close_session,
get,
+ timeout_get,
get_xpath,
get_config,
get_config_xpath,
@@ -344,6 +346,15 @@ invalid_opt(Config) ->
{error,{invalid_option,{some_other_opt,true}}} = ct_netconfc:open(Opts2),
ok.
+timeout_close_session(Config) ->
+ DataDir = ?config(data_dir,Config),
+ {ok,Client} = open_success(DataDir),
+ ?NS:expect('close-session'),
+ true = erlang:is_process_alive(Client),
+ {error,timeout} = ct_netconfc:close_session(Client,1000),
+ false = erlang:is_process_alive(Client),
+ ok.
+
get(Config) ->
DataDir = ?config(data_dir,Config),
{ok,Client} = open_success(DataDir),
@@ -354,6 +365,15 @@ get(Config) ->
?ok = ct_netconfc:close_session(Client),
ok.
+timeout_get(Config) ->
+ DataDir = ?config(data_dir,Config),
+ {ok,Client} = open_success(DataDir),
+ ?NS:expect('get'),
+ {error,timeout} = ct_netconfc:get(Client,{server,[{xmlns,"myns"}],[]},1000),
+ ?NS:expect_do_reply('close-session',close,ok),
+ ?ok = ct_netconfc:close_session(Client),
+ ok.
+
get_xpath(Config) ->
DataDir = ?config(data_dir,Config),
{ok,Client} = open_success(DataDir),