1010
1111#include " ../rrc/rrc_ue_test_messages.h"
1212#include " cu_cp_test_helpers.h"
13+ #include " srsran/asn1/f1ap/f1ap.h"
14+ #include " srsran/f1ap/common/f1ap_common.h"
15+ #include " srsran/ran/cu_types.h"
1316#include < gtest/gtest.h>
1417
1518using namespace srsran ;
@@ -420,13 +423,15 @@ TEST_F(cu_cp_test, when_invalid_paging_message_received_then_paging_is_not_sent_
420423TEST_F (cu_cp_test, when_ue_level_inactivity_message_received_then_ue_context_release_request_is_sent)
421424{
422425 // Test preamble
423- du_index_t du_index = uint_to_du_index (0 );
424- gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
425- gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
426- pci_t pci = 0 ;
427- rnti_t crnti = to_rnti (0x4601 );
428- test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti);
429- receive_ngap_dl_info_transfer ();
426+ du_index_t du_index = uint_to_du_index (0 );
427+ gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
428+ gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
429+ pci_t pci = 0 ;
430+ rnti_t crnti = to_rnti (0x4601 );
431+ amf_ue_id_t amf_ue_id = uint_to_amf_ue_id (
432+ test_rgen::uniform_int<uint64_t >(amf_ue_id_to_uint (amf_ue_id_t ::min), amf_ue_id_to_uint (amf_ue_id_t ::max)));
433+ ran_ue_id_t ran_ue_id = uint_to_ran_ue_id (0 );
434+ test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti, amf_ue_id, ran_ue_id);
430435
431436 cu_cp_inactivity_notification inactivity_notification;
432437 inactivity_notification.ue_index = uint_to_ue_index (0 );
@@ -446,12 +451,15 @@ TEST_F(cu_cp_test, when_ue_level_inactivity_message_received_then_ue_context_rel
446451TEST_F (cu_cp_test, when_unsupported_inactivity_message_received_then_ue_context_release_request_is_not_sent)
447452{
448453 // Test preamble
449- du_index_t du_index = uint_to_du_index (0 );
450- gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
451- gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
452- rnti_t crnti = to_rnti (0x4601 );
453- pci_t pci = 0 ;
454- test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti);
454+ du_index_t du_index = uint_to_du_index (0 );
455+ gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
456+ gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
457+ rnti_t crnti = to_rnti (0x4601 );
458+ pci_t pci = 0 ;
459+ amf_ue_id_t amf_ue_id = uint_to_amf_ue_id (
460+ test_rgen::uniform_int<uint64_t >(amf_ue_id_to_uint (amf_ue_id_t ::min), amf_ue_id_to_uint (amf_ue_id_t ::max)));
461+ ran_ue_id_t ran_ue_id = uint_to_ran_ue_id (0 );
462+ test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti, amf_ue_id, ran_ue_id);
455463
456464 cu_cp_inactivity_notification inactivity_notification;
457465 inactivity_notification.ue_index = uint_to_ue_index (0 );
@@ -464,6 +472,34 @@ TEST_F(cu_cp_test, when_unsupported_inactivity_message_received_then_ue_context_
464472 asn1::ngap::ngap_elem_procs_o::init_msg_c::types_opts::ue_context_release_request);
465473}
466474
475+ // ////////////////////////////////////////////////////////////////////////////////////
476+ /* AMF initiated UE Context Release */
477+ // ////////////////////////////////////////////////////////////////////////////////////
478+
479+ TEST_F (cu_cp_test, when_release_command_received_then_release_command_is_sent_to_du)
480+ {
481+ // Test preamble
482+ du_index_t du_index = uint_to_du_index (0 );
483+ gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
484+ gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
485+ rnti_t crnti = to_rnti (0x4601 );
486+ pci_t pci = 0 ;
487+ amf_ue_id_t amf_ue_id = uint_to_amf_ue_id (
488+ test_rgen::uniform_int<uint64_t >(amf_ue_id_to_uint (amf_ue_id_t ::min), amf_ue_id_to_uint (amf_ue_id_t ::max)));
489+ ran_ue_id_t ran_ue_id = uint_to_ran_ue_id (0 );
490+ test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti, amf_ue_id, ran_ue_id);
491+
492+ // Inject UE Context Release Command
493+ cu_cp_obj->get_ngap_message_handler ().handle_message (
494+ generate_valid_ue_context_release_command_with_amf_ue_ngap_id (amf_ue_id));
495+
496+ // check that the UE Context Release Command with RRC Container was sent to the DU
497+ ASSERT_EQ (f1ap_pdu_notifier.last_f1ap_msg .pdu .type (), asn1::f1ap::f1ap_pdu_c::types_opts::options::init_msg);
498+ ASSERT_EQ (f1ap_pdu_notifier.last_f1ap_msg .pdu .init_msg ().value .type ().value ,
499+ asn1::f1ap::f1ap_elem_procs_o::init_msg_c::types_opts::ue_context_release_cmd);
500+ ASSERT_TRUE (f1ap_pdu_notifier.last_f1ap_msg .pdu .init_msg ().value .ue_context_release_cmd ()->rrc_container_present );
501+ }
502+
467503// ////////////////////////////////////////////////////////////////////////////////////
468504/* DU Initiated UE Context Release */
469505// ////////////////////////////////////////////////////////////////////////////////////
@@ -472,13 +508,15 @@ TEST_F(cu_cp_test, when_unsupported_inactivity_message_received_then_ue_context_
472508TEST_F (cu_cp_test, when_du_initiated_ue_context_release_received_then_ue_context_release_request_is_sent)
473509{
474510 // Test preamble
475- du_index_t du_index = uint_to_du_index (0 );
476- gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
477- gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
478- rnti_t crnti = to_rnti (0x4601 );
479- pci_t pci = 0 ;
480- test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti);
481- receive_ngap_dl_info_transfer ();
511+ du_index_t du_index = uint_to_du_index (0 );
512+ gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
513+ gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
514+ rnti_t crnti = to_rnti (0x4601 );
515+ pci_t pci = 0 ;
516+ amf_ue_id_t amf_ue_id = uint_to_amf_ue_id (
517+ test_rgen::uniform_int<uint64_t >(amf_ue_id_to_uint (amf_ue_id_t ::min), amf_ue_id_to_uint (amf_ue_id_t ::max)));
518+ ran_ue_id_t ran_ue_id = uint_to_ran_ue_id (0 );
519+ test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti, amf_ue_id, ran_ue_id);
482520
483521 // Inject UE Context Release Request
484522 cu_cp_obj->get_f1ap_message_handler (uint_to_du_index (0 ))
@@ -499,13 +537,15 @@ TEST_F(cu_cp_test, when_du_initiated_ue_context_release_received_then_ue_context
499537TEST_F (cu_cp_test, when_reestablishment_fails_then_ue_released)
500538{
501539 // Test preamble
502- du_index_t du_index = uint_to_du_index (0 );
503- gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
504- gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
505- rnti_t crnti = to_rnti (0x4601 );
506- pci_t pci = 0 ;
507- test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti);
508- receive_ngap_dl_info_transfer ();
540+ du_index_t du_index = uint_to_du_index (0 );
541+ gnb_cu_ue_f1ap_id_t cu_ue_id = int_to_gnb_cu_ue_f1ap_id (0 );
542+ gnb_du_ue_f1ap_id_t du_ue_id = int_to_gnb_du_ue_f1ap_id (0 );
543+ rnti_t crnti = to_rnti (0x4601 );
544+ pci_t pci = 0 ;
545+ amf_ue_id_t amf_ue_id = uint_to_amf_ue_id (
546+ test_rgen::uniform_int<uint64_t >(amf_ue_id_to_uint (amf_ue_id_t ::min), amf_ue_id_to_uint (amf_ue_id_t ::max)));
547+ ran_ue_id_t ran_ue_id = uint_to_ran_ue_id (0 );
548+ test_preamble_ue_creation (du_index, du_ue_id, cu_ue_id, pci, crnti, amf_ue_id, ran_ue_id);
509549
510550 // Attach second UE with RRC Reestablishment Request
511551 {
0 commit comments