Upgrade RMR version to 4.0.2 & remove load information from supported messages
[ric-plt/e2mgr.git] / E2Manager / converters / enb_load_information_extractor_test.go
1 //
2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
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 //  This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 //  platform project (RICP).
19
20
21 package converters
22
23 //import (
24 //      "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
25 //)
26 //
27 ///*
28 //Test permutations of eNB Load Information to protobuf
29 //*/
30 //
31 //type LoadInformationTestCaseName string
32 //
33 //const LoadTimestamp = 1257894000000000000
34 //
35 //const (
36 //      SingleCellWithCellIdOnly     LoadInformationTestCaseName = "SINGLE CELL WITH CELL ID ONLY"   //base
37 //      SingleCellPartiallyPopulated LoadInformationTestCaseName = "SINGLE CELL PARTIALLY POPULATED" //8
38 //      TwoCellsFullInfo             LoadInformationTestCaseName = "TWO CELLS FULLY POPULATED"       //13
39 //)
40 //
41 //type LoadInformationTestCase struct {
42 //      loadInformationTestCaseName LoadInformationTestCaseName
43 //      packedUperPdu               string
44 //      packedAperPdu               string
45 //      expectedLoadInformation     *entities.RanLoadInformation
46 //}
47 //
48 //var testCases = []LoadInformationTestCase{
49 //      {
50 //              loadInformationTestCaseName: SingleCellWithCellIdOnly,
51 //              packedAperPdu:               "000240140000010006400d00000740080002f8290007ab50",
52 //              packedUperPdu:               "004898000400190d0000074200017c148003d5a80000",
53 //              expectedLoadInformation:     GenerateSingleCellWithCellIdOnlyRanLoadInformation(),
54 //      },
55 //      {
56 //              loadInformationTestCaseName: SingleCellPartiallyPopulated,
57 //              packedAperPdu:               "", //TODO: populate and USE
58 //              packedUperPdu:               "004b380004001961000007571e017c148003d5a8205000017c180003d5a875555003331420008007a85801f07c1f07c41f07c1e07801f2020000c680b0003220664102800d8908020000be0c4001ead4016e007ab50100002f8320067ab5005b8c1ead5070190c000000",
59 //              expectedLoadInformation:     GenerateSingleCellPartiallyPopulatedLoadInformation(),
60 //      },
61 //      {
62 //              loadInformationTestCaseName: TwoCellsFullInfo,
63 //              packedAperPdu:               "", //TODO: populate and USE
64 //              packedUperPdu:               "004c07080004001980da0100075bde017c148003d5a8205000017c180003d5a875555403331420000012883a0003547400cd20002801ea16007c1f07c1f107c1f0781e007c80800031a02c000c88199040a00352083669190000d8908020000be0c4001ead4016e007ab50100002f8320067ab5005b8c1ead5070190c00001d637805f220000f56a081400005f020000f56a1d555400ccc508002801ea16007c1f07c1f107c1f0781e007c80800031a02c000c88199040a00352083669190000d8908020000be044001ead4016e007ab50100002f8120067ab5005b8c1ead5070190c00000",
65 //              expectedLoadInformation:     GenerateTwoCellsFullyPopulatedRanLoadInformation(),
66 //      },
67 //}
68
69 //func TestExtractAndBuildRanLoadInformation(t *testing.T) {
70 //      logger, _ := logger.InitLogger(logger.InfoLevel)
71 //
72 //      for _, tc := range testCases {
73 //              t.Run(string(tc.loadInformationTestCaseName), func(t *testing.T) {
74 //
75 //                      var payload []byte
76 //                      _, err := fmt.Sscanf(tc.packedUperPdu, "%x", &payload)
77 //
78 //                      if err != nil {
79 //                              t.Errorf("convert inputPayloadAsStr to payloadAsByte. Error: %v\n", err)
80 //                      }
81 //
82 //                      pdu, err := unpackX2apPduUPer(logger, MaxAsn1CodecAllocationBufferSize, len(payload), payload, MaxAsn1CodecMessageBufferSize)
83 //
84 //                      actualRanLoadInformation := &entities.RanLoadInformation{LoadTimestamp: LoadTimestamp}
85 //
86 //                      err = ExtractAndBuildRanLoadInformation(pdu, actualRanLoadInformation)
87 //
88 //                      if err != nil {
89 //                              t.Errorf("want: success, got: error: %v\n", err)
90 //                      }
91 //
92 //                      if !assert.Equal(t, tc.expectedLoadInformation, actualRanLoadInformation) {
93 //                              t.Errorf("want: %v, got: %v", tc.expectedLoadInformation, actualRanLoadInformation)
94 //                      }
95 //              })
96 //      }
97 //}
98
99 /*func GenerateSingleCellWithCellIdOnlyRanLoadInformation() *entities.RanLoadInformation {
100         return &entities.RanLoadInformation{
101                 LoadTimestamp: LoadTimestamp,
102                 CellLoadInfos: []*entities.CellLoadInformation{
103                         {CellId: "02f829:0007ab50"},
104                 },
105         }
106 }
107
108 func GenerateSingleCellPartiallyPopulatedLoadInformation() *entities.RanLoadInformation {
109
110         ulInterferenceOverloadIndications := []entities.UlInterferenceOverloadIndication{
111                 entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE,
112                 entities.UlInterferenceOverloadIndication_MEDIUM_INTERFERENCE,
113                 entities.UlInterferenceOverloadIndication_LOW_INTERFERENCE,
114         }
115
116         rntp := entities.RelativeNarrowbandTxPower{
117                 RntpPerPrb:                       "cc",
118                 RntpThreshold:                    entities.RntpThreshold_NEG_6,
119                 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
120                 PB:                               2,
121                 PdcchInterferenceImpact:          1,
122         }
123
124         absInformation := entities.AbsInformation{
125                 Mode:                             entities.AbsInformationMode_ABS_INFO_FDD,
126                 AbsPatternInfo:                   "07c1f07c1f",
127                 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
128                 MeasurementSubset:                "83e0f83c0f",
129         }
130
131         extendedUlInterferenceOverloadInfo := entities.ExtendedUlInterferenceOverloadInfo{
132                 AssociatedSubframes:                       "c8",
133                 ExtendedUlInterferenceOverloadIndications: ulInterferenceOverloadIndications,
134         }
135
136         compInformationStartTime := entities.StartTime{
137                 StartSfn:            50,
138                 StartSubframeNumber: 3,
139         }
140
141         return &entities.RanLoadInformation{
142                 LoadTimestamp: LoadTimestamp,
143                 CellLoadInfos: []*entities.CellLoadInformation{
144                         {
145                                 CellId:                             "02f829:0007ab50",
146                                 UlInterferenceOverloadIndications:  ulInterferenceOverloadIndications,
147                                 UlHighInterferenceInfos:            []*entities.UlHighInterferenceInformation{{TargetCellId: "02f830:0007ab50", UlHighInterferenceIndication: "aaaa"}},
148                                 RelativeNarrowbandTxPower:          &rntp,
149                                 AbsInformation:                     &absInformation,
150                                 InvokeIndication:                   entities.InvokeIndication_ABS_INFORMATION,
151                                 IntendedUlDlConfiguration:          entities.SubframeAssignment_SA6,
152                                 ExtendedUlInterferenceOverloadInfo: &extendedUlInterferenceOverloadInfo,
153                                 CompInformation: &entities.CompInformation{
154                                         CompInformationItems: []*entities.CompInformationItem{
155                                                 {
156                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f831:0007ab50", CompHypothesis: "e007ab50"}},
157                                                         BenefitMetric:      -99,
158                                                 },
159                                                 {
160                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f832:0067ab50", CompHypothesis: "e307ab50"}},
161                                                         BenefitMetric:      30,
162                                                 },
163                                         },
164                                         CompInformationStartTime: &compInformationStartTime,
165                                 },
166                         },
167                 },
168         }
169
170 }
171
172 func GenerateTwoCellsFullyPopulatedRanLoadInformation() *entities.RanLoadInformation {
173
174         ulInterferenceOverloadIndications := []entities.UlInterferenceOverloadIndication{
175                 entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE,
176                 entities.UlInterferenceOverloadIndication_MEDIUM_INTERFERENCE,
177                 entities.UlInterferenceOverloadIndication_LOW_INTERFERENCE,
178         }
179
180         rntp := entities.RelativeNarrowbandTxPower{
181                 RntpPerPrb:                       "cc",
182                 RntpThreshold:                    entities.RntpThreshold_NEG_6,
183                 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
184                 PB:                               2,
185                 PdcchInterferenceImpact:          1,
186         }
187
188         enhancedRntp := entities.EnhancedRntp{
189                 EnhancedRntpBitmap:     "aa38",
190                 RntpHighPowerThreshold: entities.RntpThreshold_NEG_4,
191                 EnhancedRntpStartTime:  &entities.StartTime{StartSfn: 51, StartSubframeNumber: 9},
192         }
193
194         rntpWithEnhanced := rntp
195         rntpWithEnhanced.EnhancedRntp = &enhancedRntp
196
197         absInformation := entities.AbsInformation{
198                 Mode:                             entities.AbsInformationMode_ABS_INFO_FDD,
199                 AbsPatternInfo:                   "07c1f07c1f",
200                 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
201                 MeasurementSubset:                "83e0f83c0f",
202         }
203
204         extendedUlInterferenceOverloadInfo := entities.ExtendedUlInterferenceOverloadInfo{
205                 AssociatedSubframes:                       "c8",
206                 ExtendedUlInterferenceOverloadIndications: ulInterferenceOverloadIndications,
207         }
208
209         compInformationStartTime := entities.StartTime{
210                 StartSfn:            50,
211                 StartSubframeNumber: 3,
212         }
213
214         dynamicDlTransmissionInformation := entities.DynamicDlTransmissionInformation{
215                 State:             entities.NaicsState_NAICS_ACTIVE,
216                 TransmissionModes: "cd",
217                 PB:                0,
218                 PAList:            []entities.PA{entities.PA_DB_NEG_1_DOT_77, entities.PA_DB_NEG_3},
219         }
220
221         return &entities.RanLoadInformation{
222                 LoadTimestamp: LoadTimestamp,
223                 CellLoadInfos: []*entities.CellLoadInformation{
224                         {
225                                 CellId:                             "02f829:0007ab50",
226                                 UlInterferenceOverloadIndications:  ulInterferenceOverloadIndications,
227                                 UlHighInterferenceInfos:            []*entities.UlHighInterferenceInformation{{TargetCellId: "02f830:0007ab50", UlHighInterferenceIndication: "aaaa"}},
228                                 RelativeNarrowbandTxPower:          &rntpWithEnhanced,
229                                 AbsInformation:                     &absInformation,
230                                 InvokeIndication:                   entities.InvokeIndication_ABS_INFORMATION,
231                                 IntendedUlDlConfiguration:          entities.SubframeAssignment_SA6,
232                                 ExtendedUlInterferenceOverloadInfo: &extendedUlInterferenceOverloadInfo,
233                                 CompInformation: &entities.CompInformation{
234                                         CompInformationItems: []*entities.CompInformationItem{
235                                                 {
236                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f831:0007ab50", CompHypothesis: "e007ab50"}},
237                                                         BenefitMetric:      -99,
238                                                 },
239                                                 {
240                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f832:0067ab50", CompHypothesis: "e307ab50"}},
241                                                         BenefitMetric:      30,
242                                                 },
243                                         },
244                                         CompInformationStartTime: &compInformationStartTime,
245                                 },
246                                 DynamicDlTransmissionInformation: &dynamicDlTransmissionInformation,
247                         },
248                         {
249                                 CellId:                             "02f910:0007ab50",
250                                 UlInterferenceOverloadIndications:  ulInterferenceOverloadIndications,
251                                 UlHighInterferenceInfos:            []*entities.UlHighInterferenceInformation{{TargetCellId: "02f810:0007ab50", UlHighInterferenceIndication: "aaaa"}},
252                                 RelativeNarrowbandTxPower:          &rntp,
253                                 AbsInformation:                     &absInformation,
254                                 InvokeIndication:                   entities.InvokeIndication_ABS_INFORMATION,
255                                 IntendedUlDlConfiguration:          entities.SubframeAssignment_SA6,
256                                 ExtendedUlInterferenceOverloadInfo: &extendedUlInterferenceOverloadInfo,
257                                 CompInformation: &entities.CompInformation{
258                                         CompInformationItems: []*entities.CompInformationItem{
259                                                 {
260                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f811:0007ab50", CompHypothesis: "e007ab50"}},
261                                                         BenefitMetric:      -99,
262                                                 },
263                                                 {
264                                                         CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "02f812:0067ab50", CompHypothesis: "e307ab50"}},
265                                                         BenefitMetric:      30,
266                                                 },
267                                         },
268                                         CompInformationStartTime: &compInformationStartTime,
269                                 },
270                                 DynamicDlTransmissionInformation: &dynamicDlTransmissionInformation,
271                         },
272                 },
273         }
274 }*/