From 2145697ca8263f7afe5824dcf2cf4539dab5fa59 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 13 Nov 2012 17:04:54 +0100 Subject: [common_test] Ensure process down after ct_netconf:close_session OTP-10510 When starting a named netconf connection directly after stopping one with the same name, it sometimes failed with 'connection_exists'. This has been corrected. --- lib/common_test/src/ct_netconfc.erl | 21 +++++++++++++++------ lib/common_test/test/ct_netconfc_SUITE.erl | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl index 52fe9599ce..28480ed983 100644 --- a/lib/common_test/src/ct_netconfc.erl +++ b/lib/common_test/src/ct_netconfc.erl @@ -968,7 +968,7 @@ close_session(Client) -> %% @end %%---------------------------------------------------------------------- close_session(Client, Timeout) -> - call(Client,{send_rpc_op, close_session, [], Timeout}). + call(Client,{send_rpc_op, close_session, [], Timeout}, true). %%---------------------------------------------------------------------- @@ -1121,17 +1121,26 @@ close(Client) -> %% Internal functions %%---------------------------------------------------------------------- call(Client, Msg) -> - call(Client, Msg, infinity). -call(Client, Msg, Timeout) -> + call(Client, Msg, infinity, false). +call(Client, Msg, Timeout) when is_integer(Timeout); Timeout==infinity -> + call(Client, Msg, Timeout, false); +call(Client, Msg, WaitStop) when is_boolean(WaitStop) -> + call(Client, Msg, infinity, WaitStop). +call(Client, Msg, Timeout, WaitStop) -> case get_handle(Client) of {ok,Pid} -> case ct_gen_conn:call(Pid,Msg,Timeout) of - {error,{process_down,Client,noproc}} -> + {error,{process_down,Pid,noproc}} -> {error,no_such_client}; - {error,{process_down,Client,normal}} -> + {error,{process_down,Pid,normal}} -> {error,closed}; - {error,{process_down,Client,Reason}} -> + {error,{process_down,Pid,Reason}} -> {error,{closed,Reason}}; + Other when WaitStop -> + MRef = erlang:monitor(process,Pid), + receive {'DOWN',MRef,process,_,_} -> Other + after Timeout -> {error,{timeout,Other}} + end; Other -> Other end; diff --git a/lib/common_test/test/ct_netconfc_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE.erl index 30084a6228..3042a924fe 100644 --- a/lib/common_test/test/ct_netconfc_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE.erl @@ -113,7 +113,7 @@ reformat(Events, EH) -> %%%----------------------------------------------------------------- %%% TEST EVENTS %%%----------------------------------------------------------------- -events_to_check(Test,Config) -> +events_to_check(default,Config) -> {module,_} = code:load_abs(filename:join(?config(data_dir,Config), netconfc1_SUITE)), TCs = netconfc1_SUITE:all(), -- cgit v1.2.3 From ad398a0dbcdb36323d359bff61fe7f2e39f0e455 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 14 Nov 2012 11:00:17 +0100 Subject: [common_test] Allow server to terminate netconf session before rpc-reply OTP-10570 ct_netconfc:close_session sometimes returned {error,closed} because the ssh connection was closed (from the server side) before the rpc-reply was received by the client. This is normal and can not be helped. It has been corrected so the return will be 'ok' in this case. Other error situations will still give {error,Reason}. --- lib/common_test/src/ct_netconfc.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_netconfc.erl b/lib/common_test/src/ct_netconfc.erl index 28480ed983..294b82bff6 100644 --- a/lib/common_test/src/ct_netconfc.erl +++ b/lib/common_test/src/ct_netconfc.erl @@ -1132,14 +1132,26 @@ call(Client, Msg, Timeout, WaitStop) -> case ct_gen_conn:call(Pid,Msg,Timeout) of {error,{process_down,Pid,noproc}} -> {error,no_such_client}; + {error,{process_down,Pid,normal}} when WaitStop -> + %% This will happen when server closes connection + %% before clien received rpc-reply on + %% close-session. + ok; {error,{process_down,Pid,normal}} -> {error,closed}; {error,{process_down,Pid,Reason}} -> {error,{closed,Reason}}; Other when WaitStop -> MRef = erlang:monitor(process,Pid), - receive {'DOWN',MRef,process,_,_} -> Other - after Timeout -> {error,{timeout,Other}} + receive + {'DOWN',MRef,process,Pid,Normal} when Normal==normal; + Normal==noproc -> + Other; + {'DOWN',MRef,process,Pid,Reason} -> + {error,{{closed,Reason},Other}} + after Timeout -> + erlang:demonitor(MRef, [flush]), + {error,{timeout,Other}} end; Other -> Other -- cgit v1.2.3 From 3e52784d3c88050d695da1f2828df36c9a83d148 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 26 Oct 2012 14:29:56 +0200 Subject: [test_server] Recognize and ignore info_reports for ct connections test_server_h will now recognize info_reports written by ct connection handlers (according to the description in cth_conn_log) and ignore them as they will be completely handled by by ct_conn_log_h. Earlier test_server_h would print a tag (testcase name) before forwarding the report to error_logger_tty_h. This would cause lots of tags in the log with no info report following (since error_logger_tty_h did not handle them). --- lib/common_test/src/ct_conn_log_h.erl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_conn_log_h.erl b/lib/common_test/src/ct_conn_log_h.erl index bf27238121..d7bd18606b 100644 --- a/lib/common_test/src/ct_conn_log_h.erl +++ b/lib/common_test/src/ct_conn_log_h.erl @@ -64,10 +64,16 @@ do_open_files([],Acc) -> handle_event({_Type, GL, _Msg}, State) when node(GL) /= node() -> {ok, State}; handle_event({_Type,_GL,{Pid,{ct_connection,Action,ConnName},Report}},State) -> + %% NOTE: if the format of this event is changed + %% ({ct_connection,Action,ConnName}) then remember to change + %% test_server_h:report_receiver as well!!! Info = conn_info(Pid,#conn_log{name=ConnName,action=Action}), write_report(now(),Info,Report,State), {ok, State}; handle_event({_Type,_GL,{Pid,Info=#conn_log{},Report}},State) -> + %% NOTE: if the format of this event is changed + %% (Info=#conn_log{}) then remember to change + %% test_server_h:report_receiver as well!!! write_report(now(),conn_info(Pid,Info),Report,State), {ok, State}; handle_event({error_report,_,{Pid,_,[{ct_connection,ConnName}|R]}},State) -> -- cgit v1.2.3