lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

August 2024

  • 1 participants
  • 1478 discussions
[M] Change in osmo-ttcn3-hacks[master]: s1gw: Initial StatsD support
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958?usp=email ) Change subject: s1gw: Initial StatsD support ...................................................................... s1gw: Initial StatsD support Change-Id: Ib98c2fe68006a8d0f45de6966927b349a3b933ca --- M s1gw/S1GW_ConnHdlr.ttcn M s1gw/S1GW_Tests.cfg M s1gw/S1GW_Tests.ttcn M s1gw/gen_links.sh M s1gw/regen_makefile.sh 5 files changed, 43 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/58/37958/1 diff --git a/s1gw/S1GW_ConnHdlr.ttcn b/s1gw/S1GW_ConnHdlr.ttcn index bb2a309..6a1eb39 100644 --- a/s1gw/S1GW_ConnHdlr.ttcn +++ b/s1gw/S1GW_ConnHdlr.ttcn @@ -34,9 +34,13 @@ import from S1AP_Constants all; import from SCTP_Templates all; + +import from StatsD_Types all; +import from StatsD_Checker all; + import from S1AP_Server all; -type component ConnHdlr extends S1APSRV_ConnHdlr, PFCP_ConnHdlr { +type component ConnHdlr extends S1APSRV_ConnHdlr, PFCP_ConnHdlr, StatsD_ConnHdlr { var ConnHdlrPars g_pars; port S1AP_CODEC_PT S1AP_ENB; var ConnectionId g_s1ap_conn_id := -1; @@ -45,7 +49,8 @@ type record ConnHdlrPars { integer idx, - Global_ENB_ID genb_id + Global_ENB_ID genb_id, + charstring statsd_prefix }; template Global_ENB_ID @@ -59,9 +64,10 @@ } template (value) ConnHdlrPars -t_ConnHdlrPars(integer idx := 0) := { +t_ConnHdlrPars(integer idx := 0, charstring statsd_prefix := "") := { idx := idx, - genb_id := ts_Global_ENB_ID(idx) + genb_id := ts_Global_ENB_ID(idx), + statsd_prefix := statsd_prefix } type function void_fn(charstring id) runs on ConnHdlr; diff --git a/s1gw/S1GW_Tests.cfg b/s1gw/S1GW_Tests.cfg index dfcdbb9..54e7992 100644 --- a/s1gw/S1GW_Tests.cfg +++ b/s1gw/S1GW_Tests.cfg @@ -17,6 +17,8 @@ S1GW_Tests.mp_mme_bind_ip := "127.0.2.10"; S1GW_Tests.mp_s1gw_upf_ip := "127.0.3.1"; S1GW_Tests.mp_upf_bind_ip := "127.0.3.10"; +S1GW_Tests.mp_local_statsd_ip := "127.0.4.10"; +S1GW_Tests.mp_local_statsd_port := 8125; [MAIN_CONTROLLER] diff --git a/s1gw/S1GW_Tests.ttcn b/s1gw/S1GW_Tests.ttcn index 00b83e8..67c4267 100644 --- a/s1gw/S1GW_Tests.ttcn +++ b/s1gw/S1GW_Tests.ttcn @@ -34,6 +34,12 @@ import from PFCP_CodecPort all; import from SCTP_Templates all; + +import from StatsD_Types all; +import from StatsD_CodecPort all; +import from StatsD_CodecPort_CtrlFunct all; +import from StatsD_Checker all; + import from S1AP_Server all; import from S1GW_ConnHdlr all; @@ -44,12 +50,18 @@ charstring mp_mme_bind_ip := "127.0.2.10"; /* MME address on which we get connections from S1GW */ charstring mp_s1gw_upf_ip := "127.0.3.1"; /* UPF facing address of the S1GW */ charstring mp_upf_bind_ip := "127.0.3.10"; /* UPF address on which we get connections from S1GW */ + + /* Our emulated StatsD server: */ + charstring mp_local_statsd_ip := "127.0.4.10"; + integer mp_local_statsd_port := 8125; + charstring mp_statsd_prefix := "s1gw."; } -type component test_CT { +type component test_CT extends StatsD_Checker_CT { timer g_Tguard; var S1AP_Server_CT vc_S1APSRV; var PFCP_Emulation_CT vc_PFCP; + var StatsD_Checker_CT vc_STATSD; }; private altstep as_Tguard() runs on test_CT { @@ -64,6 +76,8 @@ g_Tguard.start(Tval); activate(as_Tguard()); + f_init_statsd("VirtHNBGW", vc_STATSD, mp_local_statsd_ip, mp_local_statsd_port); + if (s1apsrv_start) { f_init_s1ap_srv(); } @@ -95,12 +109,20 @@ vc_PFCP.start(PFCP_Emulation.main(pfcp_cfg)); } +function f_new_ConnHdlrPars(integer idx := 0) return ConnHdlrPars { + var ConnHdlrPars pars := valueof(t_ConnHdlrPars(idx, mp_statsd_prefix)); + return pars; +} + function f_ConnHdlr_spawn(void_fn fn, ConnHdlrPars pars) runs on test_CT return ConnHdlr { var ConnHdlr vc_conn; var charstring id := "ConnHdlr-" & testcasename() & "-" & int2str(pars.idx); vc_conn := ConnHdlr.create(id) alive; + if (isbound(vc_STATSD) and vc_STATSD.running) { + connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC); + } if (isbound(vc_S1APSRV) and vc_S1APSRV.running) { connect(vc_conn:S1AP_CONN, vc_S1APSRV:S1AP_CLIENT); connect(vc_conn:S1AP_PROC, vc_S1APSRV:S1AP_PROC); @@ -126,7 +148,7 @@ f_ConnHdlr_s1ap_unregister(g_pars.genb_id); } testcase TC_setup() runs on test_CT { - var ConnHdlrPars pars := valueof(t_ConnHdlrPars); + var ConnHdlrPars pars := f_new_ConnHdlrPars(); var ConnHdlr vc_conn; f_init(); @@ -140,7 +162,7 @@ f_init(); for (var integer i := 0; i < 42; i := i + 1) { - var ConnHdlrPars pars := valueof(t_ConnHdlrPars(i)); + var ConnHdlrPars pars := f_new_ConnHdlrPars(i); var ConnHdlr vc_conn := f_ConnHdlr_spawn(refers(f_TC_setup), pars); vc_conns := vc_conns & { vc_conn }; } @@ -168,7 +190,7 @@ f_ConnHdlr_s1ap_unregister(g_pars.genb_id); } testcase TC_conn_term_by_mme() runs on test_CT { - var ConnHdlrPars pars := valueof(t_ConnHdlrPars); + var ConnHdlrPars pars := f_new_ConnHdlrPars(); var ConnHdlr vc_conn; f_init(); @@ -188,7 +210,7 @@ setverdict(pass); } testcase TC_conn_term_mme_unavail() runs on test_CT { - var ConnHdlrPars pars := valueof(t_ConnHdlrPars); + var ConnHdlrPars pars := f_new_ConnHdlrPars(); var ConnHdlr vc_conn; f_init(s1apsrv_start := false); @@ -263,7 +285,7 @@ f_ConnHdlr_s1ap_unregister(g_pars.genb_id); } testcase TC_e_rab_setup() runs on test_CT { - var ConnHdlrPars pars := valueof(t_ConnHdlrPars); + var ConnHdlrPars pars := f_new_ConnHdlrPars(); var ConnHdlr vc_conn; f_init(); diff --git a/s1gw/gen_links.sh b/s1gw/gen_links.sh index ef8bdde..919e7f8 100755 --- a/s1gw/gen_links.sh +++ b/s1gw/gen_links.sh @@ -32,6 +32,7 @@ FILES+="PFCP_CodecPort.ttcn PFCP_CodecPort_CtrlFunct.ttcn PFCP_CodecPort_CtrlFunctDef.cc PFCP_Emulation.ttcn PFCP_Templates.ttcn " FILES+="S1AP_CodecPort.ttcn S1AP_CodecPort_CtrlFunctDef.cc S1AP_CodecPort_CtrlFunct.ttcn " FILES+="SCTP_Templates.ttcn " +FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcnpp " gen_links $DIR $FILES ignore_pp_results diff --git a/s1gw/regen_makefile.sh b/s1gw/regen_makefile.sh index 8c32b3d..adf765e 100755 --- a/s1gw/regen_makefile.sh +++ b/s1gw/regen_makefile.sh @@ -5,12 +5,14 @@ FILES=" *.asn *.ttcn + *.ttcnpp IPL4asp_PT.cc IPL4asp_discovery.cc Native_FunctionDefs.cc PFCP_CodecPort_CtrlFunctDef.cc S1AP_CodecPort_CtrlFunctDef.cc S1AP_EncDec.cc + StatsD_CodecPort_CtrlFunctdef.cc TCCConversion.cc TCCEncoding.cc TCCInterface.cc -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37958?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ib98c2fe68006a8d0f45de6966927b349a3b933ca Gerrit-Change-Number: 37958 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: s1gw: Print idx of component timing out
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37957?usp=email ) Change subject: s1gw: Print idx of component timing out ...................................................................... s1gw: Print idx of component timing out Change-Id: I354104dd88627a6d15e160d02f5ddf1072745a17 --- M s1gw/S1GW_ConnHdlr.ttcn 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/57/37957/1 diff --git a/s1gw/S1GW_ConnHdlr.ttcn b/s1gw/S1GW_ConnHdlr.ttcn index 091df1d..bb2a309 100644 --- a/s1gw/S1GW_ConnHdlr.ttcn +++ b/s1gw/S1GW_ConnHdlr.ttcn @@ -219,7 +219,7 @@ } [] T.timeout { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, - log2str("Timeout waiting for S1AP SetupReq")); + log2str("Timeout waiting for S1AP SetupReq, idx = ", g_pars.idx)); } } } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37957?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I354104dd88627a6d15e160d02f5ddf1072745a17 Gerrit-Change-Number: 37957 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: s1gw: ConnHdlr: Use stats reported by osmo-s1gw to expect PFCP Assoc ...
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37959?usp=email ) Change subject: s1gw: ConnHdlr: Use stats reported by osmo-s1gw to expect PFCP Assoc Setup ...................................................................... s1gw: ConnHdlr: Use stats reported by osmo-s1gw to expect PFCP Assoc Setup Change-Id: I329745125d78786fc9c243f0047cd394de9b16d4 --- M s1gw/S1GW_ConnHdlr.ttcn M s1gw/osmo-s1gw.config 2 files changed, 64 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/59/37959/1 diff --git a/s1gw/S1GW_ConnHdlr.ttcn b/s1gw/S1GW_ConnHdlr.ttcn index 6a1eb39..4505c1c 100644 --- a/s1gw/S1GW_ConnHdlr.ttcn +++ b/s1gw/S1GW_ConnHdlr.ttcn @@ -269,11 +269,22 @@ function f_ConnHdlr_register_pfcp() runs on ConnHdlr { f_pfcp_register(); - if (g_pars.idx == 0) { - /* First ConnHdlr answers the AssocSetup: */ - activate(as_pfcp_handle_assoc_setup_req(do_repeat := true)); - } else { + + /* First ConnHdlr answers the AssocSetup: */ + if (g_pars.idx != 0) { activate(as_pfcp_ignore(PFCP, tr_PFCP_Assoc_Setup_Req())); + return; + } + + var StatsDMetricKeys statsd_keys := { + valueof(ts_StatsDMetricKey(g_pars.statsd_prefix & "gauge.pfcp.associated.value", "g")) + }; + var StatsDMetrics statsd_snapshot := f_statsd_snapshot(statsd_keys, since_last_snapshot := false); + var boolean pfcp_associated := statsd_snapshot[0].val == 1; + + if (not pfcp_associated) { + log("Waiting for IUT to associate over PFCP"); + f_pfcp_wait_assoc_setup(); } } } diff --git a/s1gw/osmo-s1gw.config b/s1gw/osmo-s1gw.config index 86a89c1..8fcd994 100644 --- a/s1gw/osmo-s1gw.config +++ b/s1gw/osmo-s1gw.config @@ -32,6 +32,54 @@ {prefix, [" ", prefix, " ::"], ""}, " ", msg, {mfa, [" (", mfa, ":", line, ")"], ""}, - reset, "\n"]}}}}]}]}]. + reset, "\n"]}}}}]} + ] + }, + {exometer_core, + [{predefined, + [%{[erlang, memory], {function, erlang, memory, [], value, []}, []}, + %{[erlang, system_info], {function, erlang, system_info, ['$dp'], value, [process_count]}, []}, + %{[erlang, statistics], {function, erlang, statistics, ['$dp'], value, [run_queue]}, []}, + %{[erlang, io], {function, erlang, statistics, [io], match, {{'_', input}, {'_', output}}}, []} + ] + }, + {report, + [{reporters, + [%%{exometer_report_tty, []}, + {exometer_report_statsd, + [{hostname, "127.0.4.10"}, + {port, 8125}, + {prefix, "s1gw"}, + {type_map, []} + ] + } + ] + }, + {subscribers, + [%%{select, {[{ {['_' | '_'],'_','_'}, [], ['$_']}], + %% exometer_report_tty, value, 1000, true}} + {select, {[{ {['_' | '_'],counter,'_'}, [], ['$_']}], + exometer_report_statsd, + value, + 1000, + true, + [{report_type, counter}] + } + }, + {select, {[{ {['_' | '_'],gauge,'_'}, [], ['$_']}], + exometer_report_statsd, + value, + 1000, + true, + [{report_type, gauge}] + } + } + ] + } + ] + } + ] + } +]. %% vim:set ts=2 sw=2 et: -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37959?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I329745125d78786fc9c243f0047cd394de9b16d4 Gerrit-Change-Number: 37959 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: s1gw: TC_setup: Validate some metrics
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37960?usp=email ) Change subject: s1gw: TC_setup: Validate some metrics ...................................................................... s1gw: TC_setup: Validate some metrics Change-Id: Iae629bc9291ff8b6e482f61d692e4d97ff0136bd --- M s1gw/S1GW_Tests.ttcn 1 file changed, 28 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/60/37960/1 diff --git a/s1gw/S1GW_Tests.ttcn b/s1gw/S1GW_Tests.ttcn index 67c4267..e8dfe2b 100644 --- a/s1gw/S1GW_Tests.ttcn +++ b/s1gw/S1GW_Tests.ttcn @@ -140,11 +140,25 @@ f_ConnHdlr_register_pfcp(); f_ConnHdlr_s1ap_register(g_pars.genb_id); + /* Expected values relative to snapshot: */ + var StatsDExpects statsd_exp := { + {name := mp_statsd_prefix & "gauge.s1ap.enb.num_sctp_connections.value", mtype := "g", min := 1, max := 1}, + {name := mp_statsd_prefix & "ctr.s1ap.proxy.in_pkt.unmodified.value", mtype := "c", min := 2, max := 2} + } + var StatsDMetrics statsd_snapshot := f_statsd_snapshot(f_statsd_keys_from_expect(statsd_exp)); + f_ConnHdlr_s1ap_connect(mp_enb_bind_ip, mp_s1gw_enb_ip); f_ConnHdlr_s1ap_setup(g_pars.genb_id); f_sleep(0.5); /* keep the connection idle for some time */ + + f_statsd_expect_from_snapshot(statsd_exp, wait_converge := true, snapshot := statsd_snapshot); + f_ConnHdlr_s1ap_disconnect(); + /* Validate gauge decreases when we disconnect: */ + f_statsd_expect({{name := mp_statsd_prefix & "gauge.s1ap.enb.num_sctp_connections.value", mtype := "g", min := 0, max := 0}}, + wait_converge := true); + f_ConnHdlr_s1ap_unregister(g_pars.genb_id); } testcase TC_setup() runs on test_CT { @@ -156,6 +170,19 @@ vc_conn := f_ConnHdlr_spawn(refers(f_TC_setup), pars); vc_conn.done; } + +function f_TC_setup_multi(charstring id) runs on ConnHdlr { + f_ConnHdlr_register_pfcp(); + f_ConnHdlr_s1ap_register(g_pars.genb_id); + + f_ConnHdlr_s1ap_connect(mp_enb_bind_ip, mp_s1gw_enb_ip); + f_ConnHdlr_s1ap_setup(g_pars.genb_id); + f_sleep(0.5); /* keep the connection idle for some time */ + + f_ConnHdlr_s1ap_disconnect(); + + f_ConnHdlr_s1ap_unregister(g_pars.genb_id); +} testcase TC_setup_multi() runs on test_CT { var ConnHdlrList vc_conns := { }; @@ -163,7 +190,7 @@ for (var integer i := 0; i < 42; i := i + 1) { var ConnHdlrPars pars := f_new_ConnHdlrPars(i); - var ConnHdlr vc_conn := f_ConnHdlr_spawn(refers(f_TC_setup), pars); + var ConnHdlr vc_conn := f_ConnHdlr_spawn(refers(f_TC_setup_multi), pars); vc_conns := vc_conns & { vc_conn }; } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37960?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Iae629bc9291ff8b6e482f61d692e4d97ff0136bd Gerrit-Change-Number: 37960 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-ttcn3-hacks[master]: StatsD_Checker: Allow building and running without VTY support
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37956?usp=email ) Change subject: StatsD_Checker: Allow building and running without VTY support ...................................................................... StatsD_Checker: Allow building and running 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. New features are added to the public API of StatsD_Checker which make it possible to use it... * without "stats reset": Feature to take snapshots (f_statsd_snapshot()) which can later be used to validate expectancies with values relative to the snapshot, using API f_statsd_expect_from_snapshot(). This way, one can do: """ var StatsDExpects statsd_exp := { /* relative expectancies here... */ }; var StatsDMetrics statsd_snapshot := f_statsd_snapshot(f_statsd_keys_from_expect(statsd_exp)); /* do some test stuff here changing the state of the IUT... */ f_statsd_expect_from_snapshot(statsd_exp, snapshot := statsd_snapshot); """ * without polling ("stats report"), aka with periodict reporting: New parameter wait_converge in f_statsd_expect(), which allows overcoming race conditions with StatsD server processing older incoming metrics due to periodic reporting. This feature also allows a test to wait until a state changes in the IUT. 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 D library/StatsD_Checker.ttcn A library/StatsD_Checker.ttcnpp M library/StatsD_Types.ttcn 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 17 files changed, 483 insertions(+), 290 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/56/37956/1 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.ttcn deleted file mode 100644 index 2ad4c9f..0000000 --- a/library/StatsD_Checker.ttcn +++ /dev/null @@ -1,280 +0,0 @@ -module StatsD_Checker { - -/* Verifies that StatsD metrics in a test match the expected values - * Uses StatsD_CodecPort to receive the statsd messages from the DUT - * and a separate VTY connection to reset and trigger the stats. - * - * When using this you should configure your stats reporter to disable - * interval-based reports and always send all metrics: - * > stats interval 0 - * > stats reporter statsd - * > remote-ip a.b.c.d - * > remote-port 8125 - * > level subscriber - * > flush-period 1 - * > mtu 1024 - * > enable - * - * (C) 2020 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> - * All rights reserved. - * - * Author: Daniel Willmann <dwillmann(a)sysmocom.de> - * - * Released under the terms of GNU General Public License, Version 2 or - * (at your option) any later version. - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -import from Misc_Helpers all; -import from Socket_API_Definitions all; - -import from StatsD_Types all; -import from StatsD_CodecPort all; -import from StatsD_CodecPort_CtrlFunct all; - -import from Osmocom_Types all; -import from Osmocom_VTY_Functions all; -import from TELNETasp_PortType all; - -modulepar { - /* Whether to test stats values */ - boolean mp_enable_stats := true; -} - -type record StatsDExpect { - MetricName name, - MetricType mtype, - MetricValue min, - MetricValue max -}; - -type set of StatsDExpect StatsDExpects; - -type record StatsDExpectPriv { - StatsDExpect expect, - integer seen -} - -type set of StatsDExpectPriv StatsDExpectPrivs; - -type enumerated StatsDResultType { - e_Matched, - e_Mismatched, - e_NotFound -} - -type record StatsDExpectResult { - StatsDResultType kind, - integer idx -} - -type component StatsD_Checker_CT { - port TELNETasp_PT STATSVTY; - port STATSD_PROC_PT STATSD_PROC; - port STATSD_CODEC_PT STATS; - timer T_statsd := 5.0; -} - -type component StatsD_ConnHdlr { - port STATSD_PROC_PT STATSD_PROC; -} - -signature STATSD_reset(); -signature STATSD_expect(in StatsDExpects expects) return boolean; - -type port STATSD_PROC_PT procedure { - inout STATSD_reset, STATSD_expect; -} with {extension "internal"}; - -/* Expect templates and functions */ - - -/* StatsD checker component */ -function main(charstring statsd_host, integer statsd_port) runs on StatsD_Checker_CT { - var StatsD_ConnHdlr vc_conn; - var StatsDExpects expects; - var Result res; - - while (not mp_enable_stats) { - log("StatsD checker disabled by modulepar"); - f_sleep(3600.0); - } - - map(self:STATS, system:STATS); - res := StatsD_CodecPort_CtrlFunct.f_IPL4_listen(STATS, statsd_host, statsd_port, { udp := {} }, {}); - if (not ispresent(res.connId)) { - Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, - "Could not bind StatsD socket, check your configuration"); - } - - /* Connect to VTY and reset stats */ - map(self:STATSVTY, system:STATSVTY); - f_vty_set_prompts(STATSVTY); - f_vty_transceive(STATSVTY, "enable"); - - /* Reset the stats system at start */ - f_vty_transceive(STATSVTY, "stats reset"); - - while (true) { - alt { - [] STATSD_PROC.getcall(STATSD_reset:{}) -> sender vc_conn { - f_vty_transceive(STATSVTY, "stats reset"); - STATSD_PROC.reply(STATSD_reset:{}) to vc_conn; - } - [] STATSD_PROC.getcall(STATSD_expect:{?}) -> param(expects) sender vc_conn { - var boolean success := f_statsd_checker_expect(expects); - STATSD_PROC.reply(STATSD_expect:{expects} value success) to vc_conn; - } - } - } -} - - -/* Return false if the expectation doesn't match the metric, otherwise return true */ -private function f_compare_expect(StatsDMetric metric, StatsDExpect expect) return boolean { - if ((metric.name == expect.name) and (metric.mtype == expect.mtype) - and (metric.val >= expect.min) and (metric.val <= expect.max)) { - return true; - } else { - return false; - } -} - -private function f_statsd_checker_metric_expects(StatsDExpectPrivs exp_seen, StatsDMetric metric) -return StatsDExpectResult { - var StatsDExpectResult result := { - kind := e_NotFound, - idx := -1 - }; - - for (var integer i := 0; i < lengthof(exp_seen); i := i + 1) { - var StatsDExpectPriv exp := exp_seen[i]; - if (exp.expect.name != metric.name) { - continue; - } - if (not f_compare_expect(metric, exp.expect)) { - log("EXP mismatch: ", metric, " vs ", exp.expect); - result := { - kind := e_Mismatched, - idx := i - }; - break; - } else { - log("EXP match: ", metric, " vs ", exp.expect); - result := { - kind := e_Matched, - idx := i - }; - break; - } - } - return result; -} - -template StatsDExpectPriv t_statsd_expect_priv(template StatsDExpect expect) := { - expect := expect, - seen := 0 -} - -private function f_statsd_checker_expect(StatsDExpects expects) runs on StatsD_Checker_CT return boolean { - var default t; - var StatsDMessage msg; - var StatsDExpectResult res; - var StatsDExpectPrivs exp_seen := {}; - - for (var integer i := 0; i < lengthof(expects); i := i + 1) { - exp_seen := exp_seen & {valueof(t_statsd_expect_priv(expects[i]))}; - } - - /* Dismiss any messages we might have skipped from the last report */ - STATS.clear; - - f_vty_transceive(STATSVTY, "stats report"); - - var boolean seen_all := false; - T_statsd.start; - while (not seen_all) { - var StatsD_RecvFrom rf; - alt { - [] STATS.receive(tr_StatsD_RecvFrom(?, ?)) -> value rf { - msg := rf.msg; - } - [] T_statsd.timeout { - for (var integer i := 0; i < lengthof(exp_seen); i := i + 1) { - /* We're still missing some expects, keep looking */ - if (exp_seen[i].seen == 0) { - log("Timeout waiting for ", exp_seen[i].expect.name, " (min: ", exp_seen[i].expect.min, - ", max: ", exp_seen[i].expect.max, ")"); - } - } - setverdict(fail, "Timeout waiting for metrics"); - return false; - } - } - - for (var integer i := 0; i < lengthof(msg); i := i + 1) { - var StatsDMetric metric := msg[i]; - - res := f_statsd_checker_metric_expects(exp_seen, metric); - if (res.kind == e_NotFound) { - continue; - } - - if (res.kind == e_Mismatched) { - log("Metric: ", metric); - log("Expect: ", exp_seen[res.idx].expect); - setverdict(fail, "Metric failed expectation ", metric, " vs ", exp_seen[res.idx].expect); - return false; - } else if (res.kind == e_Matched) { - exp_seen[res.idx].seen := exp_seen[res.idx].seen + 1; - } - } - - /* Check if all expected metrics were received */ - seen_all := true; - for (var integer i := 0; i < lengthof(exp_seen); i := i + 1) { - /* We're still missing some expects, keep looking */ - if (exp_seen[i].seen == 0) { - seen_all := false; - break; - } - } - } - - T_statsd.stop; - return seen_all; -} - -function f_init_statsd(charstring id, inout StatsD_Checker_CT vc_STATSD, charstring local_addr, integer local_port) { - id := id & "-STATS"; - - vc_STATSD := StatsD_Checker_CT.create(id); - vc_STATSD.start(StatsD_Checker.main(local_addr, local_port)); -} - - -/* StatsD connhdlr */ -function f_statsd_reset() runs on StatsD_ConnHdlr { - if (not mp_enable_stats) { - return; - } - - STATSD_PROC.call(STATSD_reset:{}) { - [] STATSD_PROC.getreply(STATSD_reset:{}) {} - } -} - -function f_statsd_expect(StatsDExpects expects) runs on StatsD_ConnHdlr return boolean { - var boolean res; - - if (not mp_enable_stats) { - return true; - } - - STATSD_PROC.call(STATSD_expect:{expects}) { - [] STATSD_PROC.getreply(STATSD_expect:{expects}) -> value res; - } - return res; -} - -} diff --git a/library/StatsD_Checker.ttcnpp b/library/StatsD_Checker.ttcnpp new file mode 100644 index 0000000..ecadee3 --- /dev/null +++ b/library/StatsD_Checker.ttcnpp @@ -0,0 +1,444 @@ +module StatsD_Checker { + +/* Verifies that StatsD metrics in a test match the expected values + * Uses StatsD_CodecPort to receive the statsd messages from the DUT + * and a separate VTY connection to reset and trigger the stats. + * + * When using this you should configure your stats reporter to disable + * interval-based reports and always send all metrics: + * > stats interval 0 + * > stats reporter statsd + * > remote-ip a.b.c.d + * > remote-port 8125 + * > level subscriber + * > flush-period 1 + * > mtu 1024 + * > enable + * + * (C) 2020 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All rights reserved. + * + * Author: Daniel Willmann <dwillmann(a)sysmocom.de> + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +import from Misc_Helpers all; +import from Socket_API_Definitions all; + +import from StatsD_Types all; +import from StatsD_CodecPort all; +import from StatsD_CodecPort_CtrlFunct all; + +import from General_Types 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 */ + boolean mp_enable_stats := true; +} + +type record StatsDMetricKey { + MetricName name, + MetricType mtype +}; +type set of StatsDMetricKey StatsDMetricKeys; + +template (value) StatsDMetricKey ts_StatsDMetricKey(template (value) MetricName name, template (value) MetricType mtype) := { + name := name, + mtype := mtype +} + +type record StatsDExpect { + MetricName name, + MetricType mtype, + MetricValue min, + MetricValue max +}; +type set of StatsDExpect StatsDExpects; + +type enumerated StatsDResultType { + e_Matched, + e_Mismatched, + e_NotFound +} + +type record StatsDExpectResult { + StatsDResultType kind, + integer idx +} + +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; +} + +type component StatsD_ConnHdlr { + port STATSD_PROC_PT STATSD_PROC; +} + +signature STATSD_reset(); +signature STATSD_snapshot(in StatsDMetricKeys keys, in boolean since_last_snapshot) return StatsDMetrics; +signature STATSD_expect(in StatsDExpects expects, in boolean wait_converge, in boolean use_snapshot, in StatsDMetrics snapshot) return boolean; + +type port STATSD_PROC_PT procedure { + inout STATSD_reset, STATSD_snapshot, STATSD_expect; +} with {extension "internal"}; + +/* Expect templates and functions */ + + +/* StatsD checker component */ +function main(charstring statsd_host, integer statsd_port) runs on StatsD_Checker_CT { + var StatsD_ConnHdlr vc_conn; + var StatsDMetricKeys keys; + var boolean since_last_snapshot; + var StatsDExpects expects; + var boolean wait_converge; + var boolean use_snapshot; + var StatsDMetrics snapshot; + var Result res; + + while (not mp_enable_stats) { + log("StatsD checker disabled by modulepar"); + f_sleep(3600.0); + } + + map(self:STATS, system:STATS); + res := StatsD_CodecPort_CtrlFunct.f_IPL4_listen(STATS, statsd_host, statsd_port, { udp := {} }, {}); + if (not ispresent(res.connId)) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + "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); + f_vty_transceive(STATSVTY, "enable"); + + /* 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_snapshot:{?, ?}) -> param(keys, since_last_snapshot) sender vc_conn { + snapshot := f_statsd_checker_snapshot(keys, since_last_snapshot); + STATSD_PROC.reply(STATSD_snapshot:{keys, since_last_snapshot} value snapshot) to vc_conn; + } + [] STATSD_PROC.getcall(STATSD_expect:{?, ?, ?, ?}) -> param(expects, wait_converge, use_snapshot, snapshot) sender vc_conn { + var boolean success := f_statsd_checker_expect(expects, wait_converge, use_snapshot, snapshot); + STATSD_PROC.reply(STATSD_expect:{expects, wait_converge, use_snapshot, snapshot} value success) to vc_conn; + } + } + } +} + +/* Updates "metrics" & "seen" with content from "it". Returns true if the metric becomes known (for first time) as a result. */ +private function f_statsd_metrics_update_value(inout StatsDMetrics metrics, inout Booleans seen, StatsDMetric it) return boolean +{ + for (var integer i := 0; i < lengthof(metrics); i := i + 1) { + log("Rx new metric ", it); + if (it.name != metrics[i].name or it.mtype != metrics[i].mtype) { + log("PESPIN: metric[",i,"] ", it, " doesn't match ", metrics[i]); + continue; + } + metrics[i] := it; + log("PESPIN: metric[",i,"] seen =", seen[i]); + if (seen[i]) { + return false; + } else { + seen[i] := true; + return true; + } + } + return false; +} + + +private function f_statsd_checker_snapshot(StatsDMetricKeys keys, boolean since_last_snapshot := true) runs on StatsD_Checker_CT return StatsDMetrics { + var default t; + var StatsDMessage msg; + var StatsDMetrics metrics := {}; + var Booleans seen := {}; + var integer seen_remain := 0; + + for (var integer i := 0; i < lengthof(keys); i := i + 1) { + metrics := metrics & {valueof(ts_StatsDMetric(keys[i].name, 0, keys[i].mtype))}; + seen := seen & {false}; + seen_remain := seen_remain + 1; + } + + if (not since_last_snapshot) { + STATS.clear; + } + + T_statsd.start; + while (seen_remain > 0) { + var StatsD_RecvFrom rf; + alt { + [] STATS.receive(tr_StatsD_RecvFrom(?, ?)) -> value rf { + msg := rf.msg; + } + [] T_statsd.timeout { + for (var integer i := 0; i < lengthof(metrics); i := i + 1) { + /* We're still missing some expects, keep looking */ + if (not seen[i]) { + log("Timeout waiting for ", metrics[i].name); + } + } + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Timeout waiting for metrics: ", keys, seen)); + } + } + + for (var integer i := 0; i < lengthof(msg); i := i + 1) { + var StatsDMetric metric := msg[i]; + if (f_statsd_metrics_update_value(metrics, seen, metric)) { + seen_remain := seen_remain - 1; + } + } + } + T_statsd.stop; + + return metrics; +} + +private function get_val_from_snapshot(inout integer val, StatsDMetric metric, StatsDMetrics snapshot) return boolean +{ + for (var integer i := 0; i < lengthof(snapshot); i := i + 1) { + if (metric.name != snapshot[i].name or metric.mtype != snapshot[i].mtype) { + continue; + } + val := snapshot[i].val; + return true; + } + return false; +} + +/* Return false if the expectation doesn't match the metric, otherwise return true */ +private function f_compare_expect(StatsDMetric metric, + StatsDExpect expect, + boolean use_snapshot := false, + StatsDMetrics snapshot := {}) return boolean { + var integer val := 0; + if ((metric.name != expect.name) or (metric.mtype != expect.mtype)) { + return false; + } + if (use_snapshot) { + var integer prev_val := 0; + if (not get_val_from_snapshot(prev_val, metric, snapshot)) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Metric ", metric.name, " not found in snapshot ", snapshot)); + } + val := metric.val - prev_val; + } else { + val := metric.val; + } + + if ((val < expect.min) or (val > expect.max)) { + return false; + } + return true; +} + +private function f_statsd_checker_metric_expects(StatsDExpects expects, + StatsDMetric metric, + boolean use_snapshot := false, + StatsDMetrics snapshot := {}) +return StatsDExpectResult { + var StatsDExpectResult result := { + kind := e_NotFound, + idx := -1 + }; + + for (var integer i := 0; i < lengthof(expects); i := i + 1) { + var StatsDExpect exp := expects[i]; + if (exp.name != metric.name) { + continue; + } + if (not f_compare_expect(metric, exp, use_snapshot, snapshot)) { + log("EXP mismatch: ", metric, " vs exp ", exp, " | use_snapshot=", use_snapshot, ", snapshot=", snapshot); + result := { + kind := e_Mismatched, + idx := i + }; + break; + } else { + log("EXP match: ", metric, " vs exp ", exp); + result := { + kind := e_Matched, + idx := i + }; + break; + } + } + return result; +} + +private function f_statsd_checker_expect(StatsDExpects expects, + boolean wait_converge := false, + boolean use_snapshot := false, + StatsDMetrics snapshot := {}) runs on StatsD_Checker_CT return boolean { + var default t; + var StatsDMessage msg; + var StatsDExpectResult res; + var Booleans matched := {}; + var integer matched_remain := 0; + + for (var integer i := 0; i < lengthof(expects); i := i + 1) { + matched := matched & {false}; + matched_remain := matched_remain + 1; + } + + /* Dismiss any messages we might have skipped from the last report */ + STATS.clear; + + if (not use_snapshot) { +#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 + } + + T_statsd.start; + while (matched_remain > 0) { + var StatsD_RecvFrom rf; + alt { + [] STATS.receive(tr_StatsD_RecvFrom(?, ?)) -> value rf { + msg := rf.msg; + } + [] T_statsd.timeout { + for (var integer i := 0; i < lengthof(expects); i := i + 1) { + /* We're still missing some expects, keep looking */ + if (not matched[i]) { + log("Timeout waiting for ", expects[i].name, + " (min: ", expects[i].min, ", max: ", expects[i].max, ")"); + } + } + setverdict(fail, "Timeout waiting for metrics"); + return false; + } + } + + for (var integer i := 0; i < lengthof(msg); i := i + 1) { + var StatsDMetric metric := msg[i]; + res := f_statsd_checker_metric_expects(expects, metric, use_snapshot, snapshot); + if (res.kind == e_NotFound) { + continue; + } + if (res.kind == e_Mismatched) { + if (wait_converge and not matched[res.idx]) { + log("Waiting convergence: Ignoring metric mismatch metric=", metric, " expect=", expects[res.idx]) + continue; + } + log("Metric: ", metric); + log("Expect: ", expects[res.idx]); + setverdict(fail, "Metric failed expectation ", metric, " vs ", expects[res.idx]); + return false; + } + if (res.kind == e_Matched) { + if (not matched[res.idx]) { + matched[res.idx] := true; + matched_remain := matched_remain - 1; + } + continue; + } + } + } + T_statsd.stop; + return true; +} + +function f_init_statsd(charstring id, inout StatsD_Checker_CT vc_STATSD, charstring local_addr, integer local_port) { + id := id & "-STATS"; + + vc_STATSD := StatsD_Checker_CT.create(id); + vc_STATSD.start(StatsD_Checker.main(local_addr, local_port)); +} + + +/* StatsD connhdlr */ +function f_statsd_reset() runs on StatsD_ConnHdlr { + if (not mp_enable_stats) { + return; + } + + STATSD_PROC.call(STATSD_reset:{}) { + [] STATSD_PROC.getreply(STATSD_reset:{}) {} + } +} + +/* Useful to automatically generate param for f_statsd_snapshot() from StatsDExpects used in f_statsd_expect_from_snapshot() */ +function f_statsd_keys_from_expect(StatsDExpects expects) return StatsDMetricKeys +{ + var StatsDMetricKeys keys := {} + for (var integer i := 0; i < lengthof(expects); i := i + 1) { + keys := keys & {valueof(ts_StatsDMetricKey(expects[i].name, expects[i].mtype))} + } + return keys; +} + +/* Retrieve current values obtained at statsd server. +* If since_last_snapshot is false, then clear the received packets in port. */ +function f_statsd_snapshot(StatsDMetricKeys keys, boolean since_last_snapshot := true) runs on StatsD_ConnHdlr return StatsDMetrics { + var StatsDMetrics snapshot; + if (not mp_enable_stats) { + return {}; + } + + STATSD_PROC.call(STATSD_snapshot:{keys, since_last_snapshot}) { + [] STATSD_PROC.getreply(STATSD_snapshot:{keys, since_last_snapshot}) -> value snapshot; + } + return snapshot; +} + +function f_statsd_expect(StatsDExpects expects, boolean wait_converge := false) runs on StatsD_ConnHdlr return boolean { + var boolean res; + + if (not mp_enable_stats) { + return true; + } + + STATSD_PROC.call(STATSD_expect:{expects, wait_converge, false, {}}) { + [] STATSD_PROC.getreply(STATSD_expect:{expects, wait_converge, false, {}}) -> value res; + } + return res; +} + +function f_statsd_expect_from_snapshot(StatsDExpects expects, boolean wait_converge := false, + StatsDMetrics snapshot := {}) runs on StatsD_ConnHdlr return boolean { + var boolean res; + + if (not mp_enable_stats) { + return true; + } + + STATSD_PROC.call(STATSD_expect:{expects, wait_converge, true, snapshot}) { + [] STATSD_PROC.getreply(STATSD_expect:{expects, wait_converge, true, snapshot}) -> value res; + } + return res; +} + +} diff --git a/library/StatsD_Types.ttcn b/library/StatsD_Types.ttcn index 8938571..e60b8e8 100644 --- a/library/StatsD_Types.ttcn +++ b/library/StatsD_Types.ttcn @@ -33,6 +33,7 @@ MetricType mtype, MetricSampleRate srate optional }; +type set of StatsDMetric StatsDMetrics; type record of StatsDMetric StatsDMessage with { variant "SEPARATOR('\n')"; @@ -48,7 +49,8 @@ [0] := metric } -template (present) StatsDMetric tr_StatsDMetric(template (present) MetricName name, template (present) MetricValue val := ?, +template (present) StatsDMetric tr_StatsDMetric(template (present) MetricName name, + template (present) MetricValue val := ?, template (present) MetricType mtype) := { name := name, val := val, @@ -56,10 +58,30 @@ srate := * } -template (present) StatsDMetric tr_StatsDMetricCounter(template (present) MetricName name, template (present) MetricValue val := ?) := +template (present) StatsDMetric tr_StatsDMetricCounter(template (present) MetricName name, + template (present) MetricValue val := ?) := tr_StatsDMetric(name, val, "c"); -template (present) StatsDMetric tr_StatsDMetricGauge(template (present) MetricName name, template (present) MetricValue val := ?) := +template (present) StatsDMetric tr_StatsDMetricGauge(template (present) MetricName name, + template (present) MetricValue val := ?) := tr_StatsDMetric(name, val, "g"); +template (value) StatsDMetric ts_StatsDMetric(template (value) MetricName name, + template (value) MetricValue val := 0, + template (value) MetricType mtype := "c", + template (omit) MetricSampleRate srate := omit) := { + name := name, + val := val, + mtype := mtype, + srate := srate +} + +template (value) StatsDMetric ts_StatsDMetricCounter(template (value) MetricName name, + template (value) MetricValue val := 0) := + ts_StatsDMetric(name, val, "c"); + +template (value) StatsDMetric ts_StatsDMetricGauge(template (value) MetricName name, + template (value) MetricValue val := 0) := + ts_StatsDMetric(name, val, "g"); + } with { encode "TEXT" } 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 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37956?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I5421c76e4f303fd16d4db945a1c69910e40ac820 Gerrit-Change-Number: 37956 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in ...osmo-s1gw[master]: Introduce initial metrics support
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37955?usp=email ) Change subject: Introduce initial metrics support ...................................................................... Introduce initial metrics support metrics are implemented with the "exometer" library. A reference config to export the metrics through statsd is provided. Change-Id: I952e198238384dca4be94f91a01d7cfff0a1471f --- M config/sys.config A include/s1gw_metrics.hrl M rebar.config M rebar.lock M src/osmo_s1gw.app.src M src/osmo_s1gw_sup.erl M src/pfcp_peer.erl M src/s1ap_proxy.erl A src/s1gw_metrics.erl M src/sctp_proxy.erl M src/sctp_server.erl A test/exometer_mock.erl M test/s1ap_proxy_test.erl 13 files changed, 330 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/55/37955/1 diff --git a/config/sys.config b/config/sys.config index 45a14cb..d405db8 100644 --- a/config/sys.config +++ b/config/sys.config @@ -35,6 +35,54 @@ {prefix, [" ", prefix, " ::"], ""}, " ", msg, {mfa, [" (", mfa, ":", line, ")"], ""}, - reset, "\n"]}}}}]}]}]. + reset, "\n"]}}}}]} + ] + }, + {exometer_core, + [{predefined, + [%{[erlang, memory], {function, erlang, memory, [], value, []}, []}, + %{[erlang, system_info], {function, erlang, system_info, ['$dp'], value, [process_count]}, []}, + %{[erlang, statistics], {function, erlang, statistics, ['$dp'], value, [run_queue]}, []}, + %{[erlang, io], {function, erlang, statistics, [io], match, {{'_', input}, {'_', output}}}, []} + ] + }, + {report, + [{reporters, + [%%{exometer_report_tty, []}, + {exometer_report_statsd, + [{hostname, "127.0.4.10"}, + {port, 8125}, + {prefix, "s1gw"}, + {type_map, []} + ] + } + ] + }, + {subscribers, + [%%{select, {[{ {['_' | '_'],'_','_'}, [], ['$_']}], + %% exometer_report_tty, value, 1000, true}} + {select, {[{ {['_' | '_'],counter,'_'}, [], ['$_']}], + exometer_report_statsd, + value, + 1000, + true, + [{report_type, counter}] + } + }, + {select, {[{ {['_' | '_'],gauge,'_'}, [], ['$_']}], + exometer_report_statsd, + value, + 1000, + true, + [{report_type, gauge}] + } + } + ] + } + ] + } + ] + } +]. %% vim:set ts=2 sw=2 et: diff --git a/include/s1gw_metrics.hrl b/include/s1gw_metrics.hrl new file mode 100644 index 0000000..99410f1 --- /dev/null +++ b/include/s1gw_metrics.hrl @@ -0,0 +1,28 @@ +-define(S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TX, [ctr, pfcp, assoc_setup_req, tx]). +-define(S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TIMEOUT, [ctr, pfcp, assoc_setup_req, timeout]). +-define(S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX, [ctr, pfcp, assoc_setup_resp, rx]). +-define(S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_ACK, [ctr, pfcp, assoc_setup_resp, rx_ack]). +-define(S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_NACK, [ctr, pfcp, assoc_setup_resp, rx_nack]). +-define(S1GW_CTR_S1AP_ENB_ALL_RX, [ctr, s1ap, enb, all, rx]). +-define(S1GW_CTR_S1AP_ENB_ALL_RX_UNKNOWN_ENB, [ctr, s1ap, enb, all, rx_unknown_enb]). +-define(S1GW_CTR_S1AP_PROXY_UPLINK_PACKETS_QUEUED, [ctr, s1ap, proxy, uplink_packets_queued]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT, [ctr, s1ap, proxy, in_pkt]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ALL, [ctr, s1ap, proxy, in_pkt, all]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_DECODE_ERROR, [ctr, s1ap, proxy, in_pkt, decode_error]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_UNMODIFIED, [ctr, s1ap, proxy, in_pkt, unmodified]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ, [ctr, s1ap, proxy, in_pkt, erab_setup_req]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ_FAILED, [ctr, s1ap, proxy, in_pkt, erab_setup_req_failed]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_RSP, [ctr, s1ap, proxy, in_pkt, erab_setup_rsp]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_CMD, [ctr, s1ap, proxy, in_pkt, erab_release_cmd]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_RSP, [ctr, s1ap, proxy, in_pkt, erab_release_rsp]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_MOD_IND, [ctr, s1ap, proxy, in_pkt, erab_mod_ind]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_REQ, [ctr, s1ap, proxy, in_pkt, init_ctx_req]). +-define(S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_RSP, [ctr, s1ap, proxy, in_pkt, init_ctx_rsp]). + +-define(S1GW_GAUGE_PFCP_ASSOCIATED, [gauge, pfcp, associated]). +-define(S1GW_GAUGE_S1AP_ENB_NUM_SCTP_CONNECTIONS, [gauge, s1ap, enb, num_sctp_connections]). +-define(S1GW_GAUGE_S1AP_PROXY_UPLINK_PACKETS_QUEUED, [gauge, s1ap, proxy, uplink_packets_queued]). + +%% NOTE: Remember to add new entries to s1gw_metric:init()! + +%% vim:set ts=4 sw=4 et: diff --git a/rebar.config b/rebar.config index 91bd759..5f0fcda 100644 --- a/rebar.config +++ b/rebar.config @@ -8,7 +8,11 @@ {deps, [{logger_color_formatter, {git, "https://github.com/rlipscombe/logger_color_formatter.git", {tag, "0.5.0"}}}, {pfcplib, - {git, "https://github.com/travelping/pfcplib.git", {branch, "master"}}} + {git, "https://github.com/travelping/pfcplib.git", {branch, "master"}}}, + {exometer_core, + {git, "https://github.com/osmocom/exometer_core.git", {branch, "osmocom/master"}}}, + {exometer_report_statsd, + {git, "https://github.com/esl/exometer_report_statsd.git", {branch, "master"}}} ]}. %% test deps diff --git a/rebar.lock b/rebar.lock index 3b99c22..c9c20c5 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,16 +1,33 @@ {"1.2.0", [{<<"cut">>,{pkg,<<"cut">>,<<"1.0.3">>},1}, + {<<"exometer_core">>, + {git,"https://github.com/osmocom/exometer_core.git", + {ref,"f9c7abc095edc893c9354a3d5f061715de1d9e79"}}, + 0}, + {<<"exometer_report_statsd">>, + {git,"https://github.com/esl/exometer_report_statsd.git", + {ref,"f1c369becb6e57871f1c7b0e491f6c3a302a65ee"}}, + 0}, + {<<"hut">>,{pkg,<<"hut">>,<<"1.3.0">>},1}, {<<"logger_color_formatter">>, {git,"https://github.com/rlipscombe/logger_color_formatter.git", {ref,"f1c96f979e6350f8cd787d27fe9ff003cbf3416b"}}, 0}, + {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.1">>},1}, {<<"pfcplib">>, {git,"https://github.com/travelping/pfcplib.git", {ref,"e505c0a4c05f5f14a2c40c7ebf36db62cc911d93"}}, - 0}]}. + 0}, + {<<"setup">>,{pkg,<<"setup">>,<<"2.1.0">>},1}]}. [ {pkg_hash,[ - {<<"cut">>, <<"1577F2F3BC0F2BF3B97903B7426F8A3D79523687B6A444D0F59A095EF69A0E81">>}]}, + {<<"cut">>, <<"1577F2F3BC0F2BF3B97903B7426F8A3D79523687B6A444D0F59A095EF69A0E81">>}, + {<<"hut">>, <<"71F2F054E657C03F959CF1ACC43F436EA87580696528CA2A55C8AFB1B06C85E7">>}, + {<<"parse_trans">>, <<"6E6AA8167CB44CC8F39441D05193BE6E6F4E7C2946CB2759F015F8C56B76E5FF">>}, + {<<"setup">>, <<"05F69185A5EB71474C9BC6BA892565651EC7507791F85632B7B914DBFE130510">>}]}, {pkg_hash_ext,[ - {<<"cut">>, <<"1A4A25DB2B7C5565FD28B314A4EEB898B1ED3CAFFA1AB09149345FB5731ED04B">>}]} + {<<"cut">>, <<"1A4A25DB2B7C5565FD28B314A4EEB898B1ED3CAFFA1AB09149345FB5731ED04B">>}, + {<<"hut">>, <<"7E15D28555D8A1F2B5A3A931EC120AF0753E4853A4C66053DB354F35BF9AB563">>}, + {<<"parse_trans">>, <<"620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A">>}, + {<<"setup">>, <<"EFD072578F0CF85BEA96CAAFFC7ADB0992398272522660A136E10567377071C5">>}]} ]. diff --git a/src/osmo_s1gw.app.src b/src/osmo_s1gw.app.src index 8bb89de..363d6d6 100644 --- a/src/osmo_s1gw.app.src +++ b/src/osmo_s1gw.app.src @@ -8,7 +8,9 @@ kernel, stdlib, logger_color_formatter, - pfcplib + pfcplib, + exometer_core, + exometer_report_statsd ]}, {modules, []}, {mod, {osmo_s1gw_app, []}}, diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index c6adb55..32272bf 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -81,6 +81,7 @@ worker, [pfcp_peer]}, + s1gw_metrics:init(), {ok, {{one_for_one, 5, 10}, [SctpServer, PfcpPeer]}}. diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index 44956da..0a41f1e 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -50,6 +50,7 @@ -include_lib("kernel/include/logger.hrl"). -include_lib("pfcplib/include/pfcp_packet.hrl"). +-include("s1gw_metrics.hrl"). %% 3GPP TS 29.244, section 4.2 "UDP Header and Port Numbers" -define(PFCP_PORT, 8805). @@ -132,6 +133,7 @@ init([LocAddr, RemAddr]) -> process_flag(trap_exit, true), + s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 0), {ok, Sock} = gen_udp:open(?PFCP_PORT, [binary, {ip, LocAddr}, {reuseaddr, true}, @@ -153,6 +155,7 @@ connecting(enter, OldState, #peer_state{} = S0) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), + s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 0), %% Tx PFCP Association Setup {ok, S1} = send_assoc_setup(S0), {keep_state, S1, [{state_timeout, 2_000, assoc_setup_timeout}]}; @@ -161,6 +164,7 @@ connecting(state_timeout, assoc_setup_timeout, S) -> % Re-start sending PFCP Association Setup above: ?LOG_NOTICE("PFCP Association Setup timeout, UPF may be down, retrying..."), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TIMEOUT), {repeat_state, S}; %% Handle incoming PFCP PDU(s) @@ -170,10 +174,14 @@ #pfcp{type = association_setup_response, ie = #{pfcp_cause := 'Request accepted'}} -> ?LOG_INFO("Rx Association Setup Response (Request accepted)"), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_ACK), {next_state, connected, S}; #pfcp{type = association_setup_response, ie = #{pfcp_cause := Cause}} -> ?LOG_ERROR("Rx Association Setup Response (~p)", [Cause]), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_NACK), {stop, {shutdown, assoc_setup_nack}}; PDU -> ?LOG_NOTICE("Rx unexpected PFCP PDU: ~p", [PDU]), @@ -187,6 +195,7 @@ %% CONNECTED state connected(enter, OldState, S) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), + s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 1), {keep_state, S}; connected({call, From}, @@ -252,7 +261,8 @@ ?LOG_NOTICE("Terminating in state ~p, reason ~p", [State, Reason]), case State of connected -> - send_assoc_release(S); + send_assoc_release(S), + s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 0); _ -> nop end, @@ -368,6 +378,7 @@ send_assoc_setup(S) -> IEs = #{node_id => #node_id{id = get_node_id(S)}, recovery_time_stamp => #recovery_time_stamp{time = get_recovery_timestamp()}}, + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TX), send_pdu({association_setup_request, IEs}, S). diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index e076387..00f218f 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -43,6 +43,8 @@ -include_lib("kernel/include/logger.hrl"). +-include("s1gw_metrics.hrl"). + -include("S1AP-PDU-Descriptions.hrl"). -include("S1AP-PDU-Contents.hrl"). -include("S1AP-Containers.hrl"). @@ -80,12 +82,14 @@ %% Process an S1AP PDU -spec handle_pdu(binary(), proxy_state()) -> {binary() | undefined, binary() | undefined, proxy_state()}. handle_pdu(Data, S) when is_binary(Data) -> + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL), case decode_pdu(Data) of {ok, Pdu} -> ?LOG_INFO("S1AP PDU: ~p", [Pdu]), handle_pdu(Data, Pdu, S); {error, {asn1, Error}} -> ?LOG_ERROR("S1AP PDU decoding failed: ~p", [Error]), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_DECODE_ERROR), {Data, undefined, S} end. @@ -150,11 +154,13 @@ #'InitiatingMessage'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB SETUP REQUEST"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ), Result = handle_ies(Content#'E-RABSetupRequest'.protocolIEs, ?'id-E-RABToBeSetupListBearerSUReq', S0), case Result of {error, Reason, S1} -> ?LOG_NOTICE("Patching E-RAB SETUP REQUEST failed: ~p", [Reason]), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ_FAILED), %% Send E-RABSetupResponse with error to ENB... ?LOG_NOTICE("Tx RABSetupResponse(~p, ~p) to MME", [S1#proxy_state.mme_ue_id, S1#proxy_state.enb_ue_id]), ReplyPdu = build_erab_setup_response_failure(S1), @@ -170,6 +176,7 @@ #'SuccessfulOutcome'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB SETUP RESPONSE"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_RSP), {IEs, S1} = handle_ies(Content#'E-RABSetupResponse'.protocolIEs, ?'id-E-RABSetupListBearerSURes', S0), NewContent = Content#'E-RABSetupResponse'{protocolIEs = IEs}, @@ -182,6 +189,7 @@ #'InitiatingMessage'{procedureCode = ?'id-E-RABRelease', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Processing E-RAB RELEASE COMMAND"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_CMD), {IEs, S1} = handle_ies(Content#'E-RABReleaseCommand'.protocolIEs, ?'id-E-RABToBeReleasedList', S0), NewContent = Content#'E-RABReleaseCommand'{protocolIEs = IEs}, @@ -192,6 +200,7 @@ #'SuccessfulOutcome'{procedureCode = ?'id-E-RABRelease', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Processing E-RAB RELEASE RESPONSE"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_RSP), {IEs, S1} = handle_ies(Content#'E-RABReleaseResponse'.protocolIEs, ?'id-E-RABReleaseListBearerRelComp', S0), NewContent = Content#'E-RABReleaseResponse'{protocolIEs = IEs}, @@ -202,6 +211,7 @@ #'InitiatingMessage'{procedureCode = ?'id-E-RABModificationIndication', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB MODIFICATION INDICATION"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_MOD_IND), IEs = Content#'E-RABModificationIndication'.protocolIEs, %% E-RAB to be Modified List {IEs1, S1} = handle_ies(IEs, ?'id-E-RABToBeModifiedListBearerModInd', S0), @@ -215,6 +225,7 @@ #'InitiatingMessage'{procedureCode = ?'id-InitialContextSetup', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP REQUEST"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_REQ), {IEs, S1} = handle_ies(Content#'InitialContextSetupRequest'.protocolIEs, ?'id-E-RABToBeSetupListCtxtSUReq', S0), NewContent = Content#'InitialContextSetupRequest'{protocolIEs = IEs}, @@ -225,6 +236,7 @@ #'SuccessfulOutcome'{procedureCode = ?'id-InitialContextSetup', value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP RESPONSE"), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_RSP), {IEs, S1} = handle_ies(Content#'InitialContextSetupResponse'.protocolIEs, ?'id-E-RABSetupListCtxtSURes', S0), NewContent = Content#'InitialContextSetupResponse'{protocolIEs = IEs}, @@ -239,6 +251,7 @@ %% Proxy all other messages unmodified handle_pdu(Data, _Pdu, S) -> + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_IN_PKT_UNMODIFIED), {Data, undefined, S}. diff --git a/src/s1gw_metrics.erl b/src/s1gw_metrics.erl new file mode 100644 index 0000000..8df2bc4 --- /dev/null +++ b/src/s1gw_metrics.erl @@ -0,0 +1,162 @@ +%% Copyright (C) 2024 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> +%% Author: Pau Espin Pedrol <pespin(a)sysmocom.de> +%% +%% All Rights Reserved +%% +%% SPDX-License-Identifier: AGPL-3.0-or-later +%% +%% This program is free software; you can redistribute it and/or modify +%% it under the terms of the GNU Affero General Public License as +%% published by the Free Software Foundation; either version 3 of the +%% License, or (at your option) any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU Affero General Public License +%% along with this program. If not, see <https://www.gnu.org/licenses/>. +%% +%% Additional Permission under GNU AGPL version 3 section 7: +%% +%% If you modify this Program, or any covered work, by linking or +%% combining it with runtime libraries of Erlang/OTP as released by +%% Ericsson on https://www.erlang.org (or a modified version of these +%% libraries), containing parts covered by the terms of the Erlang Public +%% License (https://www.erlang.org/EPLICENSE) the licensors of this +%% Program grant you additional permission to convey the resulting work +%% without the need to license the runtime libraries of Erlang/OTP under +%% the GNU Affero General Public License. Corresponding Source for a +%% non-source form of such a combination shall include the source code +%% for the parts of the runtime libraries of Erlang/OTP used as well as +%% that of the covered work. + +-module(s1gw_metrics). + +-export([init/0, + ctr_reset/1, + ctr_inc/1, + ctr_inc/2, + gauge_reset/1, + gauge_set/2, + gauge_inc/1, + gauge_inc/2, + gauge_dec/1]). + +-include_lib("kernel/include/logger.hrl"). +-include("s1gw_metrics.hrl"). + +-define(S1GW_COUNTERS, [ + ?S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TX, + ?S1GW_CTR_PFCP_ASSOC_SETUP_REQ_TIMEOUT, + ?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX, + ?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_ACK, + ?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_NACK, + ?S1GW_CTR_S1AP_ENB_ALL_RX, + ?S1GW_CTR_S1AP_ENB_ALL_RX_UNKNOWN_ENB, + ?S1GW_CTR_S1AP_PROXY_UPLINK_PACKETS_QUEUED, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_DECODE_ERROR, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_UNMODIFIED, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_REQ_FAILED, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_SETUP_RSP, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_CMD, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_RELEASE_RSP, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_ERAB_MOD_IND, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_REQ, + ?S1GW_CTR_S1AP_PROXY_IN_PKT_INIT_CTX_RSP +]). + +-define(S1GW_GAUGES, [ + ?S1GW_GAUGE_PFCP_ASSOCIATED, + ?S1GW_GAUGE_S1AP_ENB_NUM_SCTP_CONNECTIONS, + ?S1GW_GAUGE_S1AP_PROXY_UPLINK_PACKETS_QUEUED +]). + +-spec new_ctr(list()) -> ok. +new_ctr(Name) -> + %%?LOG_INFO("New counter ~p", [Name]), + ok = exometer:new(Name, counter). + +-spec new_ctrs(list()) -> ok. +new_ctrs([]) -> + ok; +new_ctrs([Name | MoreNames]) -> + new_ctr(Name), + new_ctrs(MoreNames). + +-spec new_gauge(list()) -> ok. +new_gauge(Name) -> + %%?LOG_INFO("New gauge ~p", [Name]), + ok = exometer:new(Name, gauge). + +-spec new_gauges(list()) -> ok. +new_gauges([]) -> + ok; +new_gauges([Name | MoreNames]) -> + new_gauge(Name), + new_gauges(MoreNames). + +-spec get_current_value(list()) -> integer(). +get_current_value(Name) -> + Result = exometer:get_value(Name, value), + {ok,[{value,PrevVal}]} = Result, + PrevVal. + +%% ------------------------------------------------------------------ +%% public API +%% ------------------------------------------------------------------ + +init() -> + ?LOG_INFO("Initiating metrics", []), + new_ctrs(?S1GW_COUNTERS), + new_gauges(?S1GW_GAUGES). + +%%%%%%%%%%%%% +%% CTR APIs +%%%%%%%%%%%%% +-spec ctr_reset(list()) -> ok | {error, any()}. +ctr_reset(Name) -> + ?LOG_DEBUG("ctr_reset(~p)", [Name]), + exometer:reset(Name). + +-spec ctr_inc(list(), integer()) -> ok | {error, any()}. +ctr_inc(Name, Value) -> + ?LOG_DEBUG("ctr_inc(~p, ~p)", [Name, Value]), + exometer:update(Name, Value). + +-spec ctr_inc(list()) -> ok | {error, any()}. +ctr_inc(Name) -> + ctr_inc(Name, 1). + +%%%%%%%%%%%%% +%% GAUGE APIs +%%%%%%%%%%%%% +-spec gauge_reset(list()) -> ok | {error, any()}. +gauge_reset(Name) -> + ?LOG_DEBUG("gauge_reset(~p)", [Name]), + exometer:reset(Name). + +-spec gauge_set(list(), integer()) -> ok | {error, any()}. +gauge_set(Name, Value) -> + exometer:update(Name, Value). + +-spec gauge_inc(list(), integer()) -> ok | {error, any()}. +gauge_inc(Name, Value) -> + ?LOG_DEBUG("gauge_inc(~p, ~p)", [Name, Value]), + PrevVal = get_current_value(Name), + ?LOG_ERROR("gauge_inc(~p, ~p): pre_val=~p", [Name, Value, PrevVal]), + exometer:update(Name, Value + PrevVal). + +-spec gauge_inc(list()) -> ok | {error, any()}. +gauge_inc(Name) -> + gauge_inc(Name, 1). + +-spec gauge_dec(list()) -> ok | {error, any()}. +gauge_dec(Name) -> + gauge_inc(Name, -1). + + +%% vim:set ts=4 sw=4 et: diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 096ce1f..62c87cf 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -49,6 +49,8 @@ -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). +-include("s1gw_metrics.hrl"). + %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ @@ -104,6 +106,8 @@ %% Handle an eNB -> MME data forwarding request (queue) connecting(cast, {send_data, Data}, #{tx_queue := Pending} = S) -> + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_UPLINK_PACKETS_QUEUED), + s1gw_metrics:gauge_inc(?S1GW_GAUGE_S1AP_PROXY_UPLINK_PACKETS_QUEUED), {keep_state, S#{tx_queue := [Data | Pending]}}; %% Handle an #sctp_assoc_change event (connection state) @@ -259,6 +263,7 @@ sctp_send_pending([Data | Pending], S0) -> S1 = sctp_send(Data, S0), + s1gw_metrics:gauge_dec(?S1GW_CTR_S1AP_PROXY_UPLINK_PACKETS_QUEUED), sctp_send_pending(Pending, S1); sctp_send_pending([], S) -> diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 8ea311f..58d91ca 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -48,6 +48,7 @@ -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). +-include("s1gw_metrics.hrl"). -include("s1ap.hrl"). -record(server_state, {sock, clients, mme_addr_port}). @@ -170,12 +171,14 @@ sctp_recv(State, {FromAddr, FromPort, [#sctp_sndrcvinfo{assoc_id = Aid}], Data}) -> ?LOG_DEBUG("eNB connection (id=~p, ~p:~p) -> MME: ~p", [Aid, FromAddr, FromPort, Data]), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_ENB_ALL_RX), case dict:find(Aid, State#server_state.clients) of {ok, #client_state{pid = Pid}} -> sctp_proxy:send_data(Pid, Data); error -> ?LOG_ERROR("eNB connection (id=~p, ~p:~p) is not known to us?!?", - [Aid, FromAddr, FromPort]) + [Aid, FromAddr, FromPort]), + s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_ENB_ALL_RX_UNKNOWN_ENB) end, State; @@ -190,6 +193,7 @@ client_add(Clients, Aid, FromAddr, FromPort, {MmeAddr, MmePort}) -> {ok, Pid} = sctp_proxy:start_link(Aid, MmeAddr, MmePort), NewClient = #client_state{addr_port = {FromAddr, FromPort}, pid = Pid}, + s1gw_metrics:gauge_inc(?S1GW_GAUGE_S1AP_ENB_NUM_SCTP_CONNECTIONS), dict:store(Aid, NewClient, Clients). @@ -200,6 +204,7 @@ %% the proxy process might be already dead, so we guard %% against exceptions like noproc or {nodedown,Node}. catch sctp_proxy:shutdown(Client#client_state.pid), + s1gw_metrics:gauge_dec(?S1GW_GAUGE_S1AP_ENB_NUM_SCTP_CONNECTIONS), dict:erase(Aid, Clients); error -> Clients diff --git a/test/exometer_mock.erl b/test/exometer_mock.erl new file mode 100644 index 0000000..5a09692 --- /dev/null +++ b/test/exometer_mock.erl @@ -0,0 +1,24 @@ +-module(exometer_mock). + +-export([mock_all/0, + unmock_all/0]). + + +%% ------------------------------------------------------------------ +%% public API +%% ------------------------------------------------------------------ + +%% mock all pfcp_peer module functions +mock_all() -> + meck:new(exometer), + meck:expect(exometer, new, fun(_Name, _Type) -> ok end), + meck:expect(exometer, reset, fun(_Name) -> ok end), + meck:expect(exometer, update, fun(_Name, _Value) -> ok end), + meck:expect(exometer, get_value, fun(_Name, DataPoint) -> {ok,[{DataPoint,0}]} end). + +%% unmock all pfcp_peer module functions +unmock_all() -> + true = meck:validate(exometer), + meck:unload(exometer). + +%% vim:set ts=4 sw=4 et: diff --git a/test/s1ap_proxy_test.erl b/test/s1ap_proxy_test.erl index f53ce5c..2766ba2 100644 --- a/test/s1ap_proxy_test.erl +++ b/test/s1ap_proxy_test.erl @@ -15,10 +15,12 @@ start() -> pfcp_mock:mock_all(), + exometer_mock:mock_all(), s1ap_proxy:init(). stop(S) -> + exometer_mock:unmock_all(), pfcp_mock:unmock_all(), s1ap_proxy:deinit(S). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37955?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I952e198238384dca4be94f91a01d7cfff0a1471f Gerrit-Change-Number: 37955 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: testenv: Fix testsuite.run() passing too many envvars to podman
by pespin 30 Aug '24

30 Aug '24
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37954?usp=email ) Change subject: testenv: Fix testsuite.run() passing too many envvars to podman ...................................................................... testenv: Fix testsuite.run() passing too many envvars to podman A recent commit added some code in testenv to pass all environment to the testsuite being run. However, we don't want that happening when running the testsuite under podman, since then we'd be polluting the env inside the container with the env from the host running the container. This fixes running testenv with podman from an Archlinux host having some TTCN_* extra variables used by testsuite scripts to find ttcn3 binaries & libs under /opt/eclipse-titan/. Fixes: 95231624f12c299019c0d6064b5d4d3004dad093 Change-Id: Ia8fca37b878323cd188035004b587c124598376e --- M _testenv/testenv/testsuite.py 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/54/37954/1 diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py index 077d3f1..a46d5a9 100644 --- a/_testenv/testenv/testsuite.py +++ b/_testenv/testenv/testsuite.py @@ -162,8 +162,10 @@ start_testsuite = os.path.join(ttcn3_hacks_dir, "start-testsuite.sh") suite = os.path.join(ttcn3_hacks_dir, testenv.args.testsuite, section_data["program"]) - pcap_path = os.path.join(testenv.testdir.testdir, "testsuite") - env = testenv.cmd.generate_env({ "TTCN3_PCAP_PATH" : pcap_path }) + env = { + "TTCN3_PCAP_PATH": os.path.join(testenv.testdir.testdir, "testsuite"), + } + env = testenv.cmd.generate_env(env, testenv.args.podman) cmd = [start_testsuite, suite, section_data["config"]] -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37954?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ia8fca37b878323cd188035004b587c124598376e Gerrit-Change-Number: 37954 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: PFCP: drop no longer needed {ts,tr}_PDU_PFCP
by pespin 30 Aug '24

30 Aug '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37951?usp=email ) Change subject: PFCP: drop no longer needed {ts,tr}_PDU_PFCP ...................................................................... PFCP: drop no longer needed {ts,tr}_PDU_PFCP Change-Id: I6091d7e76e852d2487b784fb2b3e39b416a48195 Related: SYS#6772 --- M library/PFCP_Templates.ttcn 1 file changed, 0 insertions(+), 11 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve diff --git a/library/PFCP_Templates.ttcn b/library/PFCP_Templates.ttcn index 143175a..ad90ff2 100644 --- a/library/PFCP_Templates.ttcn +++ b/library/PFCP_Templates.ttcn @@ -113,17 +113,6 @@ message_body := ? }; -template (value) PDU_PFCP ts_PDU_PFCP(LIN3_BO_LAST sequence_number := 0, template (omit) OCT8 seid := omit) -modifies ts_PDU_PFCP_ := { - seid := seid, - sequence_number := sequence_number -}; - -template (present) PDU_PFCP tr_PDU_PFCP(template OCT8 seid := *) -modifies tr_PDU_PFCP_ := { - seid := seid -}; - /* 7.4.4.1 PFCP Association Setup Request */ template (value) PDU_PFCP ts_PFCP_Assoc_Setup_Req(template (value) Node_ID node_id, -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37951?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I6091d7e76e852d2487b784fb2b3e39b416a48195 Gerrit-Change-Number: 37951 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: PFCP: add Heartbeat Req/Resp templates
by pespin 30 Aug '24

30 Aug '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37952?usp=email ) Change subject: PFCP: add Heartbeat Req/Resp templates ...................................................................... PFCP: add Heartbeat Req/Resp templates Change-Id: I569b47b6ebc3ca238da544488cac69dfc1db1dfe Related: SYS#6772 --- M library/PFCP_Templates.ttcn 1 file changed, 44 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/library/PFCP_Templates.ttcn b/library/PFCP_Templates.ttcn index ad90ff2..f3b6893 100644 --- a/library/PFCP_Templates.ttcn +++ b/library/PFCP_Templates.ttcn @@ -73,13 +73,14 @@ template (value) Node_ID ts_PFCP_Node_ID_ipv4(OCT4 ip_value) := ts_PFCP_Node_ID(PFCP_Node_ID_IPv4, ip_value); template (value) Node_ID ts_PFCP_Node_ID_fqdn(charstring fqdn) := ts_PFCP_Node_ID(PFCP_Node_ID_FQDN, char2oct(fqdn)); -template (value) Recovery_Time_Stamp ts_PFCP_Recovery_Timestamp(LIN4_BO_LAST time_value) := { +template (value) Recovery_Time_Stamp +ts_PFCP_Recovery_Timestamp(template (value) LIN4_BO_LAST time_value) := { elementIdentifier := 96, lengthIndicator := 0, time_value := time_value }; - -template (present) Recovery_Time_Stamp tr_PFCP_Recovery_Timestamp(template (present) LIN4_BO_LAST time_value := ?) := { +template (present) Recovery_Time_Stamp +tr_PFCP_Recovery_Timestamp(template (present) LIN4_BO_LAST time_value := ?) := { elementIdentifier := 96, lengthIndicator := ?, time_value := time_value @@ -113,6 +114,46 @@ message_body := ? }; +/* 7.4.2.1 Heartbeat Request */ +template (value) PDU_PFCP +ts_PFCP_Heartbeat_Req(template (value) LIN4_BO_LAST recovery_time_stamp) +modifies ts_PDU_PFCP_ := { + message_body := { + heartbeat_request := { + recovery_time_stamp := ts_PFCP_Recovery_Timestamp(recovery_time_stamp) + } + } +}; +template (present) PDU_PFCP +tr_PFCP_Heartbeat_Req(template (present) LIN4_BO_LAST recovery_time_stamp := ?) +modifies tr_PDU_PFCP_ := { + message_body := { + heartbeat_request := { + recovery_time_stamp := tr_PFCP_Recovery_Timestamp(recovery_time_stamp) + } + } +}; + +/* 7.4.2.2 Heartbeat Response */ +template (value) PDU_PFCP +ts_PFCP_Heartbeat_Resp(template (value) LIN4_BO_LAST recovery_time_stamp) +modifies ts_PDU_PFCP_ := { + message_body := { + heartbeat_response := { + recovery_time_stamp := ts_PFCP_Recovery_Timestamp(recovery_time_stamp) + } + } +}; +template (present) PDU_PFCP +tr_PFCP_Heartbeat_Resp(template (present) LIN4_BO_LAST recovery_time_stamp := ?) +modifies tr_PDU_PFCP_ := { + message_body := { + heartbeat_response := { + recovery_time_stamp := tr_PFCP_Recovery_Timestamp(recovery_time_stamp) + } + } +}; + /* 7.4.4.1 PFCP Association Setup Request */ template (value) PDU_PFCP ts_PFCP_Assoc_Setup_Req(template (value) Node_ID node_id, -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37952?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I569b47b6ebc3ca238da544488cac69dfc1db1dfe Gerrit-Change-Number: 37952 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: PFCP_Emulation: respond to incoming Heartbeat Req
by pespin 30 Aug '24

30 Aug '24
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37953?usp=email ) Change subject: PFCP_Emulation: respond to incoming Heartbeat Req ...................................................................... PFCP_Emulation: respond to incoming Heartbeat Req This is a mandatory procedure that every 3GPP TS 29.244 compliant peer shall support. Change-Id: I93990feb1864701e2903af85480093ef751bafe5 Related: SYS#6772 --- M library/PFCP_CodecPort.ttcn M library/PFCP_Emulation.ttcn 2 files changed, 16 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/library/PFCP_CodecPort.ttcn b/library/PFCP_CodecPort.ttcn index 8d4078d..783ffb0 100644 --- a/library/PFCP_CodecPort.ttcn +++ b/library/PFCP_CodecPort.ttcn @@ -26,6 +26,12 @@ PDU_PFCP pdu } +template (present) PFCP_Unitdata +tr_PFCP_UD(template (present) PDU_PFCP pdu := ?) := { + peer := ?, + pdu := pdu +} + /* Translation port on top of IPL4asp; ASP_Event passed through transparently */ type port PFCP_PT message { out PFCP_Unitdata; diff --git a/library/PFCP_Emulation.ttcn b/library/PFCP_Emulation.ttcn index d872367..2fb3a8a 100644 --- a/library/PFCP_Emulation.ttcn +++ b/library/PFCP_Emulation.ttcn @@ -15,6 +15,7 @@ import from General_Types all; import from Osmocom_Types all; import from PFCP_Types all; +import from PFCP_Templates all; import from PFCP_CodecPort all; import from PFCP_CodecPort_CtrlFunct all; @@ -123,7 +124,15 @@ while (true) { alt { - [] PFCP.receive(PFCP_Unitdata:?) -> value ud { + [] PFCP.receive(tr_PFCP_UD(tr_PFCP_Heartbeat_Req)) -> value ud { + log("Rx Heartbeat Req: ", ud.pdu); + pdu := valueof(ts_PFCP_Heartbeat_Resp(g_recovery_timestamp)); + pdu.sequence_number := ud.pdu.sequence_number; + ud.pdu := pdu; + PFCP.send(ud); + } + + [] PFCP.receive(tr_PFCP_UD(?)) -> value ud { log("PFCP_Emulation main() PFCP.receive: ", ud); vc_conn := null; if (ud.pdu.s_flag == '1'B) { -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37953?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I93990feb1864701e2903af85480093ef751bafe5 Gerrit-Change-Number: 37953 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • ...
  • 148
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.