From 23b45974ce6401638ce0e69d704effc9719b9712 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Fri, 27 Jul 2018 17:20:38 +0200 Subject: [PATCH] detect VTY TELNET port connection failures (attempt #2) Pass the CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT parameter to the TELNET port by default. This allows tests to make progress into an error handling path if they are started while the osmo-* program they want to connect on VTY is not running. Observed with osmo-ggsn tests, where if the one test runs into a VTY connection failure the subsequent test would get stuck forever in a map() call on the VTY TELNET port. Teach the function f_vty_wait_for_prompt() about connection reports by the TELNET module. We may now receive an integer which represents the socket file descriptor for the telnet connection. This case was not handled by the previous change made in commit cb111b21aba1d5881da1a1d3f19754cbd15b3779. As a result, BSC tests started failing with "VTY Timeout for prompt" because the alt-statement in f_vty_wait_for_prompt() would not progress past the integer sitting on the VTY port's receive queue. Change-Id: I56925f93af6c55e93f3f417099db135744da6a40 Related: OS#3149 --- bsc/BSC_Tests.default | 1 + bts/BTS_Tests.default | 1 + ggsn_tests/GGSN_Tests.default | 1 + hlr/HLR_Tests.default | 1 + library/Osmocom_VTY_Functions.ttcn | 9 +++++++++ msc/MSC_Tests.default | 1 + sccp/SCCP_Tests.default | 1 + sgsn/SGSN_Tests.default | 1 + sip/SIP_Tests.default | 1 + 9 files changed, 17 insertions(+) diff --git a/bsc/BSC_Tests.default b/bsc/BSC_Tests.default index c13f7b03e..881835911 100644 --- a/bsc/BSC_Tests.default +++ b/bsc/BSC_Tests.default @@ -15,6 +15,7 @@ mtc.FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; *.BSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.BSCVTY.CTRL_READMODE := "buffered" *.BSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.BSCVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.BSCVTY.PROMPT1 := "OsmoBSC> " [MODULE_PARAMETERS] diff --git a/bts/BTS_Tests.default b/bts/BTS_Tests.default index 502c17fd8..f254993a6 100644 --- a/bts/BTS_Tests.default +++ b/bts/BTS_Tests.default @@ -12,6 +12,7 @@ mtc.FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC; *.BTSVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.BTSVTY.CTRL_READMODE := "buffered" *.BTSVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.BTSVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.BTSVTY.PROMPT1 := "OsmoBTS> " *.PCU.socket_type := "SEQPACKET" diff --git a/ggsn_tests/GGSN_Tests.default b/ggsn_tests/GGSN_Tests.default index ff0cd9753..4d52e242b 100644 --- a/ggsn_tests/GGSN_Tests.default +++ b/ggsn_tests/GGSN_Tests.default @@ -8,6 +8,7 @@ *.GGSNVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.GGSNVTY.CTRL_READMODE := "buffered" *.GGSNVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.GGSNVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.GGSNVTY.PROMPT1 := "OsmoGGSN> " [MODULE_PARAMETERS] diff --git a/hlr/HLR_Tests.default b/hlr/HLR_Tests.default index f45847926..84d4ff390 100644 --- a/hlr/HLR_Tests.default +++ b/hlr/HLR_Tests.default @@ -9,6 +9,7 @@ mtc.FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING; // | DEBUG_ENCDEC; *.VTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.VTY.CTRL_READMODE := "buffered" *.VTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.VTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.VTY.PROMPT1 := "OsmoHLR> " [MODULE_PARAMETERS] diff --git a/library/Osmocom_VTY_Functions.ttcn b/library/Osmocom_VTY_Functions.ttcn index 6e4eb74c0..427bd5c33 100644 --- a/library/Osmocom_VTY_Functions.ttcn +++ b/library/Osmocom_VTY_Functions.ttcn @@ -46,6 +46,7 @@ module Osmocom_VTY_Functions { /* wait for any of the permitted prompts; buffer + return all intermediate output */ function f_vty_wait_for_prompt(TELNETasp_PT pt) return charstring { var charstring rx, buf := ""; + var integer fd; timer T := 2.0; T.start; @@ -57,6 +58,14 @@ module Osmocom_VTY_Functions { testcase.stop(fail, "VTY: Unknown Command"); }; [] pt.receive(charstring:?) -> value rx { buf := buf & rx; repeat }; + [] pt.receive(integer:?) -> value fd { + if (fd == -1) { + setverdict(fail, "VTY Telnet Connection Failure"); + mtc.stop; + } else { + repeat; /* telnet connection succeeded */ + } + } [] T.timeout { setverdict(fail, "VTY Timeout for prompt"); mtc.stop; diff --git a/msc/MSC_Tests.default b/msc/MSC_Tests.default index bcaae0689..a24fa385d 100644 --- a/msc/MSC_Tests.default +++ b/msc/MSC_Tests.default @@ -20,6 +20,7 @@ mtc.FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; *.MSCVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.MSCVTY.CTRL_READMODE := "buffered" *.MSCVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.MSCVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.MSCVTY.PROMPT1 := "OsmoMSC> " diff --git a/sccp/SCCP_Tests.default b/sccp/SCCP_Tests.default index 7d16e5b6d..95e0d2fe4 100644 --- a/sccp/SCCP_Tests.default +++ b/sccp/SCCP_Tests.default @@ -15,6 +15,7 @@ mtc.FileMask := ERROR | WARNING; *.SCCP_DEMO_USER_VTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.SCCP_DEMO_USER_VTY.CTRL_READMODE := "buffered" *.SCCP_DEMO_USER_VTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.SCCP_DEMO_USER_VTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.SCCP_DEMO_USER_VTY.PROMPT1 := "sccp-demo-user> " [MODULE_PARAMETERS] diff --git a/sgsn/SGSN_Tests.default b/sgsn/SGSN_Tests.default index bac5fdda4..3957e82d3 100644 --- a/sgsn/SGSN_Tests.default +++ b/sgsn/SGSN_Tests.default @@ -15,6 +15,7 @@ FileMask := LOG_ALL | TTCN_MATCHING; *.SGSNVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.SGSNVTY.CTRL_READMODE := "buffered" *.SGSNVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.SGSNVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.SGSNVTY.PROMPT1 := "OsmoSGSN> " diff --git a/sip/SIP_Tests.default b/sip/SIP_Tests.default index 2576b332f..4434a1a5e 100644 --- a/sip/SIP_Tests.default +++ b/sip/SIP_Tests.default @@ -13,6 +13,7 @@ mtc.FileMask := ERROR | WARNING | PARALLEL | VERDICTOP; *.SIPVTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes" *.SIPVTY.CTRL_READMODE := "buffered" *.SIPVTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes" +*.SIPVTY.CTRL_DETECT_CONNECTION_ESTABLISHMENT_RESULT := "yes" *.SIPVTY.PROMPT1 := "OsmoSIPcon> " *.SIP.local_sip_port := "5060"