Skip to content

Commit c6b218e

Browse files
committed
sched: write unit test for multi slice scheduling
1 parent 9c104d5 commit c6b218e

File tree

3 files changed

+77
-15
lines changed

3 files changed

+77
-15
lines changed

include/srsran/ran/rrm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ namespace srsran {
1818
/// \remark See O-RAN.WG3.E2SM-RC-R003-v3.00 Section 8.4.3.6
1919
struct rrm_policy_member {
2020
std::string plmn_id;
21-
s_nssai_t s_nssai;
21+
/// Single Network Slice Selection Assistance Information (S-NSSAI).
22+
s_nssai_t s_nssai;
2223

2324
bool operator==(const rrm_policy_member& other) const
2425
{

lib/scheduler/slicing/slice_scheduler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ std::optional<dl_ran_slice_candidate> slice_scheduler::create_dl_candidate()
154154
{
155155
if (sorted_dl_prios[0].prio != ran_slice_instance::skip_slice_prio) {
156156
slices[sorted_dl_prios[0].id.value()].set_pdsch_scheduled();
157-
sorted_dl_prios[0].prio = ran_slice_instance::skip_slice_prio;
158157
return dl_ran_slice_candidate{slices[sorted_dl_prios[0].id.value()]};
159158
}
160159
return std::nullopt;
@@ -164,7 +163,6 @@ std::optional<ul_ran_slice_candidate> slice_scheduler::create_ul_candidate()
164163
{
165164
if (sorted_ul_prios[0].prio != ran_slice_instance::skip_slice_prio) {
166165
slices[sorted_ul_prios[0].id.value()].set_pusch_scheduled();
167-
sorted_ul_prios[0].prio = ran_slice_instance::skip_slice_prio;
168166
return ul_ran_slice_candidate{slices[sorted_ul_prios[0].id.value()]};
169167
}
170168
return std::nullopt;

tests/unittests/scheduler/slicing/slice_scheduler_test.cpp

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,12 @@ class slice_scheduler_test : public ::testing::Test
3939
srslog::init();
4040
}
4141

42-
~slice_scheduler_test() { srslog::flush(); }
42+
~slice_scheduler_test() override { srslog::flush(); }
4343

44-
const ue_configuration* add_ue(du_ue_index_t ue_idx)
44+
const ue_configuration* add_ue(const sched_ue_creation_request_message& req)
4545
{
46-
auto req = test_cfg.get_default_ue_config_request();
47-
req.ue_index = ue_idx;
48-
req.crnti = to_rnti(0x4601 + ue_idx);
49-
req.starts_in_fallback = false;
5046
const ue_configuration* ue_cfg = test_cfg.add_ue(req);
51-
5247
slice_sched.add_ue(*ue_cfg);
53-
5448
return ue_cfg;
5549
}
5650

@@ -62,7 +56,37 @@ class slice_scheduler_test : public ::testing::Test
6256
};
6357

6458
class default_slice_scheduler_test : public slice_scheduler_test
65-
{};
59+
{
60+
protected:
61+
const ue_configuration* add_ue(du_ue_index_t ue_idx)
62+
{
63+
auto req = test_cfg.get_default_ue_config_request();
64+
req.ue_index = ue_idx;
65+
req.crnti = to_rnti(0x4601 + ue_idx);
66+
req.starts_in_fallback = false;
67+
return slice_scheduler_test::add_ue(req);
68+
}
69+
};
70+
71+
class rb_ratio_slice_scheduler_test : public slice_scheduler_test
72+
{
73+
protected:
74+
constexpr static unsigned MIN_PRB = 10;
75+
constexpr static unsigned MAX_PRB = 20;
76+
77+
rb_ratio_slice_scheduler_test() : slice_scheduler_test({{{"00101", s_nssai_t{1}}, MIN_PRB, MAX_PRB}}) {}
78+
79+
const ue_configuration* add_ue(du_ue_index_t ue_idx)
80+
{
81+
auto req = test_cfg.get_default_ue_config_request();
82+
req.ue_index = ue_idx;
83+
req.crnti = to_rnti(0x4601 + ue_idx);
84+
req.starts_in_fallback = false;
85+
(*req.cfg.lc_config_list)[2].rrm_policy.plmn_id = "00101";
86+
(*req.cfg.lc_config_list)[2].rrm_policy.s_nssai = s_nssai_t{1};
87+
return slice_scheduler_test::add_ue(req);
88+
}
89+
};
6690

6791
TEST_F(default_slice_scheduler_test, if_no_rrm_policy_cfg_exists_then_only_default_slice_is_created)
6892
{
@@ -84,7 +108,7 @@ TEST_F(default_slice_scheduler_test, when_no_lcid_exists_then_default_slice_is_n
84108

85109
TEST_F(default_slice_scheduler_test, when_lcid_is_part_of_default_slice_then_default_slice_is_valid_candidate)
86110
{
87-
this->add_ue(to_du_ue_index(0));
111+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
88112
slice_sched.slot_indication();
89113

90114
auto next_dl_slice = slice_sched.get_next_dl_candidate();
@@ -103,7 +127,7 @@ TEST_F(default_slice_scheduler_test, when_lcid_is_part_of_default_slice_then_def
103127
TEST_F(default_slice_scheduler_test,
104128
when_candidate_instance_goes_out_of_scope_then_it_stops_being_a_candidate_for_the_same_slot)
105129
{
106-
this->add_ue(to_du_ue_index(0));
130+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
107131
slice_sched.slot_indication();
108132

109133
auto next_dl_slice = slice_sched.get_next_dl_candidate();
@@ -116,7 +140,7 @@ TEST_F(default_slice_scheduler_test,
116140

117141
TEST_F(default_slice_scheduler_test, when_candidate_instance_goes_out_of_scope_then_it_can_be_a_candidate_for_next_slot)
118142
{
119-
this->add_ue(to_du_ue_index(0));
143+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
120144

121145
slice_sched.slot_indication();
122146
auto next_dl_slice = slice_sched.get_next_dl_candidate();
@@ -127,3 +151,42 @@ TEST_F(default_slice_scheduler_test, when_candidate_instance_goes_out_of_scope_t
127151
ASSERT_TRUE(next_dl_slice.has_value());
128152
ASSERT_EQ(next_dl_slice->id(), ran_slice_id_t{0});
129153
}
154+
155+
TEST_F(default_slice_scheduler_test, when_grant_gets_allocated_then_number_of_available_rbs_decreases)
156+
{
157+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
158+
slice_sched.slot_indication();
159+
160+
auto next_dl_slice = slice_sched.get_next_dl_candidate();
161+
162+
unsigned alloc_rbs = 10;
163+
unsigned rem_rbs = next_dl_slice->remaining_rbs();
164+
next_dl_slice->store_grant(alloc_rbs);
165+
ASSERT_EQ(next_dl_slice->remaining_rbs(), rem_rbs - alloc_rbs);
166+
}
167+
168+
// rb_ratio_slice_scheduler_test
169+
170+
TEST_F(rb_ratio_slice_scheduler_test, when_slice_with_min_rb_has_ues_then_it_is_the_first_candidate)
171+
{
172+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
173+
slice_sched.slot_indication();
174+
175+
auto next_dl_slice = slice_sched.get_next_dl_candidate();
176+
ASSERT_EQ(next_dl_slice->id(), ran_slice_id_t{1});
177+
ASSERT_TRUE(next_dl_slice->is_candidate(to_du_ue_index(0), lcid_t::LCID_MIN_DRB));
178+
179+
next_dl_slice = slice_sched.get_next_dl_candidate();
180+
ASSERT_EQ(next_dl_slice->id(), ran_slice_id_t{0});
181+
}
182+
183+
TEST_F(rb_ratio_slice_scheduler_test, when_slice_rb_ratios_are_bounded_then_remaining_rbs_is_bounded)
184+
{
185+
ASSERT_NE(this->add_ue(to_du_ue_index(0)), nullptr);
186+
slice_sched.slot_indication();
187+
188+
auto next_dl_slice = slice_sched.get_next_dl_candidate();
189+
ASSERT_EQ(next_dl_slice->id(), ran_slice_id_t{1});
190+
191+
ASSERT_LE(next_dl_slice->remaining_rbs(), MAX_PRB);
192+
}

0 commit comments

Comments
 (0)