Skip to content

Commit d458847

Browse files
andrepuschmanncodebot
authored andcommitted
cu_cp,tests: add basic Inter DU mobility test
1 parent 15e2180 commit d458847

8 files changed

+351
-0
lines changed

tests/unittests/cu_cp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ add_subdirectory(du_processor)
1414
add_subdirectory(cu_up_processor)
1515
add_subdirectory(ue_manager)
1616
add_subdirectory(up_resource_manager)
17+
add_subdirectory(mobility)
1718

1819
add_library(cu_cp_test_helpers cu_cp_test_helpers.cpp du_processor_test_messages.cpp test_helpers.cpp)
1920
target_include_directories(cu_cp_test_helpers PRIVATE ${CMAKE_SOURCE_DIR})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright 2021-2023 Software Radio Systems Limited
3+
#
4+
# By using this file, you agree to the terms and conditions set
5+
# forth in the LICENSE file which can be found at the top level of
6+
# the distribution.
7+
#
8+
9+
add_library(mobility_test_helpers mobility_test_helpers.cpp ../du_processor_test_messages.cpp ../test_helpers.cpp inter_du_handover_routine_test_helpers.cpp)
10+
target_include_directories(mobility_test_helpers PRIVATE ${CMAKE_SOURCE_DIR})
11+
target_link_libraries(mobility_test_helpers srsran_cu_cp srsran_e1ap e1ap_test_helpers f1ap_test_helpers rrc_ue_test_helpers ngap_test_helpers srsran_support f1ap_asn1 srslog)
12+
13+
set(SOURCES inter_du_handover_routine_test.cpp)
14+
15+
add_executable(cu_cp_mobility_test ${SOURCES})
16+
target_include_directories(cu_cp_mobility_test PRIVATE ${CMAKE_SOURCE_DIR})
17+
target_link_libraries(cu_cp_mobility_test mobility_test_helpers srsran_support srslog gtest gtest_main)
18+
gtest_discover_tests(cu_cp_mobility_test PROPERTIES "LABELS;mobility")
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
// #include "du_processor_test_helpers.h"
12+
#include "inter_du_handover_routine_test_helpers.h"
13+
#include "lib/cu_cp/routine_managers/du_processor_routine_manager.h"
14+
#include "lib/e1ap/cu_cp/e1ap_cu_cp_asn1_helpers.h"
15+
#include "mobility_test_helpers.h"
16+
#include "srsran/support/async/async_test_utils.h"
17+
#include "srsran/support/test_utils.h"
18+
#include <gtest/gtest.h>
19+
20+
using namespace srsran;
21+
using namespace srs_cu_cp;
22+
23+
class inter_du_handover_routine_test : public mobility_test
24+
{
25+
protected:
26+
inter_du_handover_routine_test() {}
27+
28+
void create_dus_and_attach_ue()
29+
{
30+
du_processor_config_t du_cfg;
31+
du_cfg.du_index = source_du_index;
32+
source_du = create_du(du_cfg);
33+
ASSERT_NE(source_du, nullptr);
34+
35+
attach_du_to_cu(*source_du, source_du_id, source_nrcell_id, source_pci);
36+
37+
du_cfg.du_index = target_du_index;
38+
target_du = create_du(du_cfg);
39+
ASSERT_NE(target_du, nullptr);
40+
41+
attach_du_to_cu(*target_du, target_du_id, target_nrcell_id, source_pci);
42+
43+
source_ue_index = attach_ue(*source_du, source_nrcell_id).ue_index;
44+
ASSERT_NE(source_ue_index, ue_index_t::invalid);
45+
}
46+
47+
void start_procedure(const cu_cp_inter_du_handover_request& msg)
48+
{
49+
t = source_du->du_processor_obj->handle_inter_du_handover_request(
50+
msg, target_du->du_processor_obj->get_du_processor_f1ap_ue_context_notifier());
51+
t_launcher.emplace(t);
52+
}
53+
54+
bool procedure_ready() const { return t.ready(); }
55+
56+
const cu_cp_inter_du_handover_response& get_result() { return t.get(); }
57+
58+
ue_index_t get_source_ue() { return source_ue_index; }
59+
60+
unsigned get_target_pci() { return target_pci; }
61+
62+
du_index_t get_target_du_index() { return target_du_index; }
63+
64+
private:
65+
// source DU parameters.
66+
du_index_t source_du_index = uint_to_du_index(1);
67+
unsigned source_du_id = 0x11;
68+
unsigned source_nrcell_id = 411;
69+
unsigned source_pci = 1;
70+
71+
// target DU parameters.
72+
du_index_t target_du_index = uint_to_du_index(2);
73+
unsigned target_du_id = 0x22;
74+
unsigned target_nrcell_id = 0x11;
75+
unsigned target_pci = 2;
76+
77+
// Handler to DU objects.
78+
du_wrapper* source_du = nullptr;
79+
du_wrapper* target_du = nullptr;
80+
81+
ue_index_t source_ue_index = ue_index_t::invalid;
82+
83+
async_task<cu_cp_inter_du_handover_response> t;
84+
optional<lazy_task_launcher<cu_cp_inter_du_handover_response>> t_launcher;
85+
};
86+
87+
TEST_F(inter_du_handover_routine_test, when_invalid_pci_is_used_ho_fails)
88+
{
89+
// Test Preamble.
90+
create_dus_and_attach_ue();
91+
92+
cu_cp_inter_du_handover_request request = generate_inter_du_handover_request();
93+
request.neighbor_pci = INVALID_PCI;
94+
request.source_ue_index = get_source_ue();
95+
request.target_du_index = get_target_du_index();
96+
97+
// it should be ready immediately
98+
start_procedure(request);
99+
100+
ASSERT_TRUE(procedure_ready());
101+
102+
// HO failed.
103+
ASSERT_FALSE(get_result().success);
104+
}
105+
106+
TEST_F(inter_du_handover_routine_test, when_ue_context_setup_fails_ho_fails)
107+
{
108+
create_dus_and_attach_ue();
109+
110+
// Test Preamble.
111+
cu_cp_inter_du_handover_request request = generate_inter_du_handover_request();
112+
request.neighbor_pci = get_target_pci();
113+
request.source_ue_index = get_source_ue();
114+
request.target_du_index = get_target_du_index();
115+
116+
// it should be ready immediately
117+
start_procedure(request);
118+
119+
ASSERT_TRUE(procedure_ready());
120+
121+
// HO failed.
122+
ASSERT_FALSE(get_result().success);
123+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "inter_du_handover_routine_test_helpers.h"
12+
13+
using namespace srsran;
14+
using namespace srs_cu_cp;
15+
16+
cu_cp_inter_du_handover_request srsran::srs_cu_cp::generate_inter_du_handover_request()
17+
{
18+
cu_cp_inter_du_handover_request req;
19+
20+
return req;
21+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "srsran/cu_cp/cu_cp_types.h"
14+
15+
namespace srsran {
16+
namespace srs_cu_cp {
17+
18+
/// \brief Generate a Inter DU Handover Request.
19+
cu_cp_inter_du_handover_request generate_inter_du_handover_request();
20+
21+
} // namespace srs_cu_cp
22+
} // namespace srsran
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#include "mobility_test_helpers.h"
12+
#include "srsran/cu_cp/cell_meas_manager.h"
13+
#include "srsran/support/async/async_test_utils.h"
14+
15+
using namespace srsran;
16+
using namespace srs_cu_cp;
17+
18+
mobility_test::mobility_test()
19+
{
20+
test_logger.set_level(srslog::basic_levels::debug);
21+
cu_cp_logger.set_level(srslog::basic_levels::debug);
22+
srslog::init();
23+
}
24+
25+
mobility_test::~mobility_test()
26+
{
27+
// flush logger after each test
28+
srslog::flush();
29+
}
30+
31+
du_wrapper* mobility_test::create_du(const du_processor_config_t& du_cfg)
32+
{
33+
auto it = du_db.emplace(du_cfg.du_index, du_wrapper{});
34+
du_wrapper& new_du = it.first->second;
35+
36+
// create ue task scheduler
37+
new_du.ue_task_sched = std::make_unique<dummy_du_processor_ue_task_scheduler>(timers, ctrl_worker);
38+
39+
// create DU processor
40+
new_du.du_processor_obj = create_du_processor(std::move(du_cfg),
41+
new_du.cu_cp_notifier,
42+
new_du.f1ap_du_mgmt_notifier,
43+
new_du.f1ap_pdu_notifier,
44+
new_du.e1ap_ctrl_notifier,
45+
new_du.ngap_ctrl_notifier,
46+
new_du.rrc_ue_ngap_notifier,
47+
new_du.rrc_ue_ngap_notifier,
48+
new_du.rrc_ue_cu_cp_notifier,
49+
*new_du.ue_task_sched,
50+
ue_mng,
51+
new_du.cell_meas_mng,
52+
ctrl_worker);
53+
54+
return &new_du;
55+
}
56+
57+
void mobility_test::attach_du_to_cu(du_wrapper& du, unsigned gnb_du_id, unsigned nrcell_id, pci_t pci)
58+
{
59+
// Generate valid F1SetupRequest
60+
f1ap_f1_setup_request f1_setup_request_msg;
61+
generate_valid_f1_setup_request(f1_setup_request_msg, gnb_du_id, nrcell_id, pci);
62+
63+
// Pass message to DU processor
64+
du.du_processor_obj->handle_f1_setup_request(f1_setup_request_msg);
65+
}
66+
67+
ue_creation_complete_message mobility_test::attach_ue(du_wrapper& du, unsigned nrcell_id)
68+
{
69+
// Generate ue_creation message
70+
ue_creation_message ue_creation_msg = generate_ue_creation_message(MIN_CRNTI, nrcell_id);
71+
// Pass message to DU processor
72+
return du.du_processor_obj->handle_ue_creation_request(ue_creation_msg);
73+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "../du_processor/du_processor_test_helpers.h"
14+
#include "../du_processor_test_messages.h"
15+
#include "../test_helpers.h"
16+
#include "lib/cu_cp/routine_managers/cu_cp_routine_manager.h"
17+
#include "lib/cu_cp/ue_manager_impl.h"
18+
#include "lib/f1ap/common/asn1_helpers.h"
19+
#include "tests/unittests/f1ap/common/test_helpers.h"
20+
#include "tests/unittests/f1ap/cu_cp/f1ap_cu_test_helpers.h"
21+
#include "tests/unittests/rrc/test_helpers.h"
22+
#include "srsran/cu_cp/cu_cp_types.h"
23+
#include "srsran/cu_cp/du_processor.h"
24+
#include "srsran/rrc/rrc.h"
25+
#include "srsran/support/executors/manual_task_worker.h"
26+
#include "srsran/support/test_utils.h"
27+
#include <gtest/gtest.h>
28+
29+
namespace srsran {
30+
namespace srs_cu_cp {
31+
32+
struct du_wrapper {
33+
du_wrapper() : cu_cp_notifier(nullptr), f1ap_pdu_notifier(nullptr){};
34+
35+
dummy_cell_meas_manager cell_meas_mng;
36+
dummy_du_processor_cu_cp_notifier cu_cp_notifier;
37+
dummy_f1ap_pdu_notifier f1ap_pdu_notifier;
38+
dummy_f1ap_du_management_notifier f1ap_du_mgmt_notifier;
39+
dummy_du_processor_e1ap_control_notifier e1ap_ctrl_notifier;
40+
dummy_du_processor_ngap_control_notifier ngap_ctrl_notifier;
41+
dummy_rrc_ue_ngap_adapter rrc_ue_ngap_notifier;
42+
dummy_rrc_ue_cu_cp_adapter rrc_ue_cu_cp_notifier;
43+
std::unique_ptr<dummy_du_processor_ue_task_scheduler> ue_task_sched;
44+
std::unique_ptr<du_processor_interface> du_processor_obj;
45+
};
46+
47+
/// Fixture class for CU-CP mobility tests
48+
class mobility_test : public ::testing::Test
49+
{
50+
protected:
51+
mobility_test();
52+
~mobility_test() override;
53+
54+
du_wrapper* create_du(const du_processor_config_t& du_cfg);
55+
void attach_du_to_cu(du_wrapper& du, unsigned gnb_du_id, unsigned nrcell_id, pci_t pci);
56+
ue_creation_complete_message attach_ue(du_wrapper& du, unsigned nrcell_id);
57+
58+
private:
59+
srslog::basic_logger& test_logger = srslog::fetch_basic_logger("TEST");
60+
srslog::basic_logger& cu_cp_logger = srslog::fetch_basic_logger("CU-CP");
61+
62+
manual_task_worker ctrl_worker{128};
63+
timer_manager timers;
64+
ue_configuration ue_config;
65+
ue_manager ue_mng{ue_config};
66+
67+
std::unordered_map<du_index_t, du_wrapper> du_db;
68+
};
69+
70+
} // namespace srs_cu_cp
71+
} // namespace srsran
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
*
3+
* Copyright 2021-2023 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "srsran/cu_cp/cu_cp_types.h"
14+
15+
namespace srsran {
16+
namespace srs_cu_cp {
17+
18+
/// \brief Generate a Inter DU Handover Request.
19+
cu_cp_inter_du_handover_request generate_inter_du_handover_request();
20+
21+
} // namespace srs_cu_cp
22+
} // namespace srsran

0 commit comments

Comments
 (0)