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 *******************************************************************************/
21 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
30 Test permutations of x2 setup response to protobuf enb
33 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
34 logger, _ := logger.InitLogger(logger.InfoLevel)
36 var testCases = []struct {
38 key *entities.GlobalNbId
44 saveToRNib: false, //TODO: use MOCK?
45 key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
46 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 > > > > > ]",
50 procedureCode_t = 0x24
54 ProtocolIE_Container_elm
57 RespondingNodeType-EndcX2Setup:
59 ProtocolIE_Container_elm
63 pLMN_Identity_t = 02 f8 29
65 gNB_ID_t = 4a 95 2a 0a (32 bits)
66 ProtocolIE_Container_elm
69 ServedNRcellsENDCX2ManagementList:
70 ServedNRcellsENDCX2ManagementList_elm
74 pLMN_Identity_t = 1e 3f 27
75 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
76 fiveGS_TAC_t = 3d 44 d3
77 configured_TAC_t = 4e 4f
79 BroadcastPLMNs_Item_elm = 3e 4e 5e
86 freqBandIndicatorNr_t = 0x16
87 supportedSULBandList_t:
88 supportedSULBandList_t_elm
89 freqBandIndicatorNr_t = 0xb
98 measurementTimingConfiguration_t = 3e 4e 5e
99 ServedNRcellsENDCX2ManagementList_elm
103 pLMN_Identity_t = 1e 3f 27
104 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
105 fiveGS_TAC_t = 3d 44 d3
106 configured_TAC_t = 4e 4f
108 BroadcastPLMNs_Item_elm = 3e 4e 5e
115 freqBandIndicatorNr_t = 0x16
116 supportedSULBandList_t:
117 supportedSULBandList_t_elm
118 freqBandIndicatorNr_t = 0xb
127 measurementTimingConfiguration_t = 3e 4e 5e
129 NRNeighbour_Information_elm
132 pLMN_Identity_t = 1e 3f 27
133 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
134 measurementTimingConfiguration_t = 1e 3f 27
135 nRNeighbourModeInfo_t:
141 freqBandIndicatorNr_t = 0x16
142 supportedSULBandList_t:
143 supportedSULBandList_t_elm
144 freqBandIndicatorNr_t = 0xb
152 packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
155 key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952a0a"},
156 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 > > > > > ]",
160 procedureCode_t = 0x24
164 ProtocolIE_Container_elm
167 RespondingNodeType-EndcX2Setup:
169 ProtocolIE_Container_elm
173 pLMN_Identity_t = 02 f8 29
175 gNB_ID_t = 4a 95 2a 0a (32 bits)
176 ProtocolIE_Container_elm
179 ServedNRcellsENDCX2ManagementList:
180 ServedNRcellsENDCX2ManagementList_elm
184 pLMN_Identity_t = 1e 3f 27
185 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
186 fiveGS_TAC_t = 3d 44 d3
187 configured_TAC_t = 4e 4f
189 BroadcastPLMNs_Item_elm = 3e 4e 5e
196 freqBandIndicatorNr_t = 0x16
197 supportedSULBandList_t:
198 supportedSULBandList_t_elm
199 freqBandIndicatorNr_t = 0xb
208 measurementTimingConfiguration_t = 3e 4e 5e
210 NRNeighbour_Information_elm
213 pLMN_Identity_t = 1e 3f 27
214 nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
215 measurementTimingConfiguration_t = 1e 3f 27
216 nRNeighbourModeInfo_t:
222 freqBandIndicatorNr_t = 0x16
223 supportedSULBandList_t:
224 supportedSULBandList_t_elm
225 freqBandIndicatorNr_t = 0xb
233 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"},
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"},
438 key: &entities.GlobalNbId{PlmnId:"04a5c1", NbId:"4fc52bff"},
439 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 > > > > > ]",
443 procedureCode_t = 0x24
447 ProtocolIE_Container_elm
450 RespondingNodeType-EndcX2Setup:
452 ProtocolIE_Container_elm
456 pLMN_Identity_t = 04 a5 c1
458 gNB_ID_t = 4f c5 2b ff (32 bits)
459 ProtocolIE_Container_elm
462 ServedNRcellsENDCX2ManagementList:
463 ServedNRcellsENDCX2ManagementList_elm
467 pLMN_Identity_t = ae af a7
468 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
469 fiveGS_TAC_t = 7d 47 73
470 configured_TAC_t = 47 7f
472 BroadcastPLMNs_Item_elm = 7e 7e 7e
479 freqBandIndicatorNr_t = 0x16
480 supportedSULBandList_t:
481 supportedSULBandList_t_elm
482 freqBandIndicatorNr_t = 0xb
491 measurementTimingConfiguration_t = 7e 7e 7e
493 NRNeighbour_Information_elm
496 pLMN_Identity_t = 5a 5f f1
497 nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
498 measurementTimingConfiguration_t = 5a 5f f1
499 nRNeighbourModeInfo_t:
505 freqBandIndicatorNr_t = 0x4
506 supportedSULBandList_t:
507 supportedSULBandList_t_elm
508 freqBandIndicatorNr_t = 0x3
514 NRNeighbour_Information_elm
517 pLMN_Identity_t = 5d 5c aa
518 nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
519 measurementTimingConfiguration_t = 5d 5c aa
520 nRNeighbourModeInfo_t:
526 freqBandIndicatorNr_t = 0x3
527 supportedSULBandList_t:
528 supportedSULBandList_t_elm
529 freqBandIndicatorNr_t = 0x1
536 packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
538 { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952aaa"},
542 procedureCode_t = 0x24
546 ProtocolIE_Container_elm
549 RespondingNodeType-EndcX2Setup:
551 ProtocolIE_Container_elm
555 pLMN_Identity_t = 02 f8 29
557 gNB_ID_t = 4a 95 2a aa (32 bits)
559 packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
561 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*/),},
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 := unpackEndcX2SetupResponseAndExtract(logger, MaxAsn1CodecAllocationBufferSize /*allocation buffer*/, len(payload), payload, MaxAsn1CodecMessageBufferSize /*message buffer*/)
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)
607 if !strings.EqualFold(gnbStr, tc.gnb) {
608 t.Errorf("want: enb=%s, got: %s", tc.gnb, gnbStr)
614 rNibWriter.Init("e2Manager", 1)
617 nbIdentity := &entities.NbIdentity{InventoryName:"RanName", GlobalNbId:key}
618 if rNibErr := rNibWriter.GetRNibWriter().SaveNodeb(nbIdentity, nb); rNibErr != nil {
619 if tc.failure == nil {
620 t.Errorf("rNibWriter failed to save ENB. Error: %v\n", rNibErr.Error())
622 if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
623 t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())