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