pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43441?usp=email )

Change subject: smf: Introduce test TC_gy_charging_cc_time
......................................................................

smf: Introduce test TC_gy_charging_cc_time

Similar to the existing one in PGW_Tests.

Change-Id: I1d1c8983d390b65fd156eb56dc9c8ca09bcea2a8
---
M deps/Makefile
M library/PFCP_Templates.ttcn
M smf/SMF_Session_CT.ttcn
M smf/SMF_Tests.ttcn
M smf/expected-results.xml
5 files changed, 102 insertions(+), 3 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/deps/Makefile b/deps/Makefile
index 521c0ea..17943f9 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -107,7 +107,7 @@
 titan.ProtocolModules.SUA_commit=              R.5.A-5-gcf1137a
 titan.ProtocolModules.TCP_commit=              R.3.A-5-g39e5f45
 titan.ProtocolModules.UDP_commit=              R.4.A-5-geea8aa3
-titan.ProtocolModules.PFCP_v15.1.0_commit=     
38b209571697a0ae659609fa8b629edacd7dde9f
+titan.ProtocolModules.PFCP_v15.1.0_commit=     
bdd91b0a255afdb737afe9084b8ebc7b3cabc5f6
 titan.TestPorts.AF_PACKET_commit=              0.1-5-g89ebea6
 titan.TestPorts.Common_Components.Socket-API_commit=   R.6.A-6-gf4380d0
 titan.TestPorts.Common_Components.Abstract_Socket_commit=      R.9.B-4-gbd41994
diff --git a/library/PFCP_Templates.ttcn b/library/PFCP_Templates.ttcn
index 87d8592..5cdc5cc 100644
--- a/library/PFCP_Templates.ttcn
+++ b/library/PFCP_Templates.ttcn
@@ -436,6 +436,31 @@
        spare7_8 := spare7_8
 }

+/* 8.2.44 Volume Measurement */
+template (value) Volume_Measurement
+ts_PFCP_Volume_Measurement(template (value) LIN8_BO_LAST total_volume := 0,
+                          template (value) LIN8_BO_LAST uplink_volume := 0,
+                          template (value) LIN8_BO_LAST downlink_volume := 0,
+                          template (value) LIN8_BO_LAST total_packets := 0,
+                          template (value) LIN8_BO_LAST uplink_packets := 0,
+                          template (value) LIN8_BO_LAST downlink_packets := 0) 
:= {
+       elementIdentifier := 66,
+       lengthIndicator := 0, /* overwritten */
+       tovol := '1'B,
+       ulvol := '1'B,
+       dlvol := '1'B,
+       tonop := '1'B,
+       ulnop := '1'B,
+       dlnop := '1'B,
+       spare := '00'B,
+       total_volume := total_volume,
+       uplink_volume := uplink_volume,
+       downlink_volume := downlink_volume,
+       total_packets := total_packets,
+       uplink_packets := uplink_packets,
+       downlink_packets := downlink_packets
+}
+
 /* 8.2.45 Duration Measurement */
 template (value) Duration_Measurement
 ts_PFCP_Duration_Measurement(template (value) LIN4_BO_LAST duration) := {
diff --git a/smf/SMF_Session_CT.ttcn b/smf/SMF_Session_CT.ttcn
index 5ced1de..6114167 100644
--- a/smf/SMF_Session_CT.ttcn
+++ b/smf/SMF_Session_CT.ttcn
@@ -112,7 +112,12 @@
        URR_ID urr_id,
        integer ur_seqn,
        integer start_time, /* In system clock */
-       integer last_report_time /* In system clock */
+       integer last_report_time, /* In system clock */
+       /* Relative to last report sent: */
+       uint64_t ul_bytes,
+       uint64_t dl_bytes,
+       uint64_t ul_pkts,
+       uint64_t dl_pkts
 }
 type record of Session_URR Session_URR_List;
 template (value) Session_URR
@@ -120,7 +125,11 @@
        urr_id := urr_id,
        ur_seqn := 0,
        start_time := start_time,
-       last_report_time := start_time
+       last_report_time := start_time,
+       ul_bytes := 0,
+       dl_bytes := 0,
+       ul_pkts := 0,
+       dl_pkts := 0
 }
 type record PfcpParameters {
        charstring pfcp_local_addr,
@@ -586,6 +595,14 @@
        return 
valueof(ts_PFCP_Start_Time(int2oct(f_time_to_ntp32(urr.start_time), 4)));
 }

+private function f_Session_URR_Volume_Measurement(Session_URR urr)
+return Volume_Measurement {
+       return valueof(ts_PFCP_Volume_Measurement(urr.ul_bytes + urr.dl_bytes,
+                                                 urr.ul_bytes, urr.dl_bytes,
+                                                 urr.ul_pkts + urr.dl_pkts,
+                                                 urr.ul_pkts, urr.dl_pkts));
+}
+
 private function f_Session_URR_Duration_Measurement(inout Session_URR urr)
 return Duration_Measurement {
        var integer now := f_time();
@@ -613,6 +630,7 @@
                                                       
ts_PFCP_Usage_Report_Trigger(quvti := '1'B),
                                                       start_time := 
f_Session_URR_Start_Time(urr),
                                                       end_time := 
f_End_Time_now(),
+                                                      volume_measurement := 
f_Session_URR_Volume_Measurement(urr),
                                                       duration_measurement := 
f_Session_URR_Duration_Measurement(urr));
        return valueof(usage_report);
 }
diff --git a/smf/SMF_Tests.ttcn b/smf/SMF_Tests.ttcn
index bb4d231..b452bd9 100644
--- a/smf/SMF_Tests.ttcn
+++ b/smf/SMF_Tests.ttcn
@@ -325,6 +325,60 @@
        vc_conn.done;
 }

+/* Test charging over Gy interface. */
+private function f_TC_gy_charging_cc_time() runs on SMF_Session_CT {
+       var default d;
+
+       f_s5s8_create_session();
+
+       f_sleep(int2float(g_pars.gy.validity_time));
+       f_pfcp_sess_report_req();
+
+       /* We should receive an update even if no traffic is sent: */
+       as_DIA_Gy_CCR(UPDATE_REQUEST);
+       f_validate_gy_cc_report(g_rx_gy, VALIDITY_TIME, (3..4), 0, 0);
+       /* SMF updates new Volume quota obtained from OCS on UPF: */
+       as_pfcp_sess_mod_req();
+
+       /* Emulate some traffic happening at the UPF: */
+       g_pars.pfcp_pars.urr_list[0].ul_bytes := 29;
+       g_pars.pfcp_pars.urr_list[0].dl_bytes := 50;
+       g_pars.pfcp_pars.urr_list[0].ul_pkts := 2;
+       g_pars.pfcp_pars.urr_list[0].dl_pkts := 1;
+       f_sleep(int2float(g_pars.gy.validity_time));
+       f_pfcp_sess_report_req();
+
+       as_DIA_Gy_CCR(UPDATE_REQUEST)
+       f_validate_gy_cc_report(g_rx_gy, VALIDITY_TIME, (3..4), 29, 50);
+       /* SMF updates new Volume quota obtained from OCS on UPF: */
+       as_pfcp_sess_mod_req();
+
+       /* Emulate some traffic happening at the UPF: */
+       g_pars.pfcp_pars.urr_list[0].ul_bytes := 400;
+       g_pars.pfcp_pars.urr_list[0].dl_bytes := 500;
+       g_pars.pfcp_pars.urr_list[0].ul_pkts := 30;
+       g_pars.pfcp_pars.urr_list[0].dl_pkts := 31;
+       f_sleep(int2float(g_pars.gy.validity_time));
+       f_pfcp_sess_report_req();
+
+       as_DIA_Gy_CCR(UPDATE_REQUEST);
+       f_validate_gy_cc_report(g_rx_gy, VALIDITY_TIME, (3..4), 400, 500);
+       /* SMF updates new Volume quota obtained from OCS on UPF: */
+       as_pfcp_sess_mod_req();
+
+       f_delete_session(omit, Request_accepted);
+       f_validate_gy_cc_report(g_rx_gy, FINAL, (0..1), 0, 0);
+       setverdict(pass);
+}
+testcase TC_gy_charging_cc_time() runs on SMF_Test_CT {
+       var SMF_Session_CT vc_conn;
+       var SessionPars pars := valueof(t_SessionPars('001010123456789'H));
+       pars.gy.validity_time := 3; /* Grant access for 3 seconds, needs to be 
re-validated afterwards */
+       f_init();
+       vc_conn := f_start_handler(refers(f_TC_gy_charging_cc_time), pars);
+       vc_conn.done;
+}
+
 /* Test Gy CCR rejected with CCA Result-Code DIAMETER_AUTHORIZATION_REJECTED 
(5003) */
 private function f_TC_gy_ccr_update_rejected() runs on SMF_Session_CT {
        var default d;
@@ -402,6 +456,7 @@
        execute( TC_tx_echo() );
        execute( TC_createSession_deleteSession() );
        execute( TC_deleteSession_unknown() );
+       execute( TC_gy_charging_cc_time() );
        execute( TC_gy_ccr_update_rejected() );
        execute( TC_s2b_createSession_v4_noapco() );
        execute( TC_s2b_createSession_v4_apco() );
diff --git a/smf/expected-results.xml b/smf/expected-results.xml
index 32dd281..eba5484 100644
--- a/smf/expected-results.xml
+++ b/smf/expected-results.xml
@@ -3,6 +3,7 @@
   <testcase classname='SMF_Tests' name='TC_tx_echo' time='MASKED'/>
        <testcase classname='SMF_Tests' name='TC_createSession_deleteSession' 
time='MASKED'/>
        <testcase classname='SMF_Tests' name='TC_deleteSession_unknown' 
time='MASKED'/>
+       <testcase classname='SMF_Tests' name='TC_gy_charging_cc_time' 
time='MASKED'/>
        <testcase classname='SMF_Tests' name='TC_gy_ccr_update_rejected' 
time='MASKED'/>
        <testcase classname='SMF_Tests' name='TC_s2b_createSession_v4_noapco' 
time='MASKED'/>
        <testcase classname='SMF_Tests' name='TC_s2b_createSession_v4_apco' 
time='MASKED'/>

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43441?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: I1d1c8983d390b65fd156eb56dc9c8ca09bcea2a8
Gerrit-Change-Number: 43441
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to