[RICPLT-2157] Restructure handlers and converters.......
[ric-plt/e2mgr.git] / E2Manager / converters / endc_x2setupResponseToProtobuf_test.go
1 /*******************************************************************************
2  *
3  *   Copyright (c) 2019 AT&T Intellectual Property.
4  *
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
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  *******************************************************************************/
18 package converters
19
20 import (
21         "e2mgr/e2pdus"
22         "e2mgr/logger"
23         "e2mgr/rNibWriter"
24         "fmt"
25         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
26         "strings"
27         "testing"
28 )
29
30 /*
31 Test permutations of x2 setup response to protobuf enb
32  */
33
34 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
35         logger, _ := logger.InitLogger(logger.InfoLevel)
36
37         var testCases = []struct {
38                 saveToRNib       bool
39                 key              *entities.GlobalNbId
40                 gnb              string
41                 packedPdu        string
42                 failure          error
43         }{
44                 {
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 > > > > > ]",
48                         /*
49                 E2AP-PDU:
50                          successfulOutcome_t
51                           procedureCode_t = 0x24
52                           criticality_t = 0
53                           ENDCX2SetupResponse
54                            protocolIEs_t:
55                             ProtocolIE_Container_elm
56                              id_t = 0xf6
57                              criticality_t = 0
58                              RespondingNodeType-EndcX2Setup:
59                               respond_en_gNB_t:
60                                ProtocolIE_Container_elm
61                                 id_t = 0xfc
62                                 criticality_t = 0
63                                 GlobalGNB-ID
64                                  pLMN_Identity_t = 02 f8 29
65                                  gNB_ID_t:
66                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
67                                ProtocolIE_Container_elm
68                                 id_t = 0xfd
69                                 criticality_t = 0
70                                 ServedNRcellsENDCX2ManagementList:
71                                  ServedNRcellsENDCX2ManagementList_elm
72                                   servedNRCellInfo_t
73                                    nrpCI_t = 0x5
74                                    nrCellID_t
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
79                                    broadcastPLMNs_t:
80                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
81                                    nrModeInfo_t:
82                                     tdd_t
83                                      nRFreqInfo_t
84                                       nRARFCN_t = 0x1
85                                       freqBandListNr_t:
86                                        freqBandListNr_t_elm
87                                         freqBandIndicatorNr_t = 0x16
88                                         supportedSULBandList_t:
89                                          supportedSULBandList_t_elm
90                                           freqBandIndicatorNr_t = 0xb
91                                       sULInformation_t
92                                        sUL_ARFCN_t = 0x2
93                                        sUL_TxBW_t
94                                         nRSCS_t = 0x2
95                                         nRNRB_t = 0xf
96                                      nR_TxBW_t
97                                       nRSCS_t = 0x1
98                                       nRNRB_t = 0x12
99                                    measurementTimingConfiguration_t = 3e 4e 5e
100                                  ServedNRcellsENDCX2ManagementList_elm
101                                   servedNRCellInfo_t
102                                    nrpCI_t = 0x5
103                                    nrCellID_t
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
108                                    broadcastPLMNs_t:
109                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
110                                    nrModeInfo_t:
111                                     tdd_t
112                                      nRFreqInfo_t
113                                       nRARFCN_t = 0x1
114                                       freqBandListNr_t:
115                                        freqBandListNr_t_elm
116                                         freqBandIndicatorNr_t = 0x16
117                                         supportedSULBandList_t:
118                                          supportedSULBandList_t_elm
119                                           freqBandIndicatorNr_t = 0xb
120                                       sULInformation_t
121                                        sUL_ARFCN_t = 0x2
122                                        sUL_TxBW_t
123                                         nRSCS_t = 0x3
124                                         nRNRB_t = 0x10
125                                      nR_TxBW_t
126                                       nRSCS_t = 0
127                                       nRNRB_t = 0x11
128                                    measurementTimingConfiguration_t = 3e 4e 5e
129                                   nRNeighbourInfo_t:
130                                    NRNeighbour_Information_elm
131                                     nrpCI_t = 0x2c
132                                     nrCellID_t
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:
137                                      tdd_t
138                                       nRFreqInfo_t
139                                        nRARFCN_t = 0x1
140                                        freqBandListNr_t:
141                                         freqBandListNr_t_elm
142                                          freqBandIndicatorNr_t = 0x16
143                                          supportedSULBandList_t:
144                                           supportedSULBandList_t_elm
145                                            freqBandIndicatorNr_t = 0xb
146                                        sULInformation_t
147                                         sUL_ARFCN_t = 0x2
148                                         sUL_TxBW_t
149                                          nRSCS_t = 0
150                                          nRNRB_t = 0
151
152                         */
153                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
154                 {
155                         saveToRNib: false,
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 > > > > > ]",
158                         /*
159                         E2AP-PDU:
160                          successfulOutcome_t
161                           procedureCode_t = 0x24
162                           criticality_t = 0
163                           ENDCX2SetupResponse
164                            protocolIEs_t:
165                             ProtocolIE_Container_elm
166                              id_t = 0xf6
167                              criticality_t = 0
168                              RespondingNodeType-EndcX2Setup:
169                               respond_en_gNB_t:
170                                ProtocolIE_Container_elm
171                                 id_t = 0xfc
172                                 criticality_t = 0
173                                 GlobalGNB-ID
174                                  pLMN_Identity_t = 02 f8 29
175                                  gNB_ID_t:
176                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
177                                ProtocolIE_Container_elm
178                                 id_t = 0xfd
179                                 criticality_t = 0
180                                 ServedNRcellsENDCX2ManagementList:
181                                  ServedNRcellsENDCX2ManagementList_elm
182                                   servedNRCellInfo_t
183                                    nrpCI_t = 0x5
184                                    nrCellID_t
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
189                                    broadcastPLMNs_t:
190                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
191                                    nrModeInfo_t:
192                                     tdd_t
193                                      nRFreqInfo_t
194                                       nRARFCN_t = 0x1
195                                       freqBandListNr_t:
196                                        freqBandListNr_t_elm
197                                         freqBandIndicatorNr_t = 0x16
198                                         supportedSULBandList_t:
199                                          supportedSULBandList_t_elm
200                                           freqBandIndicatorNr_t = 0xb
201                                       sULInformation_t
202                                        sUL_ARFCN_t = 0x2
203                                        sUL_TxBW_t
204                                         nRSCS_t = 0x1
205                                         nRNRB_t = 0xf
206                                      nR_TxBW_t
207                                       nRSCS_t = 0
208                                       nRNRB_t = 0x10
209                                    measurementTimingConfiguration_t = 3e 4e 5e
210                                   nRNeighbourInfo_t:
211                                    NRNeighbour_Information_elm
212                                     nrpCI_t = 0x2c
213                                     nrCellID_t
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:
218                                      tdd_t
219                                       nRFreqInfo_t
220                                        nRARFCN_t = 0x5
221                                        freqBandListNr_t:
222                                         freqBandListNr_t_elm
223                                          freqBandIndicatorNr_t = 0x16
224                                          supportedSULBandList_t:
225                                           supportedSULBandList_t_elm
226                                            freqBandIndicatorNr_t = 0xb
227                                        sULInformation_t
228                                         sUL_ARFCN_t = 0x6
229                                         sUL_TxBW_t
230                                          nRSCS_t = 0x3
231                                          nRNRB_t = 0x1
232
233                         */
234                         packedPdu: "2024006500000100f6005e40000200fc00090002f829504a952a0a00fd004a00004c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000209e040033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400050000150400000a00061820"},
235
236                 {
237                         saveToRNib: false,
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 > > > > > ]",
240                         /*
241                         E2AP-PDU:
242                          successfulOutcome_t
243                           procedureCode_t = 0x24
244                           criticality_t = 0
245                           ENDCX2SetupResponse
246                            protocolIEs_t:
247                             ProtocolIE_Container_elm
248                              id_t = 0xf6
249                              criticality_t = 0
250                              RespondingNodeType-EndcX2Setup:
251                               respond_en_gNB_t:
252                                ProtocolIE_Container_elm
253                                 id_t = 0xfc
254                                 criticality_t = 0
255                                 GlobalGNB-ID
256                                  pLMN_Identity_t = 02 f8 29
257                                  gNB_ID_t:
258                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
259                                ProtocolIE_Container_elm
260                                 id_t = 0xfd
261                                 criticality_t = 0
262                                 ServedNRcellsENDCX2ManagementList:
263                                  ServedNRcellsENDCX2ManagementList_elm
264                                   servedNRCellInfo_t
265                                    nrpCI_t = 0x5
266                                    nrCellID_t
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
271                                    broadcastPLMNs_t:
272                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
273                                    nrModeInfo_t:
274                                     tdd_t
275                                      nRFreqInfo_t
276                                       nRARFCN_t = 0x1
277                                       freqBandListNr_t:
278                                        freqBandListNr_t_elm
279                                         freqBandIndicatorNr_t = 0x16
280                                         supportedSULBandList_t:
281                                          supportedSULBandList_t_elm
282                                           freqBandIndicatorNr_t = 0xb
283                                       sULInformation_t
284                                        sUL_ARFCN_t = 0x2
285                                        sUL_TxBW_t
286                                         nRSCS_t = 0x2
287                                         nRNRB_t = 0xf
288                                      nR_TxBW_t
289                                       nRSCS_t = 0x1
290                                       nRNRB_t = 0x12
291                                    measurementTimingConfiguration_t = 3e 4e 5e
292                                  ServedNRcellsENDCX2ManagementList_elm
293                                   servedNRCellInfo_t
294                                    nrpCI_t = 0x8
295                                    nrCellID_t
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
300                                    broadcastPLMNs_t:
301                                     BroadcastPLMNs_Item_elm = 50 32 1e
302                                    nrModeInfo_t:
303                                     tdd_t
304                                      nRFreqInfo_t
305                                       nRARFCN_t = 0x4
306                                       freqBandListNr_t:
307                                        freqBandListNr_t_elm
308                                         freqBandIndicatorNr_t = 0x7
309                                         supportedSULBandList_t:
310                                          supportedSULBandList_t_elm
311                                           freqBandIndicatorNr_t = 0x3
312                                       sULInformation_t
313                                        sUL_ARFCN_t = 0x8
314                                        sUL_TxBW_t
315                                         nRSCS_t = 0x3
316                                         nRNRB_t = 0x10
317                                      nR_TxBW_t
318                                       nRSCS_t = 0
319                                       nRNRB_t = 0x11
320                                    measurementTimingConfiguration_t = 50 32 1e
321                                   nRNeighbourInfo_t:
322                                    NRNeighbour_Information_elm
323                                     nrpCI_t = 0x2c
324                                     nrCellID_t
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:
329                                      tdd_t
330                                       nRFreqInfo_t
331                                        nRARFCN_t = 0x1
332                                        freqBandListNr_t:
333                                         freqBandListNr_t_elm
334                                          freqBandIndicatorNr_t = 0x16
335                                          supportedSULBandList_t:
336                                           supportedSULBandList_t_elm
337                                            freqBandIndicatorNr_t = 0xb
338                                        sULInformation_t
339                                         sUL_ARFCN_t = 0x2
340                                         sUL_TxBW_t
341                                          nRSCS_t = 0
342                                          nRNRB_t = 0
343                         */
344                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0008002e3f451f2e3d4ff04faa3c1a2f0050321e4400040000060400000200081a00440350321e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
345
346                 {
347                         saveToRNib: false,
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 > > > > > ]",
350                         /*
351                         E2AP-PDU:
352                          successfulOutcome_t
353                           procedureCode_t = 0x24
354                           criticality_t = 0
355                           ENDCX2SetupResponse
356                            protocolIEs_t:
357                             ProtocolIE_Container_elm
358                              id_t = 0xf6
359                              criticality_t = 0
360                              RespondingNodeType-EndcX2Setup:
361                               respond_en_gNB_t:
362                                ProtocolIE_Container_elm
363                                 id_t = 0xfc
364                                 criticality_t = 0
365                                 GlobalGNB-ID
366                                  pLMN_Identity_t = 02 f8 29
367                                  gNB_ID_t:
368                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
369                                ProtocolIE_Container_elm
370                                 id_t = 0xfd
371                                 criticality_t = 0
372                                 ServedNRcellsENDCX2ManagementList:
373                                  ServedNRcellsENDCX2ManagementList_elm
374                                   servedNRCellInfo_t
375                                    nrpCI_t = 0x5
376                                    nrCellID_t
377                                     pLMN_Identity_t = 1e 3f 27
378                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
379                                    broadcastPLMNs_t:
380                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
381                                    nrModeInfo_t:
382                                     fdd_t
383                                      ul_NRFreqInfo_t
384                                       nRARFCN_t = 0x5
385                                       freqBandListNr_t:
386                                        freqBandListNr_t_elm
387                                         freqBandIndicatorNr_t = 0x2c
388                                         supportedSULBandList_t:
389                                          supportedSULBandList_t_elm
390                                           freqBandIndicatorNr_t = 0x21
391                                      dl_NRFreqInfo_t
392                                       nRARFCN_t = 0x1
393                                       freqBandListNr_t:
394                                        freqBandListNr_t_elm
395                                         freqBandIndicatorNr_t = 0x16
396                                         supportedSULBandList_t:
397                                          supportedSULBandList_t_elm
398                                           freqBandIndicatorNr_t = 0xb
399                                      ul_NR_TxBW_t
400                                       nRSCS_t = 0x3
401                                       nRNRB_t = 0
402                                      dl_NR_TxBW_t
403                                       nRSCS_t = 0
404                                       nRNRB_t = 0x13
405                                    measurementTimingConfiguration_t = 01 02 03
406                                   nRNeighbourInfo_t:
407                                    NRNeighbour_Information_elm
408                                     nrpCI_t = 0x2c
409                                     nrCellID_t
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:
414                                      fdd_t
415                                       ul_NRFreqInfo_t
416                                        nRARFCN_t = 0x5
417                                        freqBandListNr_t:
418                                         freqBandListNr_t_elm
419                                          freqBandIndicatorNr_t = 0x16
420                                          supportedSULBandList_t:
421                                           supportedSULBandList_t_elm
422                                            freqBandIndicatorNr_t = 0xb
423                                       dl_NRFreqInfo_t
424                                        nRARFCN_t = 0x1
425                                        freqBandListNr_t:
426                                         freqBandListNr_t_elm
427                                          freqBandIndicatorNr_t = 0x16
428                                          supportedSULBandList_t:
429                                           supportedSULBandList_t_elm
430                                            freqBandIndicatorNr_t = 0xb
431
432
433                         */
434                         packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
435
436
437                 {
438                         saveToRNib: false,
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 > > > > > ]",
441                         /*
442                         E2AP-PDU:
443                          successfulOutcome_t
444                           procedureCode_t = 0x24
445                           criticality_t = 0
446                           ENDCX2SetupResponse
447                            protocolIEs_t:
448                             ProtocolIE_Container_elm
449                              id_t = 0xf6
450                              criticality_t = 0
451                              RespondingNodeType-EndcX2Setup:
452                               respond_en_gNB_t:
453                                ProtocolIE_Container_elm
454                                 id_t = 0xfc
455                                 criticality_t = 0
456                                 GlobalGNB-ID
457                                  pLMN_Identity_t = 04 a5 c1
458                                  gNB_ID_t:
459                                   gNB_ID_t = 4f c5 2b ff (32 bits)
460                                ProtocolIE_Container_elm
461                                 id_t = 0xfd
462                                 criticality_t = 0
463                                 ServedNRcellsENDCX2ManagementList:
464                                  ServedNRcellsENDCX2ManagementList_elm
465                                   servedNRCellInfo_t
466                                    nrpCI_t = 0x9
467                                    nrCellID_t
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
472                                    broadcastPLMNs_t:
473                                     BroadcastPLMNs_Item_elm = 7e 7e 7e
474                                    nrModeInfo_t:
475                                     tdd_t
476                                      nRFreqInfo_t
477                                       nRARFCN_t = 0x8
478                                       freqBandListNr_t:
479                                        freqBandListNr_t_elm
480                                         freqBandIndicatorNr_t = 0x16
481                                         supportedSULBandList_t:
482                                          supportedSULBandList_t_elm
483                                           freqBandIndicatorNr_t = 0xb
484                                       sULInformation_t
485                                        sUL_ARFCN_t = 0x9
486                                        sUL_TxBW_t
487                                         nRSCS_t = 0
488                                         nRNRB_t = 0x10
489                                      nR_TxBW_t
490                                       nRSCS_t = 0x2
491                                       nRNRB_t = 0x1
492                                    measurementTimingConfiguration_t = 7e 7e 7e
493                                   nRNeighbourInfo_t:
494                                    NRNeighbour_Information_elm
495                                     nrpCI_t = 0x2c
496                                     nrCellID_t
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:
501                                      tdd_t
502                                       nRFreqInfo_t
503                                        nRARFCN_t = 0x5
504                                        freqBandListNr_t:
505                                         freqBandListNr_t_elm
506                                          freqBandIndicatorNr_t = 0x4
507                                          supportedSULBandList_t:
508                                           supportedSULBandList_t_elm
509                                            freqBandIndicatorNr_t = 0x3
510                                        sULInformation_t
511                                         sUL_ARFCN_t = 0x6
512                                         sUL_TxBW_t
513                                          nRSCS_t = 0x1
514                                          nRNRB_t = 0x1
515                                    NRNeighbour_Information_elm
516                                     nrpCI_t = 0x9
517                                     nrCellID_t
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:
522                                      tdd_t
523                                       nRFreqInfo_t
524                                        nRARFCN_t = 0x7
525                                        freqBandListNr_t:
526                                         freqBandListNr_t_elm
527                                          freqBandIndicatorNr_t = 0x3
528                                          supportedSULBandList_t:
529                                           supportedSULBandList_t_elm
530                                            freqBandIndicatorNr_t = 0x1
531                                        sULInformation_t
532                                         sUL_ARFCN_t = 0x8
533                                         sUL_TxBW_t
534                                          nRSCS_t = 0x3
535                                          nRNRB_t = 0x3
536                         */
537                         packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
538
539                 { key: &entities.GlobalNbId{PlmnId:"02f829", NbId:"4a952aaa"},
540                         /*
541                         E2AP-PDU:
542                          successfulOutcome_t
543                           procedureCode_t = 0x24
544                           criticality_t = 0
545                           ENDCX2SetupResponse
546                            protocolIEs_t:
547                             ProtocolIE_Container_elm
548                              id_t = 0xf6
549                              criticality_t = 0
550                              RespondingNodeType-EndcX2Setup:
551                               respond_en_gNB_t:
552                                ProtocolIE_Container_elm
553                                 id_t = 0xfc
554                                 criticality_t = 0
555                                 GlobalGNB-ID
556                                  pLMN_Identity_t = 02 f8 29
557                                  gNB_ID_t:
558                                   gNB_ID_t = 4a 95 2a aa (32 bits)
559                         */
560                         packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
561
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*/),},
563         }
564
565     initDb_f := true
566         for _, tc := range testCases {
567                 t.Run(tc.packedPdu, func(t *testing.T) {
568
569                         var payload []byte
570
571                         _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
572
573                         if err != nil {
574                                 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
575                         }
576
577                         key, gnb, err := UnpackEndcX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
578
579                         if err != nil {
580                                 if tc.failure == nil {
581                                         t.Errorf("want: success, got: error: %v\n", err)
582                                 } else {
583                                                 if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
584                                                         t.Errorf("want: %s, got: %s", tc.failure, err)
585                                                 }
586                                 }
587                         }
588
589                         if key == nil {
590                                 if tc.failure == nil {
591                                         t.Errorf("want: key=%v, got: empty key", tc.key)
592                                 }
593                         } else {
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)
596                                 }
597                         }
598
599                         if gnb == nil {
600                                 if tc.failure == nil {
601                                         t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
602                                 }
603                         } else {
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)
610                                 }
611
612                                 // Save to rNib
613                                 if tc.saveToRNib {
614                                         if initDb_f {
615                                                 rNibWriter.Init("e2Manager", 1)
616                                                 initDb_f = false
617                                         }
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())
622                                                 } else {
623                                                         if strings.Compare(rNibErr.Error(), tc.failure.Error()) != 0 {
624                                                                 t.Errorf("want: %s, got: %s", tc.failure, rNibErr.Error())
625                                                         }
626                                                 }
627                                         }
628                                 }
629                         }
630                 })
631         }
632 }
633