Fix release notes
[ric-plt/e2mgr.git] / E2Manager / converters / endc_x2setupResponseToProtobuf_test.go
1 /*
2  *   Copyright (c) 2019 AT&T Intellectual Property.
3  *
4  *   Licensed under the Apache License, Version 2.0 (the "License");
5  *   you may not use this file except in compliance with the License.
6  *   You may obtain a copy of the License at
7  *
8  *       http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *   Unless required by applicable law or agreed to in writing, software
11  *   distributed under the License is distributed on an "AS IS" BASIS,
12  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *   See the License for the specific language governing permissions and
14  *   limitations under the License.
15  */
16
17 /*
18  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19  * platform project (RICP).
20  */
21
22 package converters
23
24 import (
25         "e2mgr/e2pdus"
26         "e2mgr/logger"
27         "fmt"
28         "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
29         "strings"
30         "testing"
31 )
32
33 /*
34 Test permutations of x2 setup response to protobuf enb
35  */
36
37 func TestUnpackEndcX2SetupResponseAndExtract(t *testing.T) {
38         logger, _ := logger.InitLogger(logger.InfoLevel)
39
40         var testCases = []struct {
41                 key       *entities.GlobalNbId
42                 gnb       string
43                 packedPdu string
44                 failure   error
45         }{
46                 {
47                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
48                         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 > > > > > ]",
49                         /*
50                 E2AP-PDU:
51                          successfulOutcome_t
52                           procedureCode_t = 0x24
53                           criticality_t = 0
54                           ENDCX2SetupResponse
55                            protocolIEs_t:
56                             ProtocolIE_Container_elm
57                              id_t = 0xf6
58                              criticality_t = 0
59                              RespondingNodeType-EndcX2Setup:
60                               respond_en_gNB_t:
61                                ProtocolIE_Container_elm
62                                 id_t = 0xfc
63                                 criticality_t = 0
64                                 GlobalGNB-ID
65                                  pLMN_Identity_t = 02 f8 29
66                                  gNB_ID_t:
67                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
68                                ProtocolIE_Container_elm
69                                 id_t = 0xfd
70                                 criticality_t = 0
71                                 ServedNRcellsENDCX2ManagementList:
72                                  ServedNRcellsENDCX2ManagementList_elm
73                                   servedNRCellInfo_t
74                                    nrpCI_t = 0x5
75                                    nrCellID_t
76                                     pLMN_Identity_t = 1e 3f 27
77                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
78                                    fiveGS_TAC_t = 3d 44 d3
79                                    configured_TAC_t = 4e 4f
80                                    broadcastPLMNs_t:
81                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
82                                    nrModeInfo_t:
83                                     tdd_t
84                                      nRFreqInfo_t
85                                       nRARFCN_t = 0x1
86                                       freqBandListNr_t:
87                                        freqBandListNr_t_elm
88                                         freqBandIndicatorNr_t = 0x16
89                                         supportedSULBandList_t:
90                                          supportedSULBandList_t_elm
91                                           freqBandIndicatorNr_t = 0xb
92                                       sULInformation_t
93                                        sUL_ARFCN_t = 0x2
94                                        sUL_TxBW_t
95                                         nRSCS_t = 0x2
96                                         nRNRB_t = 0xf
97                                      nR_TxBW_t
98                                       nRSCS_t = 0x1
99                                       nRNRB_t = 0x12
100                                    measurementTimingConfiguration_t = 3e 4e 5e
101                                  ServedNRcellsENDCX2ManagementList_elm
102                                   servedNRCellInfo_t
103                                    nrpCI_t = 0x5
104                                    nrCellID_t
105                                     pLMN_Identity_t = 1e 3f 27
106                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
107                                    fiveGS_TAC_t = 3d 44 d3
108                                    configured_TAC_t = 4e 4f
109                                    broadcastPLMNs_t:
110                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
111                                    nrModeInfo_t:
112                                     tdd_t
113                                      nRFreqInfo_t
114                                       nRARFCN_t = 0x1
115                                       freqBandListNr_t:
116                                        freqBandListNr_t_elm
117                                         freqBandIndicatorNr_t = 0x16
118                                         supportedSULBandList_t:
119                                          supportedSULBandList_t_elm
120                                           freqBandIndicatorNr_t = 0xb
121                                       sULInformation_t
122                                        sUL_ARFCN_t = 0x2
123                                        sUL_TxBW_t
124                                         nRSCS_t = 0x3
125                                         nRNRB_t = 0x10
126                                      nR_TxBW_t
127                                       nRSCS_t = 0
128                                       nRNRB_t = 0x11
129                                    measurementTimingConfiguration_t = 3e 4e 5e
130                                   nRNeighbourInfo_t:
131                                    NRNeighbour_Information_elm
132                                     nrpCI_t = 0x2c
133                                     nrCellID_t
134                                      pLMN_Identity_t = 1e 3f 27
135                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
136                                     measurementTimingConfiguration_t = 1e 3f 27
137                                     nRNeighbourModeInfo_t:
138                                      tdd_t
139                                       nRFreqInfo_t
140                                        nRARFCN_t = 0x1
141                                        freqBandListNr_t:
142                                         freqBandListNr_t_elm
143                                          freqBandIndicatorNr_t = 0x16
144                                          supportedSULBandList_t:
145                                           supportedSULBandList_t_elm
146                                            freqBandIndicatorNr_t = 0xb
147                                        sULInformation_t
148                                         sUL_ARFCN_t = 0x2
149                                         sUL_TxBW_t
150                                          nRSCS_t = 0
151                                          nRNRB_t = 0
152
153                         */
154                         packedPdu: "202400808e00000100f600808640000200fc00090002f829504a952a0a00fd007200010c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a000211e148033e4e5e4c0005001e3f271f2e3d4ff03d44d34e4f003e4e5e4400010000150400000a00021a0044033e4e5e000000002c001e3f271f2e3d4ff0031e3f274400010000150400000a00020000"},
155                 {
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                         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                         key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
347                         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 > > > > > ]",
348                         /*
349                         E2AP-PDU:
350                          successfulOutcome_t
351                           procedureCode_t = 0x24
352                           criticality_t = 0
353                           ENDCX2SetupResponse
354                            protocolIEs_t:
355                             ProtocolIE_Container_elm
356                              id_t = 0xf6
357                              criticality_t = 0
358                              RespondingNodeType-EndcX2Setup:
359                               respond_en_gNB_t:
360                                ProtocolIE_Container_elm
361                                 id_t = 0xfc
362                                 criticality_t = 0
363                                 GlobalGNB-ID
364                                  pLMN_Identity_t = 02 f8 29
365                                  gNB_ID_t:
366                                   gNB_ID_t = 4a 95 2a 0a (32 bits)
367                                ProtocolIE_Container_elm
368                                 id_t = 0xfd
369                                 criticality_t = 0
370                                 ServedNRcellsENDCX2ManagementList:
371                                  ServedNRcellsENDCX2ManagementList_elm
372                                   servedNRCellInfo_t
373                                    nrpCI_t = 0x5
374                                    nrCellID_t
375                                     pLMN_Identity_t = 1e 3f 27
376                                     nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
377                                    broadcastPLMNs_t:
378                                     BroadcastPLMNs_Item_elm = 3e 4e 5e
379                                    nrModeInfo_t:
380                                     fdd_t
381                                      ul_NRFreqInfo_t
382                                       nRARFCN_t = 0x5
383                                       freqBandListNr_t:
384                                        freqBandListNr_t_elm
385                                         freqBandIndicatorNr_t = 0x2c
386                                         supportedSULBandList_t:
387                                          supportedSULBandList_t_elm
388                                           freqBandIndicatorNr_t = 0x21
389                                      dl_NRFreqInfo_t
390                                       nRARFCN_t = 0x1
391                                       freqBandListNr_t:
392                                        freqBandListNr_t_elm
393                                         freqBandIndicatorNr_t = 0x16
394                                         supportedSULBandList_t:
395                                          supportedSULBandList_t_elm
396                                           freqBandIndicatorNr_t = 0xb
397                                      ul_NR_TxBW_t
398                                       nRSCS_t = 0x3
399                                       nRNRB_t = 0
400                                      dl_NR_TxBW_t
401                                       nRSCS_t = 0
402                                       nRNRB_t = 0x13
403                                    measurementTimingConfiguration_t = 01 02 03
404                                   nRNeighbourInfo_t:
405                                    NRNeighbour_Information_elm
406                                     nrpCI_t = 0x2c
407                                     nrCellID_t
408                                      pLMN_Identity_t = 1e 3f 27
409                                      nRcellIdentifier_t = 1f 2e 3d 4f f0 (36 bits)
410                                     measurementTimingConfiguration_t = 01 02 03
411                                     nRNeighbourModeInfo_t:
412                                      fdd_t
413                                       ul_NRFreqInfo_t
414                                        nRARFCN_t = 0x5
415                                        freqBandListNr_t:
416                                         freqBandListNr_t_elm
417                                          freqBandIndicatorNr_t = 0x16
418                                          supportedSULBandList_t:
419                                           supportedSULBandList_t_elm
420                                            freqBandIndicatorNr_t = 0xb
421                                       dl_NRFreqInfo_t
422                                        nRARFCN_t = 0x1
423                                        freqBandListNr_t:
424                                         freqBandListNr_t_elm
425                                          freqBandIndicatorNr_t = 0x16
426                                          supportedSULBandList_t:
427                                           supportedSULBandList_t_elm
428                                            freqBandIndicatorNr_t = 0xb
429
430
431                         */
432                         packedPdu: "2024006b00000100f6006440000200fc00090002f829504a952a0a00fd00500000400005001e3f271f2e3d4ff03e4e5e00000500002b0400002000010000150400000a18004c03010203000000002c001e3f271f2e3d4ff0030102030000050000150400000a00010000150400000a"},
433
434
435                 {
436                         key: &entities.GlobalNbId{PlmnId: "04a5c1", NbId: "4fc52bff"},
437                         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 > > > > > ]",
438                         /*
439                         E2AP-PDU:
440                          successfulOutcome_t
441                           procedureCode_t = 0x24
442                           criticality_t = 0
443                           ENDCX2SetupResponse
444                            protocolIEs_t:
445                             ProtocolIE_Container_elm
446                              id_t = 0xf6
447                              criticality_t = 0
448                              RespondingNodeType-EndcX2Setup:
449                               respond_en_gNB_t:
450                                ProtocolIE_Container_elm
451                                 id_t = 0xfc
452                                 criticality_t = 0
453                                 GlobalGNB-ID
454                                  pLMN_Identity_t = 04 a5 c1
455                                  gNB_ID_t:
456                                   gNB_ID_t = 4f c5 2b ff (32 bits)
457                                ProtocolIE_Container_elm
458                                 id_t = 0xfd
459                                 criticality_t = 0
460                                 ServedNRcellsENDCX2ManagementList:
461                                  ServedNRcellsENDCX2ManagementList_elm
462                                   servedNRCellInfo_t
463                                    nrpCI_t = 0x9
464                                    nrCellID_t
465                                     pLMN_Identity_t = ae af a7
466                                     nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
467                                    fiveGS_TAC_t = 7d 47 73
468                                    configured_TAC_t = 47 7f
469                                    broadcastPLMNs_t:
470                                     BroadcastPLMNs_Item_elm = 7e 7e 7e
471                                    nrModeInfo_t:
472                                     tdd_t
473                                      nRFreqInfo_t
474                                       nRARFCN_t = 0x8
475                                       freqBandListNr_t:
476                                        freqBandListNr_t_elm
477                                         freqBandIndicatorNr_t = 0x16
478                                         supportedSULBandList_t:
479                                          supportedSULBandList_t_elm
480                                           freqBandIndicatorNr_t = 0xb
481                                       sULInformation_t
482                                        sUL_ARFCN_t = 0x9
483                                        sUL_TxBW_t
484                                         nRSCS_t = 0
485                                         nRNRB_t = 0x10
486                                      nR_TxBW_t
487                                       nRSCS_t = 0x2
488                                       nRNRB_t = 0x1
489                                    measurementTimingConfiguration_t = 7e 7e 7e
490                                   nRNeighbourInfo_t:
491                                    NRNeighbour_Information_elm
492                                     nrpCI_t = 0x2c
493                                     nrCellID_t
494                                      pLMN_Identity_t = 5a 5f f1
495                                      nRcellIdentifier_t = 2a 3e 3b 4c d0 (36 bits)
496                                     measurementTimingConfiguration_t = 5a 5f f1
497                                     nRNeighbourModeInfo_t:
498                                      tdd_t
499                                       nRFreqInfo_t
500                                        nRARFCN_t = 0x5
501                                        freqBandListNr_t:
502                                         freqBandListNr_t_elm
503                                          freqBandIndicatorNr_t = 0x4
504                                          supportedSULBandList_t:
505                                           supportedSULBandList_t_elm
506                                            freqBandIndicatorNr_t = 0x3
507                                        sULInformation_t
508                                         sUL_ARFCN_t = 0x6
509                                         sUL_TxBW_t
510                                          nRSCS_t = 0x1
511                                          nRNRB_t = 0x1
512                                    NRNeighbour_Information_elm
513                                     nrpCI_t = 0x9
514                                     nrCellID_t
515                                      pLMN_Identity_t = 5d 5c aa
516                                      nRcellIdentifier_t = af 3e 35 4a c0 (36 bits)
517                                     measurementTimingConfiguration_t = 5d 5c aa
518                                     nRNeighbourModeInfo_t:
519                                      tdd_t
520                                       nRFreqInfo_t
521                                        nRARFCN_t = 0x7
522                                        freqBandListNr_t:
523                                         freqBandListNr_t_elm
524                                          freqBandIndicatorNr_t = 0x3
525                                          supportedSULBandList_t:
526                                           supportedSULBandList_t_elm
527                                            freqBandIndicatorNr_t = 0x1
528                                        sULInformation_t
529                                         sUL_ARFCN_t = 0x8
530                                         sUL_TxBW_t
531                                          nRSCS_t = 0x3
532                                          nRNRB_t = 0x3
533                         */
534                         packedPdu: "202400808200000100f6007b40000200fc00090004a5c1504fc52bff00fd006700004c000900aeafa72a3e3b4cd07d4773477f007e7e7e4400080000150400000a0009020204037e7e7e000100002c005a5ff12a3e3b4cd0035a5ff144000500000304000002000608200009005d5caaaf3e354ac0035d5caa4400070000020400000000081860"},
535
536                 {key: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952aaa"},
537                         /*
538                         E2AP-PDU:
539                          successfulOutcome_t
540                           procedureCode_t = 0x24
541                           criticality_t = 0
542                           ENDCX2SetupResponse
543                            protocolIEs_t:
544                             ProtocolIE_Container_elm
545                              id_t = 0xf6
546                              criticality_t = 0
547                              RespondingNodeType-EndcX2Setup:
548                               respond_en_gNB_t:
549                                ProtocolIE_Container_elm
550                                 id_t = 0xfc
551                                 criticality_t = 0
552                                 GlobalGNB-ID
553                                  pLMN_Identity_t = 02 f8 29
554                                  gNB_ID_t:
555                                   gNB_ID_t = 4a 95 2a aa (32 bits)
556                         */
557                         packedPdu: "2024001700000100f6001040000100fc00090002f829504a952aaa",
558
559                         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*/),},
560         }
561
562         for _, tc := range testCases {
563                 t.Run(tc.packedPdu, func(t *testing.T) {
564
565                         var payload []byte
566
567                         _, err := fmt.Sscanf(tc.packedPdu, "%x", &payload)
568
569                         if err != nil {
570                                 t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
571                         }
572
573                         key, gnb, err := UnpackEndcX2SetupResponseAndExtract(logger, e2pdus.MaxAsn1CodecAllocationBufferSize, len(payload), payload, e2pdus.MaxAsn1CodecMessageBufferSize)
574
575                         if err != nil {
576                                 if tc.failure == nil {
577                                         t.Errorf("want: success, got: error: %v\n", err)
578                                 } else {
579                                         if strings.Compare(err.Error(), tc.failure.Error()) != 0 {
580                                                 t.Errorf("want: %s, got: %s", tc.failure, err)
581                                         }
582                                 }
583                         }
584
585                         if key == nil {
586                                 if tc.failure == nil {
587                                         t.Errorf("want: key=%v, got: empty key", tc.key)
588                                 }
589                         } else {
590                                 if strings.Compare(key.PlmnId, tc.key.PlmnId) != 0 || strings.Compare(key.NbId, tc.key.NbId) != 0 {
591                                         t.Errorf("want: key=%v, got: %v", tc.key, key)
592                                 }
593                         }
594
595                         if gnb == nil {
596                                 if tc.failure == nil {
597                                         t.Errorf("want: enb=%s, got: empty enb", tc.gnb)
598                                 }
599                         } else {
600                                 nb := &entities.NodebInfo{}
601                                 nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
602                                 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: gnb}
603                                 gnbStr := fmt.Sprintf("%s %s", nb.ConnectionStatus, gnb.ServedNrCells)
604                                 if !strings.EqualFold(gnbStr, tc.gnb) {
605                                         t.Errorf("want: enb=%s, got: %s", tc.gnb, gnbStr)
606                                 }
607
608                         }
609                 })
610         }
611 }