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