1 /*******************************************************************************
3 * Copyright (c) 2019 AT&T Intellectual Property.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 *******************************************************************************/
25 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
31 Test permutations of x2 setup response to protobuf enb
34 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
35 logger, _ := logger.InitLogger(logger.InfoLevel)
37 var testCases = []struct {
39 key *entities.GlobalNbId
45 saveToRNib: false, //TODO: use MOCK?
46 key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
47 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 > > > > > ]",
51 procedureCode_t = 0x24
55 ProtocolIE_Container_elm
58 RespondingNodeType-EndcX2Setup:
60 ProtocolIE_Container_elm
64 pLMN_Identity_t = 02 f8 29
66 gNB_ID_t = 4a 95 2a 0a (32 bits)
67 ProtocolIE_Container_elm
70 ServedNRcellsENDCX2ManagementList:
71 ServedNRcellsENDCX2ManagementList_elm
75 pLMN_Identity_t = 1e 3f 27
76 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
77 fiveGS_TAC_t = 3d 44 d3
78 configured_TAC_t = 4e 4f
80 BroadcastPLMNs_Item_elm = 3e 4e 5e
87 freqBandIndicatorNr_t = 0x16
88 supportedSULBandList_t:
89 supportedSULBandList_t_elm
90 freqBandIndicatorNr_t = 0xb
99 measurementTimingConfiguration_t = 3e 4e 5e
100 ServedNRcellsENDCX2ManagementList_elm
104 pLMN_Identity_t = 1e 3f 27
105 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
106 fiveGS_TAC_t = 3d 44 d3
107 configured_TAC_t = 4e 4f
109 BroadcastPLMNs_Item_elm = 3e 4e 5e
116 freqBandIndicatorNr_t = 0x16
117 supportedSULBandList_t:
118 supportedSULBandList_t_elm
119 freqBandIndicatorNr_t = 0xb
128 measurementTimingConfiguration_t = 3e 4e 5e
130 NRNeighbour_Information_elm
133 pLMN_Identity_t = 1e 3f 27
134 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
135 measurementTimingConfiguration_t = 1e 3f 27
136 nRNeighbourModeInfo_t:
142 freqBandIndicatorNr_t = 0x16
143 supportedSULBandList_t:
144 supportedSULBandList_t_elm
145 freqBandIndicatorNr_t = 0xb
153 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"},
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"},
348 key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
349 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 > > > > > ]",
353 procedureCode_t = 0x24
357 ProtocolIE_Container_elm
360 RespondingNodeType-EndcX2Setup:
362 ProtocolIE_Container_elm
366 pLMN_Identity_t = 02 f8 29
368 gNB_ID_t = 4a 95 2a 0a (32 bits)
369 ProtocolIE_Container_elm
372 ServedNRcellsENDCX2ManagementList:
373 ServedNRcellsENDCX2ManagementList_elm
377 pLMN_Identity_t = 1e 3f 27
378 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
380 BroadcastPLMNs_Item_elm = 3e 4e 5e
387 freqBandIndicatorNr_t = 0x2c
388 supportedSULBandList_t:
389 supportedSULBandList_t_elm
390 freqBandIndicatorNr_t = 0x21
395 freqBandIndicatorNr_t = 0x16
396 supportedSULBandList_t:
397 supportedSULBandList_t_elm
398 freqBandIndicatorNr_t = 0xb
405 measurementTimingConfiguration_t = 01 02 03
407 NRNeighbour_Information_elm
410 pLMN_Identity_t = 1e 3f 27
411 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
412 measurementTimingConfiguration_t = 01 02 03
413 nRNeighbourModeInfo_t:
419 freqBandIndicatorNr_t = 0x16
420 supportedSULBandList_t:
421 supportedSULBandList_t_elm
422 freqBandIndicatorNr_t = 0xb
427 freqBandIndicatorNr_t = 0x16
428 supportedSULBandList_t:
429 supportedSULBandList_t_elm
430 freqBandIndicatorNr_t = 0xb
434 packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
439 key: &entities.GlobalNbId{PlmnId:"04a5c1", NbId:"4fc52bff"},
440 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 > > > > > ]",
444 procedureCode_t = 0x24
448 ProtocolIE_Container_elm
451 RespondingNodeType-EndcX2Setup:
453 ProtocolIE_Container_elm
457 pLMN_Identity_t = 04 a5 c1
459 gNB_ID_t = 4f c5 2b ff (32 bits)
460 ProtocolIE_Container_elm
463 ServedNRcellsENDCX2ManagementList:
464 ServedNRcellsENDCX2ManagementList_elm
468 pLMN_Identity_t = ae af a7
469 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
470 fiveGS_TAC_t = 7d 47 73
471 configured_TAC_t = 47 7f
473 BroadcastPLMNs_Item_elm = 7e 7e 7e
480 freqBandIndicatorNr_t = 0x16
481 supportedSULBandList_t:
482 supportedSULBandList_t_elm
483 freqBandIndicatorNr_t = 0xb
492 measurementTimingConfiguration_t = 7e 7e 7e
494 NRNeighbour_Information_elm
497 pLMN_Identity_t = 5a 5f f1
498 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
499 measurementTimingConfiguration_t = 5a 5f f1
500 nRNeighbourModeInfo_t:
506 freqBandIndicatorNr_t = 0x4
507 supportedSULBandList_t:
508 supportedSULBandList_t_elm
509 freqBandIndicatorNr_t = 0x3
515 NRNeighbour_Information_elm
518 pLMN_Identity_t = 5d 5c aa
519 nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
520 measurementTimingConfiguration_t = 5d 5c aa
521 nRNeighbourModeInfo_t:
527 freqBandIndicatorNr_t = 0x3
528 supportedSULBandList_t:
529 supportedSULBandList_t_elm
530 freqBandIndicatorNr_t = 0x1
537 packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
539 { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952aaa"},
543 procedureCode_t = 0x24
547 ProtocolIE_Container_elm
550 RespondingNodeType-EndcX2Setup:
552 ProtocolIE_Container_elm
556 pLMN_Identity_t = 02 f8 29
558 gNB_ID_t = 4a 95 2a aa (32 bits)
560 packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
562 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*/),},
566 for _, tc := range testCases {
567 t.Run(tc.packedPdu, func(t *testing.T) {
571 _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
574 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
577 key, gnb, err := UnpackEndcX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
580 if tc.failure == nil {
581 t.Errorf("want: success, got: error: %v\n", err)
583 if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
584 t.Errorf("want: %s, got: %s", tc.failure, err)
590 if tc.failure == nil {
591 t.Errorf("want: key=%v, got: empty key", tc.key)
594 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0{
595 t.Errorf("want: key=%v, got: %v", tc.key, key)
600 if tc.failure == nil {
601 t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
604 nb := &entities.NodebInfo{}
605 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
606 nb.Configuration = &entities.NodebInfo_Gnb{Gnb:gnb}
607 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
608 if !strings.EqualFold(gnbStr, tc.gnb) {
609 t.Errorf("want: enb=%s, got: %s", tc.gnb, gnbStr)
615 rNibWriter.Init("e2Manager", 1)
618 nbIdentity := &entities.NbIdentity{InventoryName:"RanName", GlobalNbId:key}
619 if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
620 if tc.failure == nil {
621 t.Errorf("rNibWriter failed to save ENB. Error: %v\n", rNibErr.Error())
623 if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
624 t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())