2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
24 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
25 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
26 "github.com/golang/protobuf/proto"
27 "github.com/stretchr/testify/assert"
32 func TestInitRNibWriter(t *testing.T) {
34 initSdlInstanceMock(namespace, 1)
35 available, created := writerPool.Stats()
36 assert.Equal(t, available, 0, "number of available objects in the writerPool should be 0")
37 assert.Equal(t, created, 0, "number of created objects in the writerPool should be 0")
42 func TestInitPool(t *testing.T) {
44 sdlInstanceMock := new(mocks.MockSdlInstance)
45 initPool(1, func() interface{} {
46 sdlI := common.ISdlInstance(sdlInstanceMock)
47 return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
49 func(obj interface{}) {
52 assert.NotNil(t, writerPool)
53 assert.NotNil(t, writerPool.New)
54 assert.NotNil(t, writerPool.Destroy)
55 available, created := writerPool.Stats()
56 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
57 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
60 var namespace = "namespace"
62 func initSdlInstanceMock(namespace string, poolSize int) *mocks.MockSdlInstance {
63 sdlInstanceMock := new(mocks.MockSdlInstance)
64 initPool(poolSize, func() interface{} {
65 sdlI := common.ISdlInstance(sdlInstanceMock)
66 return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
68 func(obj interface{}) {
71 return sdlInstanceMock
74 func TestUpdateNodebInfoSuccess(t *testing.T) {
75 inventoryName := "name"
79 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
81 nodebInfo := &entities.NodebInfo{}
82 nodebInfo.RanName = inventoryName
83 nodebInfo.GlobalNbId = &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
84 nodebInfo.NodeType = entities.Node_ENB
85 nodebInfo.ConnectionStatus = 1
87 nodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
88 data, err := proto.Marshal(nodebInfo)
90 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
93 var setExpected []interface{}
95 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
96 nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
97 setExpected = append(setExpected, nodebNameKey, data)
98 setExpected = append(setExpected, nodebIdKey, data)
100 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
102 rNibErr := w.UpdateNodebInfo(nodebInfo)
103 assert.Nil(t, rNibErr)
106 func TestUpdateNodebInfoMissingInventoryNameFailure(t *testing.T) {
107 inventoryName := "name"
111 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
113 nodebInfo := &entities.NodebInfo{}
114 data, err := proto.Marshal(nodebInfo)
116 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
119 var setExpected []interface{}
121 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
122 nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
123 setExpected = append(setExpected, nodebNameKey, data)
124 setExpected = append(setExpected, nodebIdKey, data)
126 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
128 rNibErr := w.UpdateNodebInfo(nodebInfo)
130 assert.NotNil(t, rNibErr)
131 assert.IsType(t, &common.ValidationError{}, rNibErr)
134 func TestUpdateNodebInfoMissingGlobalNbId(t *testing.T) {
135 inventoryName := "name"
137 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
139 nodebInfo := &entities.NodebInfo{}
140 nodebInfo.RanName = inventoryName
141 data, err := proto.Marshal(nodebInfo)
143 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
146 var setExpected []interface{}
148 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
149 setExpected = append(setExpected, nodebNameKey, data)
150 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
152 rNibErr := w.UpdateNodebInfo(nodebInfo)
154 assert.Nil(t, rNibErr)
157 func TestSaveEnb(t *testing.T) {
159 ranName := "RAN:" + name
161 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
163 nb := entities.NodebInfo{}
164 nb.NodeType = entities.Node_ENB
165 nb.ConnectionStatus = 1
168 enb := entities.Enb{}
169 cell := &entities.ServedCellInfo{CellId: "aaff", Pci: 3}
170 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: cell}}
171 enb.ServedCells = []*entities.ServedCellInfo{cell}
172 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
173 data, err := proto.Marshal(&nb)
175 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
179 cellData, err := proto.Marshal(&cellEntity)
181 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal Cell entity. Error: %v", err)
183 var setExpected []interface{}
184 setExpected = append(setExpected, ranName, data)
185 setExpected = append(setExpected, "ENB:02f829:4a952a0a", data)
186 setExpected = append(setExpected, fmt.Sprintf("CELL:%s", cell.GetCellId()), cellData)
187 setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetPci()), cellData)
189 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
191 nbIdData, err := proto.Marshal(&entities.NbIdentity{InventoryName: name})
193 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal nbIdentity entity. Error: %v", err)
195 sdlInstanceMock.On("RemoveMember", entities.Node_UNKNOWN.String(), []interface{}{nbIdData}).Return(e)
197 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
198 nbIdData, err = proto.Marshal(nbIdentity)
200 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB Identity entity. Error: %v", err)
202 sdlInstanceMock.On("AddMember", "ENB", []interface{}{nbIdData}).Return(e)
204 rNibErr := w.SaveNodeb(nbIdentity, &nb)
205 assert.Nil(t, rNibErr)
208 func TestSaveEnbCellIdValidationFailure(t *testing.T) {
211 initSdlInstanceMock(namespace, 1)
213 nb := entities.NodebInfo{}
214 nb.NodeType = entities.Node_ENB
215 nb.ConnectionStatus = 1
218 enb := entities.Enb{}
219 cell := &entities.ServedCellInfo{Pci: 3}
220 enb.ServedCells = []*entities.ServedCellInfo{cell}
221 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
223 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
224 rNibErr := w.SaveNodeb(nbIdentity, &nb)
225 assert.NotNil(t, rNibErr)
226 assert.IsType(t, &common.ValidationError{}, rNibErr)
227 assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
230 func TestSaveEnbInventoryNameValidationFailure(t *testing.T) {
232 initSdlInstanceMock(namespace, 1)
234 nb := entities.NodebInfo{}
235 nb.NodeType = entities.Node_ENB
236 nb.ConnectionStatus = 1
239 enb := entities.Enb{}
240 cell := &entities.ServedCellInfo{CellId: "aaa", Pci: 3}
241 enb.ServedCells = []*entities.ServedCellInfo{cell}
242 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
244 nbIdentity := &entities.NbIdentity{InventoryName: "", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
245 rNibErr := w.SaveNodeb(nbIdentity, &nb)
246 assert.NotNil(t, rNibErr)
247 assert.IsType(t, &common.ValidationError{}, rNibErr)
248 assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
251 func TestSaveEnbOnClosedPool(t *testing.T) {
254 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
256 nb := entities.NodebInfo{}
257 nb.NodeType = entities.Node_ENB
258 nb.ConnectionStatus = 1
261 enb := entities.Enb{}
262 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
263 data, err := proto.Marshal(&nb)
265 t.Errorf("#rNibWriter_test.TestSaveEnbOnClosedPool - Failed to marshal NodeB entity. Error: %v", err)
267 setExpected := []interface{}{name, data}
269 sdlInstanceMock.On("Set", setExpected).Return(e)
271 nbIdentity := &entities.NbIdentity{}
272 assert.Panics(t, func() { w.SaveNodeb(nbIdentity, &nb) })
275 func TestSaveGnbCellIdValidationFailure(t *testing.T) {
278 initSdlInstanceMock(namespace, 1)
280 nb := entities.NodebInfo{}
281 nb.NodeType = entities.Node_GNB
282 nb.ConnectionStatus = 1
285 gnb := entities.Gnb{}
286 cellInfo := &entities.ServedNRCellInformation{NrPci: 2}
287 cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
288 gnb.ServedNrCells = []*entities.ServedNRCell{cell}
289 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
291 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
292 rNibErr := w.SaveNodeb(nbIdentity, &nb)
293 assert.NotNil(t, rNibErr)
294 assert.IsType(t, &common.ValidationError{}, rNibErr)
295 assert.Equal(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
298 func TestSaveGnb(t *testing.T) {
300 ranName := "RAN:" + name
302 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
304 nb := entities.NodebInfo{}
305 nb.NodeType = entities.Node_GNB
306 nb.ConnectionStatus = 1
309 gnb := entities.Gnb{}
310 cellInfo := &entities.ServedNRCellInformation{NrPci: 2, CellId: "ccdd"}
311 cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
312 cellEntity := entities.Cell{Type: entities.Cell_NR_CELL, Cell: &entities.Cell_ServedNrCell{ServedNrCell: cell}}
313 gnb.ServedNrCells = []*entities.ServedNRCell{cell}
314 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
315 data, err := proto.Marshal(&nb)
317 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB entity. Error: %v", err)
321 cellData, err := proto.Marshal(&cellEntity)
323 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal Cell entity. Error: %v", err)
325 var setExpected []interface{}
326 setExpected = append(setExpected, ranName, data)
327 setExpected = append(setExpected, "GNB:02f829:4a952a0a", data)
328 setExpected = append(setExpected, fmt.Sprintf("NRCELL:%s", cell.GetServedNrCellInformation().GetCellId()), cellData)
329 setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetServedNrCellInformation().GetNrPci()), cellData)
331 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
332 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
333 nbIdData, err := proto.Marshal(nbIdentity)
335 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB Identity entity. Error: %v", err)
337 sdlInstanceMock.On("AddMember", "GNB", []interface{}{nbIdData}).Return(e)
339 nbIdData, err = proto.Marshal(&entities.NbIdentity{InventoryName: name})
341 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal nbIdentity entity. Error: %v", err)
343 sdlInstanceMock.On("RemoveMember", entities.Node_UNKNOWN.String(), []interface{}{nbIdData}).Return(e)
345 rNibErr := w.SaveNodeb(nbIdentity, &nb)
346 assert.Nil(t, rNibErr)
349 func TestSaveRanLoadInformationSuccess(t *testing.T) {
350 inventoryName := "name"
351 loadKey, validationErr := common.ValidateAndBuildRanLoadInformationKey(inventoryName)
353 if validationErr != nil {
354 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
358 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
361 ranLoadInformation := generateRanLoadInformation()
362 data, err := proto.Marshal(ranLoadInformation)
365 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
369 var setExpected []interface{}
370 setExpected = append(setExpected, loadKey, data)
371 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
373 rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
374 assert.Nil(t, rNibErr)
377 func TestSaveRanLoadInformationMarshalNilFailure(t *testing.T) {
378 inventoryName := "name2"
380 initSdlInstanceMock(namespace, 1)
383 expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
384 err := w.SaveRanLoadInformation(inventoryName, nil)
385 assert.Equal(t, expectedErr, err)
388 func TestSaveRanLoadInformationEmptyInventoryNameFailure(t *testing.T) {
391 initSdlInstanceMock(namespace, 1)
394 err := w.SaveRanLoadInformation(inventoryName, nil)
395 assert.NotNil(t, err)
396 assert.IsType(t, &common.ValidationError{}, err)
399 func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
400 inventoryName := "name2"
402 loadKey, validationErr := common.ValidateAndBuildRanLoadInformationKey(inventoryName)
404 if validationErr != nil {
405 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
409 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
412 ranLoadInformation := generateRanLoadInformation()
413 data, err := proto.Marshal(ranLoadInformation)
416 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
419 expectedErr := errors.New("expected error")
420 var setExpected []interface{}
421 setExpected = append(setExpected, loadKey, data)
422 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
424 rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
425 assert.NotNil(t, rNibErr)
426 assert.IsType(t, &common.InternalError{}, rNibErr)
429 func generateCellLoadInformation() *entities.CellLoadInformation {
430 cellLoadInformation := entities.CellLoadInformation{}
432 cellLoadInformation.CellId = "123"
434 ulInterferenceOverloadIndication := entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE
435 cellLoadInformation.UlInterferenceOverloadIndications = []entities.UlInterferenceOverloadIndication{ulInterferenceOverloadIndication}
437 ulHighInterferenceInformation := entities.UlHighInterferenceInformation{
439 UlHighInterferenceIndication: "xxx",
442 cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation}
444 cellLoadInformation.RelativeNarrowbandTxPower = &entities.RelativeNarrowbandTxPower{
446 RntpThreshold: entities.RntpThreshold_NEG_4,
447 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
449 PdcchInterferenceImpact: 2,
450 EnhancedRntp: &entities.EnhancedRntp{
451 EnhancedRntpBitmap: "xxx",
452 RntpHighPowerThreshold: entities.RntpThreshold_NEG_2,
453 EnhancedRntpStartTime: &entities.StartTime{StartSfn: 500, StartSubframeNumber: 5},
457 cellLoadInformation.AbsInformation = &entities.AbsInformation{
458 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
459 AbsPatternInfo: "xxx",
460 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
461 MeasurementSubset: "xxx",
464 cellLoadInformation.InvokeIndication = entities.InvokeIndication_ABS_INFORMATION
466 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = &entities.ExtendedUlInterferenceOverloadInfo{
467 AssociatedSubframes: "xxx",
468 ExtendedUlInterferenceOverloadIndications: cellLoadInformation.UlInterferenceOverloadIndications,
471 compInformationItem := &entities.CompInformationItem{
472 CompHypothesisSets: []*entities.CompHypothesisSet{&entities.CompHypothesisSet{CellId: "789", CompHypothesis: "xxx"}},
476 cellLoadInformation.CompInformation = &entities.CompInformation{
477 CompInformationItems: []*entities.CompInformationItem{compInformationItem},
478 CompInformationStartTime: &entities.StartTime{StartSfn: 123, StartSubframeNumber: 456},
481 cellLoadInformation.DynamicDlTransmissionInformation = &entities.DynamicDlTransmissionInformation{
482 State: entities.NaicsState_NAICS_ACTIVE,
483 TransmissionModes: "xxx",
485 PAList: []entities.PA{entities.PA_DB_NEG_3},
488 return &cellLoadInformation
491 func generateRanLoadInformation() *entities.RanLoadInformation {
492 ranLoadInformation := entities.RanLoadInformation{}
494 ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
496 cellLoadInformation := generateCellLoadInformation()
497 ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
499 return &ranLoadInformation
502 func TestSaveNilEntityFailure(t *testing.T) {
504 initSdlInstanceMock(namespace, 1)
506 expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
507 nbIdentity := &entities.NbIdentity{}
508 actualErr := w.SaveNodeb(nbIdentity, nil)
509 assert.Equal(t, expectedErr, actualErr)
512 func TestSaveUnknownTypeEntityFailure(t *testing.T) {
514 initSdlInstanceMock(namespace, 1)
516 expectedErr := common.NewValidationError("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 ")
517 nbIdentity := &entities.NbIdentity{InventoryName: "name", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
518 nb := &entities.NodebInfo{}
521 actualErr := w.SaveNodeb(nbIdentity, nb)
522 assert.Equal(t, expectedErr, actualErr)
525 func TestSaveEntityFailure(t *testing.T) {
531 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
533 gnb := entities.NodebInfo{}
534 gnb.NodeType = entities.Node_GNB
535 data, err := proto.Marshal(&gnb)
537 t.Errorf("#rNibWriter_test.TestSaveEntityFailure - Failed to marshal NodeB entity. Error: %v", err)
539 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
540 setExpected := []interface{}{"RAN:" + name, data}
541 setExpected = append(setExpected, "GNB:"+plmnId+":"+nbId, data)
542 expectedErr := errors.New("expected error")
543 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
544 rNibErr := w.SaveNodeb(nbIdentity, &gnb)
545 assert.NotEmpty(t, rNibErr)
548 func TestGetRNibWriterPoolNotInitializedFailure(t *testing.T) {
550 assert.Panics(t, func() { GetRNibWriter().SaveNodeb(nil,nil) })
553 func TestGetRNibWriter(t *testing.T) {
555 initSdlInstanceMock(namespace, 1)
556 received := GetRNibWriter()
557 assert.Empty(t, received)
558 available, created := writerPool.Stats()
559 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
560 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
564 func TestClose(t *testing.T) {
566 instanceMock := initSdlInstanceMock(namespace, 2)
567 w1 := GetRNibWriter()
568 w2 := GetRNibWriter()
571 available, created := writerPool.Stats()
572 assert.Equal(t, 2, available, "number of available objects in the writerPool should be 2")
573 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
575 instanceMock.On("Close").Return(e)
577 available, created = writerPool.Stats()
578 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
581 func TestCloseOnClosedPoolFailure(t *testing.T) {
583 instanceMock := initSdlInstanceMock(namespace, 1)
584 w1 := GetRNibWriter()
586 available, created := writerPool.Stats()
587 assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
588 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
590 instanceMock.On("Close").Return(e)
592 assert.Panics(t, func() { Close() })
595 func TestCloseFailure(t *testing.T) {
597 instanceMock := initSdlInstanceMock(namespace, 2)
598 w1 := GetRNibWriter()
600 available, created := writerPool.Stats()
601 assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
602 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
603 e := errors.New("expected error")
604 instanceMock.On("Close").Return(e)
606 available, created = writerPool.Stats()
607 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
610 func TestInit(t *testing.T) {
613 assert.NotNil(t, writerPool)
614 assert.NotNil(t, writerPool.New)
615 assert.NotNil(t, writerPool.Destroy)
616 available, created := writerPool.Stats()
617 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
618 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
623 //func TestSaveEnbGnbInteg(t *testing.T){
624 // for i := 0; i<10; i++{
625 // Init("e2Manager", 1)
626 // w := GetRNibWriter()
627 // nb := entities.NodebInfo{}
628 // nb.NodeType = entities.Node_ENB
629 // nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
630 // nb.Ip = "localhost"
631 // nb.Port = uint32(5656 + i)
632 // enb := entities.Enb{}
633 // cell1 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",111 + i), Pci:uint32(11 + i)}
634 // cell2 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",222 + i), Pci:uint32(22 + i)}
635 // cell3 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",333 + i), Pci:uint32(33 + i)}
636 // enb.ServedCells = []*entities.ServedCellInfo{cell1, cell2, cell3}
637 // nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
638 // plmnId := 0x02f828
639 // nbId := 0x4a952a0a
640 // nbIdentity := &entities.NbIdentity{InventoryName: fmt.Sprintf("nameEnb%d" ,i), GlobalNbId:&entities.GlobalNbId{PlmnId:fmt.Sprintf("%02x", plmnId + i), NbId:fmt.Sprintf("%02x", nbId + i)}}
641 // err := w.SaveNodeb(nbIdentity, &nb)
643 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
646 // nb1 := entities.NodebInfo{}
647 // nb1.NodeType = entities.Node_GNB
648 // nb1.ConnectionStatus = entities.ConnectionStatus_CONNECTED
649 // nb1.Ip = "localhost"
650 // nb1.Port = uint32(6565 + i)
651 // gnb := entities.Gnb{}
652 // gCell1 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",1111 + i), NrPci:uint32(1 + i)}}
653 // gCell2 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",2222 + i), NrPci:uint32(2 + i)}}
654 // gCell3 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",3333 + i), NrPci:uint32(3 + i)}}
655 // gnb.ServedNrCells = []*entities.ServedNRCell{gCell1, gCell2, gCell3,}
656 // nb1.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
657 // nbIdentity = &entities.NbIdentity{InventoryName: fmt.Sprintf("nameGnb%d" ,i), GlobalNbId:&entities.GlobalNbId{PlmnId:fmt.Sprintf("%02x", plmnId - i), NbId:fmt.Sprintf("%02x", nbId - i)}}
658 // err = w.SaveNodeb(nbIdentity, &nb1)
660 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
665 //func TestSaveNbRanNamesInteg(t *testing.T){
666 // for i := 0; i<10; i++{
667 // Init("e2Manager", 1)
668 // w := GetRNibWriter()
669 // nb := entities.NodebInfo{}
670 // nb.ConnectionStatus = entities.ConnectionStatus_CONNECTING
671 // nb.Ip = "localhost"
672 // nb.Port = uint32(5656 + i)
673 // nbIdentity := &entities.NbIdentity{InventoryName: fmt.Sprintf("nameOnly%d" ,i)}
674 // err := w.SaveNodeb(nbIdentity, &nb)
676 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
681 //func TestSaveRanLoadInformationInteg(t *testing.T){
682 // Init("e2Manager", 1)
683 // w := GetRNibWriter()
684 // ranLoadInformation := generateRanLoadInformation()
685 // err := w.SaveRanLoadInformation("ran_integ", ranLoadInformation)
687 // t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationInteg - Failed to save RanLoadInformation entity. Error: %v", err)