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

Change subject: hnbgw: Move generic PFCP ConnHdlr helpers to 
library/PFCP_Emulation.ttcn
......................................................................

hnbgw: Move generic PFCP ConnHdlr helpers to library/PFCP_Emulation.ttcn

Change-Id: Ic40bea51934ad465a68e0d5690de066cbe1dc57d
---
M hnbgw/HNBGW_Tests.ttcn
M library/PFCP_Emulation.ttcn
2 files changed, 112 insertions(+), 98 deletions(-)

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




diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index f43a738..ac43d9f 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -260,100 +260,6 @@
        return pfcp_associated;
 }

-private function f_pfcp_wait_assoc_setup_req(boolean fail_timeout := true, 
boolean fail_rx_others := true, float wait_timeout := 16.0) runs on 
PFCP_ConnHdlr {
-       var PDU_PFCP m;
-       timer T := wait_timeout;
-       var integer rts := f_PFCPEM_get_recovery_timestamp();
-       /* ask PFCPEM to route all PDUs to us */
-       f_PFCPEM_subscribe_bcast();
-
-       T.start;
-       alt {
-       [] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> value m {
-                       PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
-                                          ts_PFCP_Cause(REQUEST_ACCEPTED), 
rts));
-                       setverdict(pass);
-               }
-       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [fail_timeout] T.timeout {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [not fail_timeout] T.timeout {
-                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
-               }
-       }
-       T.stop;
-       /* ask PFCPEM to *not* route all PDUs to us anymore */
-       f_PFCPEM_unsubscribe_bcast();
-}
-
-altstep as_pfcp_handle_heartbeat_req(integer tx_recovery_timestamp)
-runs on PFCP_ConnHdlr {
-       var PDU_PFCP m;
-
-       [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value m {
-               var PDU_PFCP tx_pfcp;
-               tx_pfcp := 
valueof(ts_PFCP_Heartbeat_Resp(tx_recovery_timestamp));
-               tx_pfcp.sequence_number := m.sequence_number;
-               PFCP.send(tx_pfcp);
-               }
-}
-
-/* Notify peer that we restarted, it will then try to associate again. */
-private function f_pfcp_force_assoc_setup_req(boolean fail_timeout := true,
-                                              boolean fail_rx_others := true,
-                                              float wait_timeout := 16.0)
-runs on PFCP_ConnHdlr {
-       var boolean rx_hb_resp := false;
-       var boolean rx_assoc_setup_req := false;
-       var integer rts := f_PFCPEM_get_recovery_timestamp();
-       var PDU_PFCP m;
-       timer T := wait_timeout;
-
-       /* ask PFCPEM to route all PDUs to us */
-       f_PFCPEM_subscribe_bcast();
-
-       T.start;
-       PFCP.send(ts_PFCP_Heartbeat_Req(rts));
-       alt {
-       [not rx_hb_resp] PFCP.receive(tr_PFCP_Heartbeat_Resp) {
-               rx_hb_resp := true;
-               if (not rx_assoc_setup_req) {
-                       repeat;
-               }
-               }
-       [not rx_assoc_setup_req] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> 
value m {
-               rx_assoc_setup_req := true;
-               PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, 
ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
-                                                  
ts_PFCP_Cause(REQUEST_ACCEPTED), rts));
-               if (not rx_hb_resp) {
-                       repeat;
-               }
-       }
-       [] as_pfcp_handle_heartbeat_req(rts) { repeat; }
-       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [fail_timeout] T.timeout {
-                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
-                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
-               }
-       [not fail_timeout] T.timeout {
-                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
-               }
-       }
-       T.stop;
-       setverdict(pass);
-
-       /* ask PFCPEM to *not* route all PDUs to us anymore */
-       f_PFCPEM_unsubscribe_bcast();
-}
-
 function f_init_pfcp(charstring id) runs on test_CT {
        id := id & "-PFCP";

@@ -380,10 +286,12 @@
        connect(self:PFCP_PROC, vc_PFCP:CLIENT_PROC);
        /* the non-nightly path can be removed once osmo-hnbgw >1.8.1 is 
released. */
        if (Misc_Helpers.f_osmo_repo_is("nightly")) {
-               f_pfcp_force_assoc_setup_req(fail_timeout := true);
+               
f_pfcp_force_assoc_setup_req(ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                                            fail_timeout := true);
        } else {
                if (not f_statsd_pfcp_associated()) {
-                       f_pfcp_wait_assoc_setup_req(fail_timeout := true);
+                       
f_pfcp_wait_assoc_setup_req(ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                                                   fail_timeout := true);
                }
        }
        disconnect(self:PFCP, vc_PFCP:CLIENT);
@@ -2809,7 +2717,8 @@
        RAN_CONN.receive(tr_MSC_CONN_PRIM_DISC_IND);
        as_pfcp_handle_del_req();
        /* Wait for a 2nd ASSOC SETUP REQ after Heartbeat timeout: */
-       f_pfcp_wait_assoc_setup_req(fail_timeout := true, fail_rx_others := 
false);
+       f_pfcp_wait_assoc_setup_req(ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                                   fail_timeout := true, fail_rx_others := 
false);
        /* After we answer the ASSOC SETUP RESP, IUT detects peer up: */
        f_statsd_expect(expect_connected, wait_converge := true);

@@ -2871,7 +2780,8 @@
        f_PFCPEM_unsubscribe_bcast();

        /* Wait for a 2nd ASSOC SETUP REQ after Recovery triggered: */
-       f_pfcp_wait_assoc_setup_req(fail_timeout := true, fail_rx_others := 
false);
+       f_pfcp_wait_assoc_setup_req(ts_PFCP_Node_ID_fqdn(mp_pfcp_upf_node_id),
+                                   fail_timeout := true, fail_rx_others := 
false);
        /* After we answer the ASSOC SETUP RESP, IUT detects peer up: */
        f_statsd_expect(expect_connected, wait_converge := true);

diff --git a/library/PFCP_Emulation.ttcn b/library/PFCP_Emulation.ttcn
index a5ec818..2471faf 100644
--- a/library/PFCP_Emulation.ttcn
+++ b/library/PFCP_Emulation.ttcn
@@ -401,4 +401,108 @@
        }
 }

+/* Wait for peer to send a PFCP HEARTBEAT REQ to us, answer it */
+altstep as_pfcp_handle_heartbeat_req(integer tx_recovery_timestamp)
+runs on PFCP_ConnHdlr {
+       var PDU_PFCP m;
+
+       [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value m {
+               var PDU_PFCP tx_pfcp;
+               tx_pfcp := 
valueof(ts_PFCP_Heartbeat_Resp(tx_recovery_timestamp));
+               tx_pfcp.sequence_number := m.sequence_number;
+               PFCP.send(tx_pfcp);
+               }
+}
+
+/* Wait for peer to send a PFCP ASSOC SETUP REQ to us, answer it */
+function f_pfcp_wait_assoc_setup_req(template (value) Node_ID local_node_id,
+                                    boolean fail_timeout := true,
+                                    boolean fail_rx_others := true,
+                                    float wait_timeout := 16.0) runs on 
PFCP_ConnHdlr {
+       var PDU_PFCP m;
+       timer T := wait_timeout;
+       var integer rts := f_PFCPEM_get_recovery_timestamp();
+       /* ask PFCPEM to route all PDUs to us */
+       f_PFCPEM_subscribe_bcast();
+
+       T.start;
+       alt {
+       [] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> value m {
+                       PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number,
+                                                          local_node_id,
+                                                          
ts_PFCP_Cause(REQUEST_ACCEPTED),
+                                                          rts));
+                       setverdict(pass);
+               }
+       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [fail_timeout] T.timeout {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [not fail_timeout] T.timeout {
+                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
+               }
+       }
+       T.stop;
+       /* ask PFCPEM to *not* route all PDUs to us anymore */
+       f_PFCPEM_unsubscribe_bcast();
+}
+
+/* Notify peer that we restarted, it will then try to associate again. */
+function f_pfcp_force_assoc_setup_req(template (value) Node_ID local_node_id,
+                                     boolean fail_timeout := true,
+                                     boolean fail_rx_others := true,
+                                     float wait_timeout := 16.0)
+runs on PFCP_ConnHdlr {
+       var boolean rx_hb_resp := false;
+       var boolean rx_assoc_setup_req := false;
+       var integer rts := f_PFCPEM_get_recovery_timestamp();
+       var PDU_PFCP m;
+       timer T := wait_timeout;
+
+       /* ask PFCPEM to route all PDUs to us */
+       f_PFCPEM_subscribe_bcast();
+
+       T.start;
+       PFCP.send(ts_PFCP_Heartbeat_Req(rts));
+       alt {
+       [not rx_hb_resp] PFCP.receive(tr_PFCP_Heartbeat_Resp) {
+               rx_hb_resp := true;
+               if (not rx_assoc_setup_req) {
+                       repeat;
+               }
+               }
+       [not rx_assoc_setup_req] PFCP.receive(tr_PFCP_Assoc_Setup_Req()) -> 
value m {
+               rx_assoc_setup_req := true;
+               PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number,
+                                                  local_node_id,
+                                                  
ts_PFCP_Cause(REQUEST_ACCEPTED),
+                                                  rts));
+               if (not rx_hb_resp) {
+                       repeat;
+               }
+       }
+       [] as_pfcp_handle_heartbeat_req(rts) { repeat; }
+       [fail_rx_others] PFCP.receive(PDU_PFCP:?) -> value m {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Got an unexpected PFCP 
message ", m, " vs exp ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [fail_timeout] T.timeout {
+                       Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+                                               log2str("Timeout waiting for 
PFCP ", tr_PFCP_Assoc_Setup_Req()));
+               }
+       [not fail_timeout] T.timeout {
+                       log("Timeout waiting for PFCP ", 
tr_PFCP_Assoc_Setup_Req());
+               }
+       }
+       T.stop;
+       setverdict(pass);
+
+       /* ask PFCPEM to *not* route all PDUs to us anymore */
+       f_PFCPEM_unsubscribe_bcast();
+}
+
 }

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

Reply via email to