pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37956?usp=email )
Change subject: StatsD_Checker: Allow building without VTY support ......................................................................
StatsD_Checker: Allow building without VTY support
Some programs may support exporting to statsd, but may not support the Osmocom VTY set of commands to send reports, or not have a VTY at all.
The current StatsD_Checker implementation as it is now is not totally useful without VTY code. a Follow-up patch will provide new APIs and improved implementation to use it without VTY.
Change-Id: I5421c76e4f303fd16d4db945a1c69910e40ac820 --- M bsc/gen_links.sh M bsc/regen_makefile.sh M hnbgw/gen_links.sh M hnbgw/regen_makefile.sh M hnodeb/gen_links.sh M hnodeb/regen_makefile.sh R library/StatsD_Checker.ttcnpp M mgw/gen_links.sh M mgw/regen_makefile.sh M ns/gen_links.sh M ns/regen_makefile.sh M pcu/gen_links.sh M pcu/regen_makefile.sh M upf/gen_links.sh M upf/regen_makefile.sh 15 files changed, 29 insertions(+), 7 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved fixeria: Looks good to me, but someone else must approve
diff --git a/bsc/gen_links.sh b/bsc/gen_links.sh index cb9f12f..05c1e51 100755 --- a/bsc/gen_links.sh +++ b/bsc/gen_links.sh @@ -70,7 +70,7 @@ FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn BSSMAP_Templates.ttcn RAN_Emulation.ttcnpp RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn SDP_Templates.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc BSSAP_CodecPort.ttcn RAN_Adapter.ttcnpp Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn SCCP_Templates.ttcn IPA_Testing.ttcn GSM_SystemInformation.ttcn GSM_RestOctets.ttcn " FILES+="CBSP_Types.ttcn CBSP_Templates.ttcn " FILES+="CBSP_CodecPort.ttcn CBSP_CodecPort_CtrlFunct.ttcn CBSP_CodecPort_CtrlFunctdef.cc CBSP_Adapter.ttcn " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="BSSAP_LE_CodecPort.ttcn BSSAP_LE_Emulation.ttcn BSSAP_LE_Types.ttcn BSSAP_LE_Adapter.ttcn BSSLAP_Types.ttcn BSSMAP_LE_Templates.ttcn " FILES+="AbisOML_Types.ttcn"
diff --git a/bsc/regen_makefile.sh b/bsc/regen_makefile.sh index fc53e30..6683f29 100755 --- a/bsc/regen_makefile.sh +++ b/bsc/regen_makefile.sh @@ -32,6 +32,7 @@ -DRAN_EMULATION_BSSAP -DRAN_EMULATION_CTRL -DRAN_EMULATION_MGCP + -DSTATSD_HAVE_VTY -DUSE_MTP3_DISTRIBUTOR "
diff --git a/hnbgw/gen_links.sh b/hnbgw/gen_links.sh index e11b915..51ce602 100755 --- a/hnbgw/gen_links.sh +++ b/hnbgw/gen_links.sh @@ -102,7 +102,7 @@ FILES+="RAN_Adapter.ttcnpp RAN_Emulation.ttcnpp BSSAP_CodecPort.ttcn SCCP_Templates.ttcn " FILES+="PFCP_CodecPort.ttcn PFCP_CodecPort_CtrlFunct.ttcn PFCP_CodecPort_CtrlFunctDef.cc PFCP_Emulation.ttcn PFCP_Templates.ttcn " FILES+="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="L3_Templates.ttcn L3_Common.ttcn " FILES+="SCTP_Templates.ttcn " gen_links $DIR $FILES diff --git a/hnbgw/regen_makefile.sh b/hnbgw/regen_makefile.sh index 13db985..c67323e 100755 --- a/hnbgw/regen_makefile.sh +++ b/hnbgw/regen_makefile.sh @@ -33,6 +33,7 @@ export CPPFLAGS_TTCN3=" -DIPA_EMULATION_CTRL -DRAN_EMULATION_RANAP + -DSTATSD_HAVE_VTY -DUSE_MTP3_DISTRIBUTOR "
diff --git a/hnodeb/gen_links.sh b/hnodeb/gen_links.sh index 35aa039..71265b1 100755 --- a/hnodeb/gen_links.sh +++ b/hnodeb/gen_links.sh @@ -62,7 +62,7 @@ FILES="HNBLLIF_Types.ttcn HNBLLIF_Templates.ttcn HNBLLIF_CodecPort.ttcn " FILES+="Iuh_Types.ttcn Iuh_CodecPort.ttcn Iuh_CodecPort_CtrlFunctDef.cc Iuh_CodecPort_CtrlFunct.ttcn Iuh_Emulation.ttcn DNS_Helpers.ttcn " FILES+="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="GTPv1C_CodecPort.ttcn GTPv1C_CodecPort_CtrlFunct.ttcn GTPv1C_CodecPort_CtrlFunctDef.cc GTPv1C_Templates.ttcn " FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Templates.ttcn " FILES+="GTP_Emulation.ttcn IPCP_Types.ttcn GSM_Types.ttcn " diff --git a/hnodeb/regen_makefile.sh b/hnodeb/regen_makefile.sh index cf5fed3..be7dec5 100755 --- a/hnodeb/regen_makefile.sh +++ b/hnodeb/regen_makefile.sh @@ -33,6 +33,7 @@
export CPPFLAGS_TTCN3=" -DIPA_EMULATION_CTRL + -DSTATSD_HAVE_VTY "
../regen-makefile.sh -e $NAME $FILES diff --git a/library/StatsD_Checker.ttcn b/library/StatsD_Checker.ttcnpp similarity index 94% rename from library/StatsD_Checker.ttcn rename to library/StatsD_Checker.ttcnpp index 2ad4c9f..ee299e4 100644 --- a/library/StatsD_Checker.ttcn +++ b/library/StatsD_Checker.ttcnpp @@ -33,8 +33,10 @@ import from StatsD_CodecPort_CtrlFunct all;
import from Osmocom_Types all; +#ifdef STATSD_HAVE_VTY import from Osmocom_VTY_Functions all; import from TELNETasp_PortType all; +#endif
modulepar { /* Whether to test stats values */ @@ -69,7 +71,9 @@ }
type component StatsD_Checker_CT { +#ifdef STATSD_HAVE_VTY port TELNETasp_PT STATSVTY; +#endif port STATSD_PROC_PT STATSD_PROC; port STATSD_CODEC_PT STATS; timer T_statsd := 5.0; @@ -107,6 +111,7 @@ "Could not bind StatsD socket, check your configuration"); }
+#ifdef STATSD_HAVE_VTY /* Connect to VTY and reset stats */ map(self:STATSVTY, system:STATSVTY); f_vty_set_prompts(STATSVTY); @@ -114,12 +119,18 @@
/* Reset the stats system at start */ f_vty_transceive(STATSVTY, "stats reset"); +#endif
while (true) { alt { [] STATSD_PROC.getcall(STATSD_reset:{}) -> sender vc_conn { +#ifdef STATSD_HAVE_VTY f_vty_transceive(STATSVTY, "stats reset"); STATSD_PROC.reply(STATSD_reset:{}) to vc_conn; +#else + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + "STATSD_reset not supported, StatsD_Checker was built without VTY support"); +#endif } [] STATSD_PROC.getcall(STATSD_expect:{?}) -> param(expects) sender vc_conn { var boolean success := f_statsd_checker_expect(expects); @@ -189,7 +200,11 @@ /* Dismiss any messages we might have skipped from the last report */ STATS.clear;
+#ifdef STATSD_HAVE_VTY f_vty_transceive(STATSVTY, "stats report"); +#else + /* Assume caller knows previous state, eg. gauges may have been 0 due to IUT being reset */ +#endif
var boolean seen_all := false; T_statsd.start; diff --git a/mgw/gen_links.sh b/mgw/gen_links.sh index 2fd2b0d..7662b55 100755 --- a/mgw/gen_links.sh +++ b/mgw/gen_links.sh @@ -46,7 +46,7 @@ FILES+="Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn " FILES+="Osmocom_VTY_Functions.ttcn " FILES+="RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc " FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
diff --git a/mgw/regen_makefile.sh b/mgw/regen_makefile.sh index 921956c..2b78cf0 100755 --- a/mgw/regen_makefile.sh +++ b/mgw/regen_makefile.sh @@ -25,6 +25,7 @@
export CPPFLAGS_TTCN3=" -DIPA_EMULATION_CTRL + -DSTATSD_HAVE_VTY "
../regen-makefile.sh -e $NAME $FILES diff --git a/ns/gen_links.sh b/ns/gen_links.sh index 8d78ddf..fde0a67 100755 --- a/ns/gen_links.sh +++ b/ns/gen_links.sh @@ -51,7 +51,7 @@
DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn Osmocom_Types.ttcn " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="RAW_NS.ttcnpp NS_Provider_IPL4.ttcn NS_Provider_FR.ttcn NS_Emulation.ttcnpp " FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn " FILES+="LLC_Templates.ttcn " diff --git a/ns/regen_makefile.sh b/ns/regen_makefile.sh index ad86d71..57dde2d 100755 --- a/ns/regen_makefile.sh +++ b/ns/regen_makefile.sh @@ -22,6 +22,7 @@ export CPPFLAGS_TTCN3=" -DBSSGP_EM_L3 -DNS_EMULATION_FR + -DSTATSD_HAVE_VTY "
../regen-makefile.sh -e $NAME $FILES diff --git a/pcu/gen_links.sh b/pcu/gen_links.sh index 556f02a..146f538 100755 --- a/pcu/gen_links.sh +++ b/pcu/gen_links.sh @@ -50,7 +50,7 @@
DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn GSM_RR_Types.ttcn GSM_RestOctets.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="RAW_NS.ttcnpp NS_Provider_IPL4.ttcn NS_Emulation.ttcnpp " FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn " FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn " diff --git a/pcu/regen_makefile.sh b/pcu/regen_makefile.sh index 006c6ba..9cb1554 100755 --- a/pcu/regen_makefile.sh +++ b/pcu/regen_makefile.sh @@ -22,6 +22,7 @@ export CPPFLAGS_TTCN3=" -DBSSGP_EM_L3 -DIPA_EMULATION_CTRL + -DSTATSD_HAVE_VTY "
../regen-makefile.sh -e $NAME $FILES diff --git a/upf/gen_links.sh b/upf/gen_links.sh index 3865110..6c710ee 100755 --- a/upf/gen_links.sh +++ b/upf/gen_links.sh @@ -29,7 +29,7 @@
DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn " -FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " FILES+="PFCP_CodecPort.ttcn PFCP_CodecPort_CtrlFunct.ttcn PFCP_CodecPort_CtrlFunctDef.cc PFCP_Emulation.ttcn PFCP_Templates.ttcn" gen_links $DIR $FILES
diff --git a/upf/regen_makefile.sh b/upf/regen_makefile.sh index 953e10f..1368db1 100755 --- a/upf/regen_makefile.sh +++ b/upf/regen_makefile.sh @@ -19,6 +19,7 @@
export CPPFLAGS_TTCN3=" -DIPA_EMULATION_CTRL + -DSTATSD_HAVE_VTY "
../regen-makefile.sh -e $NAME $FILES