Skip to content

Commit 25b53b7

Browse files
FabianEckermanncodebot
authored andcommitted
cu_cp: add inter cu handover unit test for source cu
1 parent 181e862 commit 25b53b7

File tree

2 files changed

+63
-18
lines changed

2 files changed

+63
-18
lines changed

tests/test_doubles/f1ap/f1ap_test_message_validators.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ const byte_buffer& srsran::test_helpers::get_rrc_container(const f1ap_message& m
6161
return msg.pdu.init_msg().value.ue_context_setup_request()->rrc_container;
6262
}
6363

64+
if (msg.pdu.init_msg().proc_code == ASN1_F1AP_ID_UE_CONTEXT_MOD) {
65+
return msg.pdu.init_msg().value.ue_context_mod_request()->rrc_container;
66+
}
67+
6468
return msg.pdu.init_msg().value.dl_rrc_msg_transfer()->rrc_container;
6569
}
6670

tests/unittests/cu_cp/cu_cp_inter_cu_handover_test.cpp

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "tests/test_doubles/e1ap/e1ap_test_message_validators.h"
1313
#include "tests/test_doubles/f1ap/f1ap_test_message_validators.h"
1414
#include "tests/test_doubles/ngap/ngap_test_message_validators.h"
15+
#include "tests/test_doubles/rrc/rrc_test_message_validators.h"
1516
#include "tests/unittests/cu_cp/test_helpers.h"
1617
#include "tests/unittests/e1ap/common/e1ap_cu_cp_test_messages.h"
1718
#include "tests/unittests/f1ap/common/f1ap_cu_test_messages.h"
@@ -161,6 +162,28 @@ class cu_cp_inter_cu_handover_test : public cu_cp_test_environment, public ::tes
161162
return true;
162163
}
163164

165+
[[nodiscard]] bool send_handover_command_and_await_ue_context_modification_request()
166+
{
167+
// Inject Handover Command and wait for UE Context Modification Request (containing RRC Reconfiguration)
168+
get_amf().push_tx_pdu(generate_valid_handover_command(ue_ctx->amf_ue_id.value(), ue_ctx->ran_ue_id.value()));
169+
report_fatal_error_if_not(
170+
this->wait_for_f1ap_tx_pdu(du_idx, f1ap_pdu),
171+
"Failed to receive F1AP UE Context Modification Request (containing RRC Reconfiguration)");
172+
report_fatal_error_if_not(test_helpers::is_valid_ue_context_modification_request(f1ap_pdu),
173+
"Invalid UE Context Modification Request");
174+
175+
// Make sure RRC Reconfiguration is valid
176+
const byte_buffer& rrc_container = test_helpers::get_rrc_container(f1ap_pdu);
177+
report_fatal_error_if_not(
178+
test_helpers::is_valid_rrc_reconfiguration(test_helpers::extract_dl_dcch_msg(rrc_container),
179+
false,
180+
std::vector<srb_id_t>{srb_id_t::srb1, srb_id_t::srb2},
181+
std::vector<drb_id_t>{drb_id_t::drb1}),
182+
"Invalid RRC Reconfiguration");
183+
184+
return true;
185+
}
186+
164187
unsigned du_idx = 0;
165188
unsigned cu_up_idx = 0;
166189

@@ -182,24 +205,9 @@ class cu_cp_inter_cu_handover_test : public cu_cp_test_environment, public ::tes
182205
e1ap_message e1ap_pdu;
183206
};
184207

185-
TEST_F(cu_cp_inter_cu_handover_test, when_handover_request_received_then_handover_notify_is_sent)
186-
{
187-
// Inject Handover Request and await Bearer Context Setup Request
188-
ASSERT_TRUE(send_handover_request_and_await_bearer_context_setup_request());
189-
190-
// Inject Bearer Context Setup Response and await UE Context Setup Request
191-
ASSERT_TRUE(send_bearer_context_setup_response_and_await_ue_context_setup_request());
192-
193-
// Inject UE Context Setup Response and await Bearer Context Modification Request
194-
ASSERT_TRUE(send_ue_context_setup_response_and_await_bearer_context_modification_request());
195-
196-
// Inject Bearer Context Modification Response and await Handover Request Ack
197-
ASSERT_TRUE(send_bearer_context_modification_response_and_await_handover_request_ack());
198-
199-
// Inject RRC Reconfiguration Complete and await Handover Notify
200-
ASSERT_TRUE(send_rrc_reconfiguration_complete_and_await_handover_notify());
201-
}
202-
208+
///////////////////////////////////////////////////////////////////////////////
209+
// Source CU-CP
210+
///////////////////////////////////////////////////////////////////////////////
203211
TEST_F(cu_cp_inter_cu_handover_test, when_handover_preparation_failure_is_received_then_handover_fails)
204212
{
205213
// Attach UE
@@ -230,3 +238,36 @@ TEST_F(cu_cp_inter_cu_handover_test, when_handover_command_times_out_then_handov
230238
// Inject Handover Cancel Ack
231239
ASSERT_TRUE(send_handover_cancel_ack());
232240
}
241+
242+
TEST_F(cu_cp_inter_cu_handover_test, when_handover_command_received_then_rrc_reconfiguration_is_sent)
243+
{
244+
// Attach UE
245+
ASSERT_TRUE(attach_ue());
246+
247+
// Inject RRC Measurement Report and await Handover Required
248+
ASSERT_TRUE(send_rrc_measurement_report_and_await_handover_required());
249+
250+
// timeout Handover Command and await RRC Reconfiguration
251+
ASSERT_TRUE(send_handover_command_and_await_ue_context_modification_request());
252+
}
253+
254+
///////////////////////////////////////////////////////////////////////////////
255+
// Target CU-CP
256+
///////////////////////////////////////////////////////////////////////////////
257+
TEST_F(cu_cp_inter_cu_handover_test, when_handover_request_received_then_handover_notify_is_sent)
258+
{
259+
// Inject Handover Request and await Bearer Context Setup Request
260+
ASSERT_TRUE(send_handover_request_and_await_bearer_context_setup_request());
261+
262+
// Inject Bearer Context Setup Response and await UE Context Setup Request
263+
ASSERT_TRUE(send_bearer_context_setup_response_and_await_ue_context_setup_request());
264+
265+
// Inject UE Context Setup Response and await Bearer Context Modification Request
266+
ASSERT_TRUE(send_ue_context_setup_response_and_await_bearer_context_modification_request());
267+
268+
// Inject Bearer Context Modification Response and await Handover Request Ack
269+
ASSERT_TRUE(send_bearer_context_modification_response_and_await_handover_request_ack());
270+
271+
// Inject RRC Reconfiguration Complete and await Handover Notify
272+
ASSERT_TRUE(send_rrc_reconfiguration_complete_and_await_handover_notify());
273+
}

0 commit comments

Comments
 (0)