@@ -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
6458class 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
6791TEST_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
85109TEST_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
103127TEST_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
117141TEST_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