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) {
39 logger, _ := logger.InitLogger(InfoLevel)
41 var testCases = []struct {
42 key *entities.GlobalNbId
48 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
49 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}}}}}]",
53 procedureCode_t = 0x24
57 ProtocolIE_Container_elm
60 RespondingNodeType-EndcX2Setup:
62 ProtocolIE_Container_elm
66 pLMN_Identity_t = 02 f8 29
68 gNB_ID_t = 4a 95 2a 0a (32 bits)
69 ProtocolIE_Container_elm
72 ServedNRcellsENDCX2ManagementList:
73 ServedNRcellsENDCX2ManagementList_elm
77 pLMN_Identity_t = 1e 3f 27
78 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
79 fiveGS_TAC_t = 3d 44 d3
80 configured_TAC_t = 4e 4f
82 BroadcastPLMNs_Item_elm = 3e 4e 5e
89 freqBandIndicatorNr_t = 0x16
90 supportedSULBandList_t:
91 supportedSULBandList_t_elm
92 freqBandIndicatorNr_t = 0xb
101 measurementTimingConfiguration_t = 3e 4e 5e
102 ServedNRcellsENDCX2ManagementList_elm
106 pLMN_Identity_t = 1e 3f 27
107 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
108 fiveGS_TAC_t = 3d 44 d3
109 configured_TAC_t = 4e 4f
111 BroadcastPLMNs_Item_elm = 3e 4e 5e
118 freqBandIndicatorNr_t = 0x16
119 supportedSULBandList_t:
120 supportedSULBandList_t_elm
121 freqBandIndicatorNr_t = 0xb
130 measurementTimingConfiguration_t = 3e 4e 5e
132 NRNeighbour_Information_elm
135 pLMN_Identity_t = 1e 3f 27
136 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
137 measurementTimingConfiguration_t = 1e 3f 27
138 nRNeighbourModeInfo_t:
144 freqBandIndicatorNr_t = 0x16
145 supportedSULBandList_t:
146 supportedSULBandList_t_elm
147 freqBandIndicatorNr_t = 0xb
155 packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
157 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
158 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}}}}}]",
162 procedureCode_t = 0x24
166 ProtocolIE_Container_elm
169 RespondingNodeType-EndcX2Setup:
171 ProtocolIE_Container_elm
175 pLMN_Identity_t = 02 f8 29
177 gNB_ID_t = 4a 95 2a 0a (32 bits)
178 ProtocolIE_Container_elm
181 ServedNRcellsENDCX2ManagementList:
182 ServedNRcellsENDCX2ManagementList_elm
186 pLMN_Identity_t = 1e 3f 27
187 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
188 fiveGS_TAC_t = 3d 44 d3
189 configured_TAC_t = 4e 4f
191 BroadcastPLMNs_Item_elm = 3e 4e 5e
198 freqBandIndicatorNr_t = 0x16
199 supportedSULBandList_t:
200 supportedSULBandList_t_elm
201 freqBandIndicatorNr_t = 0xb
210 measurementTimingConfiguration_t = 3e 4e 5e
212 NRNeighbour_Information_elm
215 pLMN_Identity_t = 1e 3f 27
216 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
217 measurementTimingConfiguration_t = 1e 3f 27
218 nRNeighbourModeInfo_t:
224 freqBandIndicatorNr_t = 0x16
225 supportedSULBandList_t:
226 supportedSULBandList_t_elm
227 freqBandIndicatorNr_t = 0xb
235 packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
238 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
239 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}}}}}]",
243 procedureCode_t = 0x24
247 ProtocolIE_Container_elm
250 RespondingNodeType-EndcX2Setup:
252 ProtocolIE_Container_elm
256 pLMN_Identity_t = 02 f8 29
258 gNB_ID_t = 4a 95 2a 0a (32 bits)
259 ProtocolIE_Container_elm
262 ServedNRcellsENDCX2ManagementList:
263 ServedNRcellsENDCX2ManagementList_elm
267 pLMN_Identity_t = 1e 3f 27
268 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
269 fiveGS_TAC_t = 3d 44 d3
270 configured_TAC_t = 4e 4f
272 BroadcastPLMNs_Item_elm = 3e 4e 5e
279 freqBandIndicatorNr_t = 0x16
280 supportedSULBandList_t:
281 supportedSULBandList_t_elm
282 freqBandIndicatorNr_t = 0xb
291 measurementTimingConfiguration_t = 3e 4e 5e
292 ServedNRcellsENDCX2ManagementList_elm
296 pLMN_Identity_t = 2e 3f 45
297 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
298 fiveGS_TAC_t = 4f aa 3c
299 configured_TAC_t = 1a 2f
301 BroadcastPLMNs_Item_elm = 50 32 1e
308 freqBandIndicatorNr_t = 0x7
309 supportedSULBandList_t:
310 supportedSULBandList_t_elm
311 freqBandIndicatorNr_t = 0x3
320 measurementTimingConfiguration_t = 50 32 1e
322 NRNeighbour_Information_elm
325 pLMN_Identity_t = 1e 3f 27
326 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
327 measurementTimingConfiguration_t = 1e 3f 27
328 nRNeighbourModeInfo_t:
334 freqBandIndicatorNr_t = 0x16
335 supportedSULBandList_t:
336 supportedSULBandList_t_elm
337 freqBandIndicatorNr_t = 0xb
344 packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
347 key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
348 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}}}}}]",
352 procedureCode_t = 0x24
356 ProtocolIE_Container_elm
359 RespondingNodeType-EndcX2Setup:
361 ProtocolIE_Container_elm
365 pLMN_Identity_t = 02 f8 29
367 gNB_ID_t = 4a 95 2a 0a (32 bits)
368 ProtocolIE_Container_elm
371 ServedNRcellsENDCX2ManagementList:
372 ServedNRcellsENDCX2ManagementList_elm
376 pLMN_Identity_t = 1e 3f 27
377 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
379 BroadcastPLMNs_Item_elm = 3e 4e 5e
386 freqBandIndicatorNr_t = 0x2c
387 supportedSULBandList_t:
388 supportedSULBandList_t_elm
389 freqBandIndicatorNr_t = 0x21
394 freqBandIndicatorNr_t = 0x16
395 supportedSULBandList_t:
396 supportedSULBandList_t_elm
397 freqBandIndicatorNr_t = 0xb
404 measurementTimingConfiguration_t = 01 02 03
406 NRNeighbour_Information_elm
409 pLMN_Identity_t = 1e 3f 27
410 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
411 measurementTimingConfiguration_t = 01 02 03
412 nRNeighbourModeInfo_t:
418 freqBandIndicatorNr_t = 0x16
419 supportedSULBandList_t:
420 supportedSULBandList_t_elm
421 freqBandIndicatorNr_t = 0xb
426 freqBandIndicatorNr_t = 0x16
427 supportedSULBandList_t:
428 supportedSULBandList_t_elm
429 freqBandIndicatorNr_t = 0xb
433 packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
437 key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
438 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}}}}}]",
442 procedureCode_t = 0x24
446 ProtocolIE_Container_elm
449 RespondingNodeType-EndcX2Setup:
451 ProtocolIE_Container_elm
455 pLMN_Identity_t = 04 a5 c1
457 gNB_ID_t = 4f c5 2b ff (32 bits)
458 ProtocolIE_Container_elm
461 ServedNRcellsENDCX2ManagementList:
462 ServedNRcellsENDCX2ManagementList_elm
466 pLMN_Identity_t = ae af a7
467 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
468 fiveGS_TAC_t = 7d 47 73
469 configured_TAC_t = 47 7f
471 BroadcastPLMNs_Item_elm = 7e 7e 7e
478 freqBandIndicatorNr_t = 0x16
479 supportedSULBandList_t:
480 supportedSULBandList_t_elm
481 freqBandIndicatorNr_t = 0xb
490 measurementTimingConfiguration_t = 7e 7e 7e
492 NRNeighbour_Information_elm
495 pLMN_Identity_t = 5a 5f f1
496 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
497 measurementTimingConfiguration_t = 5a 5f f1
498 nRNeighbourModeInfo_t:
504 freqBandIndicatorNr_t = 0x4
505 supportedSULBandList_t:
506 supportedSULBandList_t_elm
507 freqBandIndicatorNr_t = 0x3
513 NRNeighbour_Information_elm
516 pLMN_Identity_t = 5d 5c aa
517 nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
518 measurementTimingConfiguration_t = 5d 5c aa
519 nRNeighbourModeInfo_t:
525 freqBandIndicatorNr_t = 0x3
526 supportedSULBandList_t:
527 supportedSULBandList_t_elm
528 freqBandIndicatorNr_t = 0x1
535 packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
537 {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
541 procedureCode_t = 0x24
545 ProtocolIE_Container_elm
548 RespondingNodeType-EndcX2Setup:
550 ProtocolIE_Container_elm
554 pLMN_Identity_t = 02 f8 29
556 gNB_ID_t = 4a 95 2a aa (32 bits)
558 packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
560 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*/),},
563 converter := NewEndcSetupResponseConverter(logger)
565 for _, tc := range testCases {
566 t.Run(tc.packedPdu, func(t *testing.T) {
570 _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
573 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
576 key, gnb, err := converter.UnpackEndcSetupResponseAndExtract(payload)
579 if tc.failure == nil {
580 t.Errorf("want: success, got: error: %v\n", err)
582 if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
583 t.Errorf("want: %s, got: %s", tc.failure, err)
589 if tc.failure == nil {
590 t.Errorf("want: key=%v, got: empty key", tc.key)
593 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
594 t.Errorf("want: key=%v, got: %v", tc.key, key)
599 if tc.failure == nil {
600 t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
603 nb := &entities.NodebInfo{}
604 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
605 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
606 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
608 space := regexp.MustCompile(`\s+`)
609 s1 := space.ReplaceAllString(gnbStr, " ")
610 s2 := space.ReplaceAllString(tc.gnb," ")
612 if !strings.EqualFold(s1, s2) {
613 t.Errorf("want: [%s], got: [%s]", tc.gnb, gnbStr)