2 * Copyright (c) 2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 * platform project (RICP).
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
34 Test permutations of x2 setup response to protobuf enb
37 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
38 logger, _ := logger.InitLogger(logger.InfoLevel)
40 var testCases = []struct {
41 key *entities.GlobalNbId
47 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
48 gnb: "CONNECTED [served_nr_cell_information:{nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS60 ncnrb:NRB107}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} transmission_bandwidth:{nrscs:SCS30 ncnrb:NRB133}}}} served_nr_cell_information:{nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS120 ncnrb:NRB121}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB132}}}} nr_neighbour_infos:{nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:{tdd:{ar_fcn_nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB11}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}}}}}]",
52 procedureCode_t = 0x24
56 ProtocolIE_Container_elm
59 RespondingNodeType-EndcX2Setup:
61 ProtocolIE_Container_elm
65 pLMN_Identity_t = 02 f8 29
67 gNB_ID_t = 4a 95 2a 0a (32 bits)
68 ProtocolIE_Container_elm
71 ServedNRcellsENDCX2ManagementList:
72 ServedNRcellsENDCX2ManagementList_elm
76 pLMN_Identity_t = 1e 3f 27
77 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
78 fiveGS_TAC_t = 3d 44 d3
79 configured_TAC_t = 4e 4f
81 BroadcastPLMNs_Item_elm = 3e 4e 5e
88 freqBandIndicatorNr_t = 0x16
89 supportedSULBandList_t:
90 supportedSULBandList_t_elm
91 freqBandIndicatorNr_t = 0xb
100 measurementTimingConfiguration_t = 3e 4e 5e
101 ServedNRcellsENDCX2ManagementList_elm
105 pLMN_Identity_t = 1e 3f 27
106 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
107 fiveGS_TAC_t = 3d 44 d3
108 configured_TAC_t = 4e 4f
110 BroadcastPLMNs_Item_elm = 3e 4e 5e
117 freqBandIndicatorNr_t = 0x16
118 supportedSULBandList_t:
119 supportedSULBandList_t_elm
120 freqBandIndicatorNr_t = 0xb
129 measurementTimingConfiguration_t = 3e 4e 5e
131 NRNeighbour_Information_elm
134 pLMN_Identity_t = 1e 3f 27
135 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
136 measurementTimingConfiguration_t = 1e 3f 27
137 nRNeighbourModeInfo_t:
143 freqBandIndicatorNr_t = 0x16
144 supportedSULBandList_t:
145 supportedSULBandList_t_elm
146 freqBandIndicatorNr_t = 0xb
154 packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
156 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
157 gnb: "CONNECTED [served_nr_cell_information:{nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS30 ncnrb:NRB107}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB121}}}} nr_neighbour_infos:{nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:{tdd:{ar_fcn_nr_freq_info:{nr_ar_fcn:5 sulInformation:{sul_ar_fcn:6 sul_transmission_bandwidth:{nrscs:SCS120 ncnrb:NRB18}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}}}}}]",
161 procedureCode_t = 0x24
165 ProtocolIE_Container_elm
168 RespondingNodeType-EndcX2Setup:
170 ProtocolIE_Container_elm
174 pLMN_Identity_t = 02 f8 29
176 gNB_ID_t = 4a 95 2a 0a (32 bits)
177 ProtocolIE_Container_elm
180 ServedNRcellsENDCX2ManagementList:
181 ServedNRcellsENDCX2ManagementList_elm
185 pLMN_Identity_t = 1e 3f 27
186 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
187 fiveGS_TAC_t = 3d 44 d3
188 configured_TAC_t = 4e 4f
190 BroadcastPLMNs_Item_elm = 3e 4e 5e
197 freqBandIndicatorNr_t = 0x16
198 supportedSULBandList_t:
199 supportedSULBandList_t_elm
200 freqBandIndicatorNr_t = 0xb
209 measurementTimingConfiguration_t = 3e 4e 5e
211 NRNeighbour_Information_elm
214 pLMN_Identity_t = 1e 3f 27
215 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
216 measurementTimingConfiguration_t = 1e 3f 27
217 nRNeighbourModeInfo_t:
223 freqBandIndicatorNr_t = 0x16
224 supportedSULBandList_t:
225 supportedSULBandList_t_elm
226 freqBandIndicatorNr_t = 0xb
234 packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
237 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
238 gnb: "CONNECTED [served_nr_cell_information:{nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" stac5g:\"3d44d3\" configured_stac:\"4e4f\" served_plmns:\"3e4e5e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS60 ncnrb:NRB107}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} transmission_bandwidth:{nrscs:SCS30 ncnrb:NRB133}}}} served_nr_cell_information:{nr_pci:8 cell_id:\"2e3f45:1f2e3d4ff0\" stac5g:\"4faa3c\" configured_stac:\"1a2f\" served_plmns:\"50321e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:4 sulInformation:{sul_ar_fcn:8 sul_transmission_bandwidth:{nrscs:SCS120 ncnrb:NRB121}} frequency_bands:{nr_frequency_band:7 supported_sul_bands:3}} transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB132}}}} nr_neighbour_infos:{nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:TDD choice_nr_mode:{tdd:{ar_fcn_nr_freq_info:{nr_ar_fcn:1 sulInformation:{sul_ar_fcn:2 sul_transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB11}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}}}}}]",
242 procedureCode_t = 0x24
246 ProtocolIE_Container_elm
249 RespondingNodeType-EndcX2Setup:
251 ProtocolIE_Container_elm
255 pLMN_Identity_t = 02 f8 29
257 gNB_ID_t = 4a 95 2a 0a (32 bits)
258 ProtocolIE_Container_elm
261 ServedNRcellsENDCX2ManagementList:
262 ServedNRcellsENDCX2ManagementList_elm
266 pLMN_Identity_t = 1e 3f 27
267 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
268 fiveGS_TAC_t = 3d 44 d3
269 configured_TAC_t = 4e 4f
271 BroadcastPLMNs_Item_elm = 3e 4e 5e
278 freqBandIndicatorNr_t = 0x16
279 supportedSULBandList_t:
280 supportedSULBandList_t_elm
281 freqBandIndicatorNr_t = 0xb
290 measurementTimingConfiguration_t = 3e 4e 5e
291 ServedNRcellsENDCX2ManagementList_elm
295 pLMN_Identity_t = 2e 3f 45
296 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
297 fiveGS_TAC_t = 4f aa 3c
298 configured_TAC_t = 1a 2f
300 BroadcastPLMNs_Item_elm = 50 32 1e
307 freqBandIndicatorNr_t = 0x7
308 supportedSULBandList_t:
309 supportedSULBandList_t_elm
310 freqBandIndicatorNr_t = 0x3
319 measurementTimingConfiguration_t = 50 32 1e
321 NRNeighbour_Information_elm
324 pLMN_Identity_t = 1e 3f 27
325 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
326 measurementTimingConfiguration_t = 1e 3f 27
327 nRNeighbourModeInfo_t:
333 freqBandIndicatorNr_t = 0x16
334 supportedSULBandList_t:
335 supportedSULBandList_t_elm
336 freqBandIndicatorNr_t = 0xb
343 packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
346 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
347 gnb: "CONNECTED [served_nr_cell_information:{nr_pci:5 cell_id:\"1e3f27:1f2e3d4ff0\" served_plmns:\"3e4e5e\" nr_mode:FDD choice_nr_mode:{fdd:{ul_freq_info:{nr_ar_fcn:5 frequency_bands:{nr_frequency_band:44 supported_sul_bands:33}} dl_freq_info:{nr_ar_fcn:1 frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} ul_transmission_bandwidth:{nrscs:SCS120 ncnrb:NRB11} dl_transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB135}}}} nr_neighbour_infos:{nr_pci:44 nr_cgi:\"1e3f27:1f2e3d4ff0\" nr_mode:FDD choice_nr_mode:{fdd:{ular_fcn_freq_info:{nr_ar_fcn:5 frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} dlar_fcn_freq_info:{nr_ar_fcn:1 frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}}}}}]",
351 procedureCode_t = 0x24
355 ProtocolIE_Container_elm
358 RespondingNodeType-EndcX2Setup:
360 ProtocolIE_Container_elm
364 pLMN_Identity_t = 02 f8 29
366 gNB_ID_t = 4a 95 2a 0a (32 bits)
367 ProtocolIE_Container_elm
370 ServedNRcellsENDCX2ManagementList:
371 ServedNRcellsENDCX2ManagementList_elm
375 pLMN_Identity_t = 1e 3f 27
376 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
378 BroadcastPLMNs_Item_elm = 3e 4e 5e
385 freqBandIndicatorNr_t = 0x2c
386 supportedSULBandList_t:
387 supportedSULBandList_t_elm
388 freqBandIndicatorNr_t = 0x21
393 freqBandIndicatorNr_t = 0x16
394 supportedSULBandList_t:
395 supportedSULBandList_t_elm
396 freqBandIndicatorNr_t = 0xb
403 measurementTimingConfiguration_t = 01 02 03
405 NRNeighbour_Information_elm
408 pLMN_Identity_t = 1e 3f 27
409 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
410 measurementTimingConfiguration_t = 01 02 03
411 nRNeighbourModeInfo_t:
417 freqBandIndicatorNr_t = 0x16
418 supportedSULBandList_t:
419 supportedSULBandList_t_elm
420 freqBandIndicatorNr_t = 0xb
425 freqBandIndicatorNr_t = 0x16
426 supportedSULBandList_t:
427 supportedSULBandList_t_elm
428 freqBandIndicatorNr_t = 0xb
432 packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
436 key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
437 gnb: "CONNECTED [served_nr_cell_information:{nr_pci:9 cell_id:\"aeafa7:2a3e3b4cd0\" stac5g:\"7d4773\" configured_stac:\"477f\" served_plmns:\"7e7e7e\" nr_mode:TDD choice_nr_mode:{tdd:{nr_freq_info:{nr_ar_fcn:8 sulInformation:{sul_ar_fcn:9 sul_transmission_bandwidth:{nrscs:SCS15 ncnrb:NRB121}} frequency_bands:{nr_frequency_band:22 supported_sul_bands:11}} transmission_bandwidth:{nrscs:SCS60 ncnrb:NRB18}}}} nr_neighbour_infos:{nr_pci:44 nr_cgi:\"5a5ff1:2a3e3b4cd0\" nr_mode:TDD choice_nr_mode:{tdd:{ar_fcn_nr_freq_info:{nr_ar_fcn:5 sulInformation:{sul_ar_fcn:6 sul_transmission_bandwidth:{nrscs:SCS30 ncnrb:NRB18}} frequency_bands:{nr_frequency_band:4 supported_sul_bands:3}}}}} nr_neighbour_infos:{nr_pci:9 nr_cgi:\"5d5caa:af3e354ac0\" nr_mode:TDD choice_nr_mode:{tdd:{ar_fcn_nr_freq_info:{nr_ar_fcn:7 sulInformation:{sul_ar_fcn:8 sul_transmission_bandwidth:{nrscs:SCS120 ncnrb:NRB25}} frequency_bands:{nr_frequency_band:3 supported_sul_bands:1}}}}}]",
441 procedureCode_t = 0x24
445 ProtocolIE_Container_elm
448 RespondingNodeType-EndcX2Setup:
450 ProtocolIE_Container_elm
454 pLMN_Identity_t = 04 a5 c1
456 gNB_ID_t = 4f c5 2b ff (32 bits)
457 ProtocolIE_Container_elm
460 ServedNRcellsENDCX2ManagementList:
461 ServedNRcellsENDCX2ManagementList_elm
465 pLMN_Identity_t = ae af a7
466 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
467 fiveGS_TAC_t = 7d 47 73
468 configured_TAC_t = 47 7f
470 BroadcastPLMNs_Item_elm = 7e 7e 7e
477 freqBandIndicatorNr_t = 0x16
478 supportedSULBandList_t:
479 supportedSULBandList_t_elm
480 freqBandIndicatorNr_t = 0xb
489 measurementTimingConfiguration_t = 7e 7e 7e
491 NRNeighbour_Information_elm
494 pLMN_Identity_t = 5a 5f f1
495 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
496 measurementTimingConfiguration_t = 5a 5f f1
497 nRNeighbourModeInfo_t:
503 freqBandIndicatorNr_t = 0x4
504 supportedSULBandList_t:
505 supportedSULBandList_t_elm
506 freqBandIndicatorNr_t = 0x3
512 NRNeighbour_Information_elm
515 pLMN_Identity_t = 5d 5c aa
516 nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
517 measurementTimingConfiguration_t = 5d 5c aa
518 nRNeighbourModeInfo_t:
524 freqBandIndicatorNr_t = 0x3
525 supportedSULBandList_t:
526 supportedSULBandList_t_elm
527 freqBandIndicatorNr_t = 0x1
534 packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
536 {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
540 procedureCode_t = 0x24
544 ProtocolIE_Container_elm
547 RespondingNodeType-EndcX2Setup:
549 ProtocolIE_Container_elm
553 pLMN_Identity_t = 02 f8 29
555 gNB_ID_t = 4a 95 2a aa (32 bits)
557 packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
559 failure: fmt.Errorf("getList for path [successfulOutcome_t ENDCX2SetupResponse protocolIEs_t ProtocolIE_Container_elm RespondingNodeType-EndcX2Setup respond_en_gNB_t ProtocolIE_Container_elm ServedNRcellsENDCX2ManagementList ServedNRcellsENDCX2ManagementList_elm servedNRCellInfo_t nrpCI_t] failed, rc = 1" /*NO_ITEMS*/),},
562 converter := NewEndcSetupResponseConverter(logger)
564 for _, tc := range testCases {
565 t.Run(tc.packedPdu, func(t *testing.T) {
569 _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
572 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
575 key, gnb, err := converter.UnpackEndcSetupResponseAndExtract(payload)
578 if tc.failure == nil {
579 t.Errorf("want: success, got: error: %v\n", err)
581 if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
582 t.Errorf("want: %s, got: %s", tc.failure, err)
588 if tc.failure == nil {
589 t.Errorf("want: key=%v, got: empty key", tc.key)
592 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
593 t.Errorf("want: key=%v, got: %v", tc.key, key)
598 if tc.failure == nil {
599 t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
602 nb := &entities.NodebInfo{}
603 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
604 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
605 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
607 space := regexp.MustCompile(`\s+`)
608 s1 := space.ReplaceAllString(gnbStr, " ")
609 s2 := space.ReplaceAllString(tc.gnb," ")
611 if !strings.EqualFold(s1, s2) {
612 t.Errorf("want: [%s], got: [%s]", tc.gnb, gnbStr)