fixeria submitted this change.

View Change

Approvals: fixeria: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
s1ap_proxy_test: Add unit tests for S1 HANDOVER procedure

Change-Id: I400ac73343f2a795c8206aeee75a31f1455adbd0
Related: SYS#7309
---
M test/s1ap_proxy_test.erl
1 file changed, 108 insertions(+), 0 deletions(-)

diff --git a/test/s1ap_proxy_test.erl b/test/s1ap_proxy_test.erl
index 60b09dc..c0ada57 100644
--- a/test/s1ap_proxy_test.erl
+++ b/test/s1ap_proxy_test.erl
@@ -72,6 +72,10 @@
?TC(fun test_initial_context_setup/1)},
{"INITIAL CONTEXT SETUP REQUEST/RESPONSE (duplicate)",
?TC(fun test_initial_context_setup_dup/1)},
+ {"HANDOVER REQUIRED/COMMAND",
+ ?TC(fun test_handover_preparation/1)},
+ {"HANDOVER REQUEST/REQUEST ACKNOWLEDGE",
+ ?TC(fun test_handover_res_alloc/1)},
{"UE CONTEXT RELEASE REQUEST",
?TC(fun test_ue_ctx_release_req/1)},
{"UE CONTEXT RELEASE COMMAND/COMPLETE",
@@ -391,6 +395,50 @@
?_assertMatch([_], s1ap_proxy:fetch_erab_list(Pid))].


+test_handover_preparation(#{handler := Pid}) ->
+ %% [eNB -> MME] HANDOVER REQUIRED
+ HandoverRqd = handover_required(),
+ %% [MME -> eNB] HANDOVER COMMAND
+ HandoverCmd = handover_command(),
+
+ [?_assertMatch({forward, HandoverRqd}, s1ap_proxy:process_pdu(Pid, HandoverRqd)),
+ ?_assertMatch({forward, HandoverCmd}, s1ap_proxy:process_pdu(Pid, HandoverCmd)),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL, 2),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_IN_PKT_HANDOVER_CMD, 1),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_ALL, 2),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_PROC, 0),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED, 2),
+ ?_assertMatch([], s1ap_proxy:fetch_erab_list(Pid))].
+
+test_handover_res_alloc(#{handler := Pid}) ->
+ %% [MME -> eNB] HANDOVER REQUEST
+ HandoverReqIn = handover_request(?ADDR_U2C, ?TEID_U2C),
+ HandoverReqExp = handover_request(?ADDR_A2U, ?TEID_A2U),
+ %% [eNB -> MME] HANDOVER REQUEST ACKNOWLEDGE
+ HandoverAckIn = handover_request_ack(?ADDR_U2A, ?TEID_U2A),
+ HandoverAckExp = handover_request_ack(?ADDR_C2U, ?TEID_C2U),
+
+ [?_assertMatch({forward, _}, s1ap_proxy:process_pdu(Pid, s1_setup_req_pdu())),
+ ?_assertMatch({forward, _}, s1ap_proxy:process_pdu(Pid, s1_setup_rsp_pdu())),
+ ?_assertEqual({forward, HandoverReqExp}, s1ap_proxy:process_pdu(Pid, HandoverReqIn)),
+ ?_assertEqual({forward, HandoverAckExp}, s1ap_proxy:process_pdu(Pid, HandoverAckIn)),
+ %% global counters
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL, 2 + 2),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_IN_PKT_HANDOVER_REQ, 1),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_IN_PKT_HANDOVER_REQ_ACK, 1),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_ALL, 2 + 2),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_PROC, 2),
+ ?_assertMetric(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED, 2),
+ %% per-eNB counters
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_IN_PKT_ALL, 2 + 2),
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_IN_PKT_HANDOVER_REQ, 1),
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_IN_PKT_HANDOVER_REQ_ACK, 1),
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_ALL, 2 + 2),
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_PROC, 2),
+ ?_assertMetricENB(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED, 2),
+ ?_assertMatch([_], s1ap_proxy:fetch_erab_list(Pid))].
+
+
test_ue_ctx_release_req(#{handler := Pid}) ->
%% [eNB <- MME] INITIAL CONTEXT SETUP REQUEST
InitCtxSetupReq = initial_context_setup_req_pdu(?ADDR_U2C, ?TEID_U2C),
@@ -707,4 +755,64 @@
>>.


+%% [eNB -> MME] HANDOVER REQUIRED
+handover_required() ->
+ << 16#00, 16#00, 16#00, 16#35, 16#00, 16#00, 16#06, 16#00,
+ 16#00, 16#00, 16#03, 16#40, 16#10, 16#92, 16#00, 16#08,
+ 16#00, 16#02, 16#00, 16#00, 16#00, 16#01, 16#00, 16#01,
+ 16#00, 16#00, 16#02, 16#40, 16#02, 16#04, 16#20, 16#00,
+ 16#04, 16#00, 16#0e, 16#00, 16#62, 16#f2, 16#10, 16#40,
+ 16#00, 16#00, 16#00, 16#00, 16#62, 16#f2, 16#10, 16#00,
+ 16#07, 16#00, 16#68, 16#00, 16#04, 16#03, 16#12, 16#34,
+ 16#56
+ >>.
+
+
+%% [MME -> eNB] HANDOVER COMMAND
+handover_command() ->
+ << 16#20, 16#00, 16#00, 16#28, 16#00, 16#00, 16#05, 16#00,
+ 16#00, 16#00, 16#03, 16#40, 16#10, 16#92, 16#00, 16#08,
+ 16#00, 16#02, 16#00, 16#00, 16#00, 16#01, 16#00, 16#01,
+ 16#00, 16#00, 16#0c, 16#40, 16#07, 16#00, 16#00, 16#0e,
+ 16#40, 16#02, 16#00, 16#00, 16#00, 16#7b, 16#00, 16#04,
+ 16#03, 16#12, 16#34, 16#56
+ >>.
+
+
+%% [MME -> eNB] HANDOVER REQUEST
+handover_request(TLA, TEID) when is_binary(TLA),
+ is_integer(TEID) ->
+ << 16#00, 16#01, 16#00, 16#6f, 16#00, 16#00, 16#08, 16#00,
+ 16#00, 16#00, 16#03, 16#40, 16#10, 16#92, 16#00, 16#01,
+ 16#00, 16#01, 16#00, 16#00, 16#02, 16#40, 16#02, 16#04,
+ 16#20, 16#00, 16#42, 16#00, 16#0a, 16#18, 16#40, 16#00,
+ 16#00, 16#00, 16#60, 16#40, 16#00, 16#00, 16#00, 16#00,
+ 16#35, 16#00, 16#12, 16#00, 16#00, 16#1b, 16#00, 16#0d,
+ 16#00, 16#1f,
+ TLA/bytes, %% transportLayerAddress (IPv4)
+ TEID:32/big, %% GTP-TEID
+ 16#00, 16#05, 16#04, 16#00, 16#68, 16#00,
+ 16#04, 16#03, 16#12, 16#34, 16#56, 16#00, 16#6b, 16#00,
+ 16#05, 16#1c, 16#00, 16#0e, 16#00, 16#00, 16#00, 16#28,
+ 16#00, 16#21, 16#28, 16#e0, 16#3f, 16#02, 16#35, 16#f1,
+ 16#1e, 16#13, 16#68, 16#a8, 16#55, 16#04, 16#db, 16#fb,
+ 16#8f, 16#65, 16#2b, 16#8c, 16#c7, 16#1c, 16#7c, 16#87,
+ 16#cc, 16#f3, 16#f6, 16#4d, 16#4f, 16#84, 16#5e, 16#e1,
+ 16#d2, 16#fc, 16#c6
+ >>.
+
+
+%% [eNB -> MME] HANDOVER REQUEST ACKNOWLEDGE
+handover_request_ack(TLA, TEID) when is_binary(TLA),
+ is_integer(TEID) ->
+ << 16#20, 16#01, 16#00, 16#2c, 16#00, 16#00, 16#04, 16#00,
+ 16#00, 16#40, 16#03, 16#40, 16#10, 16#92, 16#00, 16#08,
+ 16#40, 16#02, 16#00, 16#00, 16#00, 16#12, 16#40, 16#10,
+ 16#00, 16#00, 16#14, 16#40, 16#0b, 16#00, 16#01, 16#f0,
+ TLA/bytes, %% transportLayerAddress (IPv4)
+ TEID:32/big, %% GTP-TEID
+ 16#00, 16#7b, 16#00, 16#04, 16#03, 16#12, 16#34, 16#56
+ >>.
+
+
%% vim:set ts=4 sw=4 et:

To view, visit change 41029. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I400ac73343f2a795c8206aeee75a31f1455adbd0
Gerrit-Change-Number: 41029
Gerrit-PatchSet: 4
Gerrit-Owner: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>