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.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
27 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
28 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
29 "github.com/golang/protobuf/proto"
30 "github.com/stretchr/testify/assert"
35 func TestInitRNibWriter(t *testing.T) {
37 initSdlInstanceMock(namespace, 1)
38 available, created := writerPool.Stats()
39 assert.Equal(t, available, 0, "number of available objects in the writerPool should be 0")
40 assert.Equal(t, created, 0, "number of created objects in the writerPool should be 0")
45 func TestInitPool(t *testing.T) {
47 sdlInstanceMock := new(mocks.MockSdlInstance)
48 initPool(1, func() interface{} {
49 sdlI := common.ISdlInstance(sdlInstanceMock)
50 return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
52 func(obj interface{}) {
55 assert.NotNil(t, writerPool)
56 assert.NotNil(t, writerPool.New)
57 assert.NotNil(t, writerPool.Destroy)
58 available, created := writerPool.Stats()
59 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
60 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
63 var namespace = "namespace"
65 func initSdlInstanceMock(namespace string, poolSize int) *mocks.MockSdlInstance {
66 sdlInstanceMock := new(mocks.MockSdlInstance)
67 initPool(poolSize, func() interface{} {
68 sdlI := common.ISdlInstance(sdlInstanceMock)
69 return &rNibWriterInstance{sdl: &sdlI, namespace: namespace}
71 func(obj interface{}) {
74 return sdlInstanceMock
77 func TestUpdateNodebInfoSuccess(t *testing.T) {
78 inventoryName := "name"
82 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
84 nodebInfo := &entities.NodebInfo{}
85 nodebInfo.RanName = inventoryName
86 nodebInfo.GlobalNbId = &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
87 nodebInfo.NodeType = entities.Node_ENB
88 nodebInfo.ConnectionStatus = 1
90 nodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
91 data, err := proto.Marshal(nodebInfo)
93 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
96 var setExpected []interface{}
98 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
99 nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
100 setExpected = append(setExpected, nodebNameKey, data)
101 setExpected = append(setExpected, nodebIdKey, data)
103 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
105 rNibErr := w.UpdateNodebInfo(nodebInfo)
106 assert.Nil(t, rNibErr)
109 func TestUpdateNodebInfoMissingInventoryNameFailure(t *testing.T) {
110 inventoryName := "name"
114 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
116 nodebInfo := &entities.NodebInfo{}
117 data, err := proto.Marshal(nodebInfo)
119 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
122 var setExpected []interface{}
124 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
125 nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
126 setExpected = append(setExpected, nodebNameKey, data)
127 setExpected = append(setExpected, nodebIdKey, data)
129 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
131 rNibErr := w.UpdateNodebInfo(nodebInfo)
133 assert.NotNil(t, rNibErr)
134 assert.IsType(t, &common.ValidationError{}, rNibErr)
137 func TestUpdateNodebInfoMissingGlobalNbId(t *testing.T) {
138 inventoryName := "name"
140 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
142 nodebInfo := &entities.NodebInfo{}
143 nodebInfo.RanName = inventoryName
144 data, err := proto.Marshal(nodebInfo)
146 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
149 var setExpected []interface{}
151 nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
152 setExpected = append(setExpected, nodebNameKey, data)
153 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
155 rNibErr := w.UpdateNodebInfo(nodebInfo)
157 assert.Nil(t, rNibErr)
160 func TestSaveEnb(t *testing.T) {
162 ranName := "RAN:" + name
164 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
166 nb := entities.NodebInfo{}
167 nb.NodeType = entities.Node_ENB
168 nb.ConnectionStatus = 1
171 enb := entities.Enb{}
172 cell := &entities.ServedCellInfo{CellId: "aaff", Pci: 3}
173 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: cell}}
174 enb.ServedCells = []*entities.ServedCellInfo{cell}
175 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
176 data, err := proto.Marshal(&nb)
178 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
182 cellData, err := proto.Marshal(&cellEntity)
184 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal Cell entity. Error: %v", err)
186 var setExpected []interface{}
187 setExpected = append(setExpected, ranName, data)
188 setExpected = append(setExpected, "ENB:02f829:4a952a0a", data)
189 setExpected = append(setExpected, fmt.Sprintf("CELL:%s", cell.GetCellId()), cellData)
190 setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetPci()), cellData)
192 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
194 nbIdData, err := proto.Marshal(&entities.NbIdentity{InventoryName: name})
196 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal nbIdentity entity. Error: %v", err)
198 sdlInstanceMock.On("RemoveMember", entities.Node_UNKNOWN.String(), []interface{}{nbIdData}).Return(e)
200 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
201 nbIdData, err = proto.Marshal(nbIdentity)
203 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB Identity entity. Error: %v", err)
205 sdlInstanceMock.On("AddMember", "ENB", []interface{}{nbIdData}).Return(e)
207 rNibErr := w.SaveNodeb(nbIdentity, &nb)
208 assert.Nil(t, rNibErr)
211 func TestSaveEnbCellIdValidationFailure(t *testing.T) {
214 initSdlInstanceMock(namespace, 1)
216 nb := entities.NodebInfo{}
217 nb.NodeType = entities.Node_ENB
218 nb.ConnectionStatus = 1
221 enb := entities.Enb{}
222 cell := &entities.ServedCellInfo{Pci: 3}
223 enb.ServedCells = []*entities.ServedCellInfo{cell}
224 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
226 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
227 rNibErr := w.SaveNodeb(nbIdentity, &nb)
228 assert.NotNil(t, rNibErr)
229 assert.IsType(t, &common.ValidationError{}, rNibErr)
230 assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", rNibErr.Error())
233 func TestSaveEnbInventoryNameValidationFailure(t *testing.T) {
235 initSdlInstanceMock(namespace, 1)
237 nb := entities.NodebInfo{}
238 nb.NodeType = entities.Node_ENB
239 nb.ConnectionStatus = 1
242 enb := entities.Enb{}
243 cell := &entities.ServedCellInfo{CellId: "aaa", Pci: 3}
244 enb.ServedCells = []*entities.ServedCellInfo{cell}
245 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
247 nbIdentity := &entities.NbIdentity{InventoryName: "", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
248 rNibErr := w.SaveNodeb(nbIdentity, &nb)
249 assert.NotNil(t, rNibErr)
250 assert.IsType(t, &common.ValidationError{}, rNibErr)
251 assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
254 func TestSaveEnbOnClosedPool(t *testing.T) {
257 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
259 nb := entities.NodebInfo{}
260 nb.NodeType = entities.Node_ENB
261 nb.ConnectionStatus = 1
264 enb := entities.Enb{}
265 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
266 data, err := proto.Marshal(&nb)
268 t.Errorf("#rNibWriter_test.TestSaveEnbOnClosedPool - Failed to marshal NodeB entity. Error: %v", err)
270 setExpected := []interface{}{name, data}
272 sdlInstanceMock.On("Set", setExpected).Return(e)
274 nbIdentity := &entities.NbIdentity{}
275 assert.Panics(t, func() { w.SaveNodeb(nbIdentity, &nb) })
278 func TestSaveGnbCellIdValidationFailure(t *testing.T) {
281 initSdlInstanceMock(namespace, 1)
283 nb := entities.NodebInfo{}
284 nb.NodeType = entities.Node_GNB
285 nb.ConnectionStatus = 1
288 gnb := entities.Gnb{}
289 cellInfo := &entities.ServedNRCellInformation{NrPci: 2}
290 cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
291 gnb.ServedNrCells = []*entities.ServedNRCell{cell}
292 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
294 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
295 rNibErr := w.SaveNodeb(nbIdentity, &nb)
296 assert.NotNil(t, rNibErr)
297 assert.IsType(t, &common.ValidationError{}, rNibErr)
298 assert.Equal(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", rNibErr.Error())
301 func TestSaveGnb(t *testing.T) {
303 ranName := "RAN:" + name
305 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
307 nb := entities.NodebInfo{}
308 nb.NodeType = entities.Node_GNB
309 nb.ConnectionStatus = 1
312 gnb := entities.Gnb{}
313 cellInfo := &entities.ServedNRCellInformation{NrPci: 2, CellId: "ccdd"}
314 cell := &entities.ServedNRCell{ServedNrCellInformation: cellInfo}
315 cellEntity := entities.Cell{Type: entities.Cell_NR_CELL, Cell: &entities.Cell_ServedNrCell{ServedNrCell: cell}}
316 gnb.ServedNrCells = []*entities.ServedNRCell{cell}
317 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
318 data, err := proto.Marshal(&nb)
320 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB entity. Error: %v", err)
324 cellData, err := proto.Marshal(&cellEntity)
326 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal Cell entity. Error: %v", err)
328 var setExpected []interface{}
329 setExpected = append(setExpected, ranName, data)
330 setExpected = append(setExpected, "GNB:02f829:4a952a0a", data)
331 setExpected = append(setExpected, fmt.Sprintf("NRCELL:%s", cell.GetServedNrCellInformation().GetCellId()), cellData)
332 setExpected = append(setExpected, fmt.Sprintf("PCI:%s:%02x", name, cell.GetServedNrCellInformation().GetNrPci()), cellData)
334 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
335 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
336 nbIdData, err := proto.Marshal(nbIdentity)
338 t.Errorf("#rNibWriter_test.TestSaveGnb - Failed to marshal NodeB Identity entity. Error: %v", err)
340 sdlInstanceMock.On("AddMember", "GNB", []interface{}{nbIdData}).Return(e)
342 nbIdData, err = proto.Marshal(&entities.NbIdentity{InventoryName: name})
344 t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal nbIdentity entity. Error: %v", err)
346 sdlInstanceMock.On("RemoveMember", entities.Node_UNKNOWN.String(), []interface{}{nbIdData}).Return(e)
348 rNibErr := w.SaveNodeb(nbIdentity, &nb)
349 assert.Nil(t, rNibErr)
352 func TestSaveRanLoadInformationSuccess(t *testing.T) {
353 inventoryName := "name"
354 loadKey, validationErr := common.ValidateAndBuildRanLoadInformationKey(inventoryName)
356 if validationErr != nil {
357 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
361 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
364 ranLoadInformation := generateRanLoadInformation()
365 data, err := proto.Marshal(ranLoadInformation)
368 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
372 var setExpected []interface{}
373 setExpected = append(setExpected, loadKey, data)
374 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
376 rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
377 assert.Nil(t, rNibErr)
380 func TestSaveRanLoadInformationMarshalNilFailure(t *testing.T) {
381 inventoryName := "name2"
383 initSdlInstanceMock(namespace, 1)
386 expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
387 err := w.SaveRanLoadInformation(inventoryName, nil)
388 assert.Equal(t, expectedErr, err)
391 func TestSaveRanLoadInformationEmptyInventoryNameFailure(t *testing.T) {
394 initSdlInstanceMock(namespace, 1)
397 err := w.SaveRanLoadInformation(inventoryName, nil)
398 assert.NotNil(t, err)
399 assert.IsType(t, &common.ValidationError{}, err)
402 func TestSaveRanLoadInformationSdlFailure(t *testing.T) {
403 inventoryName := "name2"
405 loadKey, validationErr := common.ValidateAndBuildRanLoadInformationKey(inventoryName)
407 if validationErr != nil {
408 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationSuccess - Failed to build ran load infromation key. Error: %v", validationErr)
412 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
415 ranLoadInformation := generateRanLoadInformation()
416 data, err := proto.Marshal(ranLoadInformation)
419 t.Errorf("#rNibWriter_test.TestSaveRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
422 expectedErr := errors.New("expected error")
423 var setExpected []interface{}
424 setExpected = append(setExpected, loadKey, data)
425 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
427 rNibErr := w.SaveRanLoadInformation(inventoryName, ranLoadInformation)
428 assert.NotNil(t, rNibErr)
429 assert.IsType(t, &common.InternalError{}, rNibErr)
432 func generateCellLoadInformation() *entities.CellLoadInformation {
433 cellLoadInformation := entities.CellLoadInformation{}
435 cellLoadInformation.CellId = "123"
437 ulInterferenceOverloadIndication := entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE
438 cellLoadInformation.UlInterferenceOverloadIndications = []entities.UlInterferenceOverloadIndication{ulInterferenceOverloadIndication}
440 ulHighInterferenceInformation := entities.UlHighInterferenceInformation{
442 UlHighInterferenceIndication: "xxx",
445 cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation}
447 cellLoadInformation.RelativeNarrowbandTxPower = &entities.RelativeNarrowbandTxPower{
449 RntpThreshold: entities.RntpThreshold_NEG_4,
450 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
452 PdcchInterferenceImpact: 2,
453 EnhancedRntp: &entities.EnhancedRntp{
454 EnhancedRntpBitmap: "xxx",
455 RntpHighPowerThreshold: entities.RntpThreshold_NEG_2,
456 EnhancedRntpStartTime: &entities.StartTime{StartSfn: 500, StartSubframeNumber: 5},
460 cellLoadInformation.AbsInformation = &entities.AbsInformation{
461 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
462 AbsPatternInfo: "xxx",
463 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
464 MeasurementSubset: "xxx",
467 cellLoadInformation.InvokeIndication = entities.InvokeIndication_ABS_INFORMATION
469 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = &entities.ExtendedUlInterferenceOverloadInfo{
470 AssociatedSubframes: "xxx",
471 ExtendedUlInterferenceOverloadIndications: cellLoadInformation.UlInterferenceOverloadIndications,
474 compInformationItem := &entities.CompInformationItem{
475 CompHypothesisSets: []*entities.CompHypothesisSet{&entities.CompHypothesisSet{CellId: "789", CompHypothesis: "xxx"}},
479 cellLoadInformation.CompInformation = &entities.CompInformation{
480 CompInformationItems: []*entities.CompInformationItem{compInformationItem},
481 CompInformationStartTime: &entities.StartTime{StartSfn: 123, StartSubframeNumber: 456},
484 cellLoadInformation.DynamicDlTransmissionInformation = &entities.DynamicDlTransmissionInformation{
485 State: entities.NaicsState_NAICS_ACTIVE,
486 TransmissionModes: "xxx",
488 PAList: []entities.PA{entities.PA_DB_NEG_3},
491 return &cellLoadInformation
494 func generateRanLoadInformation() *entities.RanLoadInformation {
495 ranLoadInformation := entities.RanLoadInformation{}
497 ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
499 cellLoadInformation := generateCellLoadInformation()
500 ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
502 return &ranLoadInformation
505 func TestSaveNilEntityFailure(t *testing.T) {
507 initSdlInstanceMock(namespace, 1)
509 expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
510 nbIdentity := &entities.NbIdentity{}
511 actualErr := w.SaveNodeb(nbIdentity, nil)
512 assert.Equal(t, expectedErr, actualErr)
515 func TestSaveUnknownTypeEntityFailure(t *testing.T) {
517 initSdlInstanceMock(namespace, 1)
519 expectedErr := common.NewValidationError("#rNibWriter.saveNodeB - Unknown responding node type, entity: ip:\"localhost\" port:5656 ")
520 nbIdentity := &entities.NbIdentity{InventoryName: "name", GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"}}
521 nb := &entities.NodebInfo{}
524 actualErr := w.SaveNodeb(nbIdentity, nb)
525 assert.Equal(t, expectedErr, actualErr)
528 func TestSaveEntityFailure(t *testing.T) {
534 sdlInstanceMock := initSdlInstanceMock(namespace, 1)
536 gnb := entities.NodebInfo{}
537 gnb.NodeType = entities.Node_GNB
538 data, err := proto.Marshal(&gnb)
540 t.Errorf("#rNibWriter_test.TestSaveEntityFailure - Failed to marshal NodeB entity. Error: %v", err)
542 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
543 setExpected := []interface{}{"RAN:" + name, data}
544 setExpected = append(setExpected, "GNB:"+plmnId+":"+nbId, data)
545 expectedErr := errors.New("expected error")
546 sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(expectedErr)
547 rNibErr := w.SaveNodeb(nbIdentity, &gnb)
548 assert.NotEmpty(t, rNibErr)
551 func TestGetRNibWriterPoolNotInitializedFailure(t *testing.T) {
553 assert.Panics(t, func() { GetRNibWriter().SaveNodeb(nil,nil) })
556 func TestGetRNibWriter(t *testing.T) {
558 initSdlInstanceMock(namespace, 1)
559 received := GetRNibWriter()
560 assert.Empty(t, received)
561 available, created := writerPool.Stats()
562 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
563 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
567 func TestClose(t *testing.T) {
569 instanceMock := initSdlInstanceMock(namespace, 2)
570 w1 := GetRNibWriter()
571 w2 := GetRNibWriter()
574 available, created := writerPool.Stats()
575 assert.Equal(t, 2, available, "number of available objects in the writerPool should be 2")
576 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
578 instanceMock.On("Close").Return(e)
580 available, created = writerPool.Stats()
581 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
584 func TestCloseOnClosedPoolFailure(t *testing.T) {
586 instanceMock := initSdlInstanceMock(namespace, 1)
587 w1 := GetRNibWriter()
589 available, created := writerPool.Stats()
590 assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
591 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
593 instanceMock.On("Close").Return(e)
595 assert.Panics(t, func() { Close() })
598 func TestCloseFailure(t *testing.T) {
600 instanceMock := initSdlInstanceMock(namespace, 2)
601 w1 := GetRNibWriter()
603 available, created := writerPool.Stats()
604 assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
605 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
606 e := errors.New("expected error")
607 instanceMock.On("Close").Return(e)
609 available, created = writerPool.Stats()
610 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
613 func TestInit(t *testing.T) {
616 assert.NotNil(t, writerPool)
617 assert.NotNil(t, writerPool.New)
618 assert.NotNil(t, writerPool.Destroy)
619 available, created := writerPool.Stats()
620 assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
621 assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
626 //func TestSaveEnbGnbInteg(t *testing.T){
627 // for i := 0; i<10; i++{
628 // Init("e2Manager", 1)
629 // w := GetRNibWriter()
630 // nb := entities.NodebInfo{}
631 // nb.NodeType = entities.Node_ENB
632 // nb.ConnectionStatus = entities.ConnectionStatus_CONNECTED
633 // nb.Ip = "localhost"
634 // nb.Port = uint32(5656 + i)
635 // enb := entities.Enb{}
636 // cell1 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",111 + i), Pci:uint32(11 + i)}
637 // cell2 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",222 + i), Pci:uint32(22 + i)}
638 // cell3 := &entities.ServedCellInfo{CellId:fmt.Sprintf("%02x",333 + i), Pci:uint32(33 + i)}
639 // enb.ServedCells = []*entities.ServedCellInfo{cell1, cell2, cell3}
640 // nb.Configuration = &entities.NodebInfo_Enb{Enb:&enb}
641 // plmnId := 0x02f828
642 // nbId := 0x4a952a0a
643 // nbIdentity := &entities.NbIdentity{InventoryName: fmt.Sprintf("nameEnb%d" ,i), GlobalNbId:&entities.GlobalNbId{PlmnId:fmt.Sprintf("%02x", plmnId + i), NbId:fmt.Sprintf("%02x", nbId + i)}}
644 // err := w.SaveNodeb(nbIdentity, &nb)
646 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
649 // nb1 := entities.NodebInfo{}
650 // nb1.NodeType = entities.Node_GNB
651 // nb1.ConnectionStatus = entities.ConnectionStatus_CONNECTED
652 // nb1.Ip = "localhost"
653 // nb1.Port = uint32(6565 + i)
654 // gnb := entities.Gnb{}
655 // gCell1 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",1111 + i), NrPci:uint32(1 + i)}}
656 // gCell2 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",2222 + i), NrPci:uint32(2 + i)}}
657 // gCell3 := &entities.ServedNRCell{ServedNrCellInformation:&entities.ServedNRCellInformation{CellId:fmt.Sprintf("%02x",3333 + i), NrPci:uint32(3 + i)}}
658 // gnb.ServedNrCells = []*entities.ServedNRCell{gCell1, gCell2, gCell3,}
659 // nb1.Configuration = &entities.NodebInfo_Gnb{Gnb:&gnb}
660 // nbIdentity = &entities.NbIdentity{InventoryName: fmt.Sprintf("nameGnb%d" ,i), GlobalNbId:&entities.GlobalNbId{PlmnId:fmt.Sprintf("%02x", plmnId - i), NbId:fmt.Sprintf("%02x", nbId - i)}}
661 // err = w.SaveNodeb(nbIdentity, &nb1)
663 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
668 //func TestSaveNbRanNamesInteg(t *testing.T){
669 // for i := 0; i<10; i++{
670 // Init("e2Manager", 1)
671 // w := GetRNibWriter()
672 // nb := entities.NodebInfo{}
673 // nb.ConnectionStatus = entities.ConnectionStatus_CONNECTING
674 // nb.Ip = "localhost"
675 // nb.Port = uint32(5656 + i)
676 // nbIdentity := &entities.NbIdentity{InventoryName: fmt.Sprintf("nameOnly%d" ,i)}
677 // err := w.SaveNodeb(nbIdentity, &nb)
679 // t.Errorf("#rNibWriter_test.TestSaveEnbInteg - Failed to save NodeB entity. Error: %v", err)
684 //func TestSaveRanLoadInformationInteg(t *testing.T){
685 // Init("e2Manager", 1)
686 // w := GetRNibWriter()
687 // ranLoadInformation := generateRanLoadInformation()
688 // err := w.SaveRanLoadInformation("ran_integ", ranLoadInformation)
690 // t.Errorf("#rNibWriter_test.TestSaveRanLoadInformationInteg - Failed to save RanLoadInformation entity. Error: %v", err)