Skip to content

Commit a834f69

Browse files
committed
f1ap-du: fix unit tests for ue context setup
1 parent cdfaa4d commit a834f69

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

lib/f1ap/du/procedures/f1ap_du_ue_context_setup_procedure.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "proc_logger.h"
1515
#include "srsran/asn1/f1ap/common.h"
1616
#include "srsran/f1ap/common/f1ap_message.h"
17+
#include "srsran/support/async/async_no_op_task.h"
1718

1819
using namespace srsran;
1920
using namespace srs_du;
@@ -91,7 +92,7 @@ void f1ap_du_ue_context_setup_procedure::operator()(coro_context<async_task<void
9192
// > If the UE CONTEXT SETUP REQUEST message contains the RRC-Container IE, the gNB-DU shall send the corresponding
9293
// RRC message to the UE via SRB1.
9394
if (msg->rrc_container_present and not msg->rrc_container.empty()) {
94-
CORO_AWAIT(ue->bearers.find_srb(srb_id_t::srb1)->handle_pdu_and_await_transmission(msg->rrc_container.copy()));
95+
CORO_AWAIT(handle_rrc_container());
9596
}
9697

9798
// Respond back to CU-CP with success.
@@ -100,6 +101,16 @@ void f1ap_du_ue_context_setup_procedure::operator()(coro_context<async_task<void
100101
CORO_RETURN();
101102
}
102103

104+
async_task<void> f1ap_du_ue_context_setup_procedure::handle_rrc_container()
105+
{
106+
f1c_bearer* srb1 = ue->bearers.find_srb(srb_id_t::srb1);
107+
if (srb1 != nullptr) {
108+
return srb1->handle_pdu_and_await_transmission(msg->rrc_container.copy());
109+
}
110+
logger.error("{}: Failed to find SRB1 bearer to send RRC container.", f1ap_log_prefix{ue->context, name()});
111+
return launch_no_op_task();
112+
}
113+
103114
async_task<f1ap_ue_context_update_response> f1ap_du_ue_context_setup_procedure::request_du_ue_config()
104115
{
105116
// Construct DU request.

lib/f1ap/du/procedures/f1ap_du_ue_context_setup_procedure.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class f1ap_du_ue_context_setup_procedure
3939
// Send UE Context Setup Failure to CU.
4040
void send_ue_context_setup_failure();
4141

42+
async_task<void> handle_rrc_container();
43+
4244
const char* name() const { return "UE Context Setup"; }
4345

4446
const asn1::f1ap::ue_context_setup_request_s msg;

tests/unittests/f1ap/du/f1ap_du_ue_context_setup_procedure_test.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ class f1ap_du_ue_context_setup_test : public f1ap_du_test
7979
}
8080

8181
f1ap->handle_message(msg);
82+
83+
if (not ue_ctx_setup.gnb_du_ue_f1ap_id_present) {
84+
report_fatal_error_if_not(this->f1ap_du_cfg_handler.last_ue_creation_response.has_value(),
85+
"UE should have been created");
86+
test_ue->f1c_bearers[srb_id_to_uint(srb_id_t::srb1)].bearer =
87+
this->f1ap_du_cfg_handler.last_ue_creation_response.value().f1c_bearers_added[0];
88+
}
89+
}
90+
91+
void on_rrc_container_transmitted(uint32_t highest_pdcp_sn)
92+
{
93+
this->test_ue->f1c_bearers[LCID_SRB1].bearer->handle_transmit_notification(highest_pdcp_sn);
8294
}
8395

8496
ue_test_context* test_ue = nullptr;
@@ -110,6 +122,10 @@ TEST_F(f1ap_du_ue_context_setup_test, when_f1ap_receives_request_then_f1ap_respo
110122
gnb_cu_ue_f1ap_id_t{0}, gnb_du_ue_f1ap_id_t{0}, 1, {drb_id_t::drb1});
111123
start_procedure(msg);
112124

125+
// Lower layers handle RRC container.
126+
this->f1c_gw.last_tx_f1ap_pdu = {};
127+
on_rrc_container_transmitted(1);
128+
113129
// F1AP sends UE CONTEXT SETUP RESPONSE to CU-CP.
114130
ASSERT_EQ(this->f1c_gw.last_tx_f1ap_pdu.pdu.type().value, f1ap_pdu_c::types_opts::successful_outcome);
115131
ASSERT_EQ(this->f1c_gw.last_tx_f1ap_pdu.pdu.successful_outcome().value.type().value,
@@ -168,9 +184,8 @@ TEST_F(f1ap_du_ue_context_setup_test, when_f1ap_receives_request_then_new_srbs_b
168184

169185
TEST_F(f1ap_du_ue_context_setup_test, when_f1ap_receives_request_without_gnb_du_ue_f1ap_id_then_ue_is_created)
170186
{
171-
f1ap_message msg = test_helpers::create_ue_context_setup_request(
172-
gnb_cu_ue_f1ap_id_t{0}, gnb_du_ue_f1ap_id_t{0}, 1, {drb_id_t::drb1});
173-
msg.pdu.init_msg().value.ue_context_setup_request()->gnb_du_ue_f1ap_id_present = false;
187+
f1ap_message msg =
188+
test_helpers::create_ue_context_setup_request(gnb_cu_ue_f1ap_id_t{0}, std::nullopt, 1, {drb_id_t::drb1});
174189

175190
start_procedure(msg);
176191

@@ -180,9 +195,8 @@ TEST_F(f1ap_du_ue_context_setup_test, when_f1ap_receives_request_without_gnb_du_
180195

181196
TEST_F(f1ap_du_ue_context_setup_test, when_f1ap_receives_request_without_gnb_du_ue_f1ap_id_then_ue_context_is_updated)
182197
{
183-
f1ap_message msg = test_helpers::create_ue_context_setup_request(
184-
gnb_cu_ue_f1ap_id_t{0}, gnb_du_ue_f1ap_id_t{0}, 1, {drb_id_t::drb1});
185-
msg.pdu.init_msg().value.ue_context_setup_request()->gnb_du_ue_f1ap_id_present = false;
198+
f1ap_message msg =
199+
test_helpers::create_ue_context_setup_request(gnb_cu_ue_f1ap_id_t{0}, std::nullopt, 1, {drb_id_t::drb1});
186200

187201
start_procedure(msg);
188202

@@ -199,11 +213,11 @@ TEST_F(
199213
f1ap_du_ue_context_setup_test,
200214
when_f1ap_receives_request_without_gnb_du_ue_f1ap_id_then_ue_context_setup_response_is_sent_to_cu_cp_with_crnti_ie)
201215
{
202-
f1ap_message msg = test_helpers::create_ue_context_setup_request(
203-
gnb_cu_ue_f1ap_id_t{0}, gnb_du_ue_f1ap_id_t{0}, 1, {drb_id_t::drb1});
204-
msg.pdu.init_msg().value.ue_context_setup_request()->gnb_du_ue_f1ap_id_present = false;
216+
f1ap_message msg =
217+
test_helpers::create_ue_context_setup_request(gnb_cu_ue_f1ap_id_t{0}, std::nullopt, 1, {drb_id_t::drb1});
205218

206219
start_procedure(msg);
220+
on_rrc_container_transmitted(1);
207221

208222
// F1AP sends UE CONTEXT SETUP RESPONSE to CU-CP.
209223
ASSERT_EQ(this->f1c_gw.last_tx_f1ap_pdu.pdu.type().value, f1ap_pdu_c::types_opts::successful_outcome);

0 commit comments

Comments
 (0)