2 // Copyright 2021 AT&T Intellectual Property
3 // Copyright 2021 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).
25 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
26 "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
27 "github.com/golang/protobuf/proto"
28 "github.com/pkg/errors"
29 "github.com/stretchr/testify/assert"
35 //Deprecated: This file will be removed in a future release when SDL SdlInstance usage will be replaced by SynchStorage.
36 //Valid RNIB Reader unit tests are in rNibReader_test.go file, rNibReaderDeprecated_test.go will exist until SdlInstance
37 //usage will be removed from the RNIB source code.
39 func initSdlInstanceMock() (w RNibReader, sdlInstanceMock *MockSdlInstance) {
40 sdlInstanceMock = new(MockSdlInstance)
41 w = GetRNibReader(sdlInstanceMock)
45 func TestGetNodeBDeprecated(t *testing.T) {
47 w, sdlInstanceMock := initSdlInstanceMock()
48 nb := entities.NodebInfo{}
49 nb.ConnectionStatus = 1
53 cell := entities.ServedCellInfo{Tac: "tac"}
54 enb.ServedCells = []*entities.ServedCellInfo{&cell}
55 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
57 data, err := proto.Marshal(&nb)
59 t.Errorf("#rNibReader_test.TestGetNb - Failed to marshal ENB instance. Error: %v", err)
61 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
63 t.Errorf("#rNibReader_test.TestGetNodeB - failed to validate key parameter")
65 ret := map[string]interface{}{redisKey: string(data)}
66 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
67 getNb, er := w.GetNodeb(name)
69 assert.Equal(t, getNb.Ip, nb.Ip)
70 assert.Equal(t, getNb.Port, nb.Port)
71 assert.Equal(t, getNb.ConnectionStatus, nb.ConnectionStatus)
72 assert.Len(t, getNb.GetEnb().GetServedCells(), 1)
73 assert.Equal(t, getNb.GetEnb().GetServedCells()[0].Tac, nb.GetEnb().GetServedCells()[0].Tac)
76 func TestGetNodeBNotFoundFailureDeprecated(t *testing.T) {
78 w, sdlInstanceMock := initSdlInstanceMock()
80 var ret map[string]interface{}
81 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
83 t.Errorf("#rNibReader_test.TestGetNodeBNotFoundFailure - failed to validate key parameter")
85 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
86 getNb, er := w.GetNodeb(name)
89 assert.IsType(t, &common.ResourceNotFoundError{}, er)
90 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: RAN:name", er.Error())
93 func TestGetNodeBUnmarshalFailureDeprecated(t *testing.T) {
95 w, sdlInstanceMock := initSdlInstanceMock()
97 ret := make(map[string]interface{}, 1)
98 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
100 t.Errorf("#rNibReader_test.TestGetNodeBUnmarshalFailure - failed to validate key parameter")
102 ret[redisKey] = "data"
103 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
104 getNb, er := w.GetNodeb(name)
107 assert.IsType(t, &common.InternalError{}, er)
108 assert.Contains(t, er.Error(), "proto:")
111 func TestGetNodeBSdlgoFailureDeprecated(t *testing.T) {
113 errMsg := "expected Sdlgo error"
114 errMsgExpected := "expected Sdlgo error"
115 w, sdlInstanceMock := initSdlInstanceMock()
116 e := errors.New(errMsg)
117 var ret map[string]interface{}
118 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
120 t.Errorf("#rNibReader_test.TestGetNodeBSdlgoFailure - failed to validate key parameter")
122 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
123 getNb, er := w.GetNodeb(name)
126 assert.IsType(t, &common.InternalError{}, er)
127 assert.EqualValues(t, errMsgExpected, er.Error())
130 func TestGetNodeBCellsListEnbDeprecated(t *testing.T) {
132 w, sdlInstanceMock := initSdlInstanceMock()
133 nb := entities.NodebInfo{}
134 nb.ConnectionStatus = 1
137 enb := entities.Enb{}
138 cell := entities.ServedCellInfo{Tac: "tac"}
139 enb.ServedCells = []*entities.ServedCellInfo{&cell}
140 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
142 data, err := proto.Marshal(&nb)
144 t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal ENB instance. Error: %v", err)
146 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
148 t.Errorf("#rNibReader_test.TestGetNodeBCellsListEnb - failed to validate key parameter")
150 ret := map[string]interface{}{redisKey: string(data)}
151 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
152 cells, er := w.GetCellList(name)
154 assert.NotNil(t, cells)
155 assert.Len(t, cells.GetServedCellInfos().GetServedCells(), 1)
156 retCell := cells.GetServedCellInfos().GetServedCells()[0]
157 assert.Equal(t, retCell.Tac, "tac")
160 func TestGetNodeBCellsListGnbDeprecated(t *testing.T) {
162 w, sdlInstanceMock := initSdlInstanceMock()
163 nb := entities.NodebInfo{}
164 nb.ConnectionStatus = 1
167 nb.NodeType = entities.Node_GNB
168 gnb := entities.Gnb{}
169 cell := entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{NrPci: 10}}
170 gnb.ServedNrCells = []*entities.ServedNRCell{&cell}
171 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
173 data, err := proto.Marshal(&nb)
175 t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal GNB instance. Error: %v", err)
177 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
179 t.Errorf("#rNibReader_test.TestGetNodeBCellsListGnb - failed to validate key parameter")
181 ret := map[string]interface{}{redisKey: string(data)}
182 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
183 cells, er := w.GetCellList(name)
185 assert.NotNil(t, cells)
186 assert.Len(t, cells.GetServedNrCells().GetServedCells(), 1)
187 retCell := cells.GetServedNrCells().GetServedCells()[0]
188 assert.Equal(t, retCell.GetServedNrCellInformation().GetNrPci(), uint32(10))
191 func TestGetNodeBCellsListNodeUnmarshalFailureDeprecated(t *testing.T) {
193 w, sdlInstanceMock := initSdlInstanceMock()
195 ret := make(map[string]interface{}, 1)
196 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
198 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNodeUnmarshalFailure - failed to validate key parameter")
200 ret[redisKey] = "data"
201 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
202 cells, er := w.GetCellList(name)
205 assert.IsType(t, &common.InternalError{}, er)
206 assert.Contains(t, er.Error(), "proto:")
209 func TestGetNodeBCellsListNodeNotFoundFailureDeprecated(t *testing.T) {
211 w, sdlInstanceMock := initSdlInstanceMock()
213 var ret map[string]interface{}
214 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
216 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNodeNotFoundFailure - failed to validate key parameter")
218 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
219 cells, er := w.GetCellList(name)
222 assert.IsType(t, &common.ResourceNotFoundError{}, er)
223 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: RAN:name", er.Error())
226 func TestGetNodeBCellsListNotFoundFailureEnbDeprecated(t *testing.T) {
228 w, sdlInstanceMock := initSdlInstanceMock()
229 nb := entities.NodebInfo{}
230 nb.ConnectionStatus = 1
233 enb := entities.Enb{}
234 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
236 data, err := proto.Marshal(&nb)
238 t.Errorf("#rNibReader_test.TestGetNbCellsListNotFoundFailure - Failed to marshal ENB instance. Error: %v", err)
240 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
242 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureEnb - failed to validate key parameter")
244 ret := map[string]interface{}{redisKey: string(data)}
245 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
246 _, er := w.GetCellList(name)
248 assert.EqualValues(t, "#rNibReader.GetCellList - served cells not found. Responding node RAN name: name.", er.Error())
251 func TestGetNodeBCellsListNotFoundFailureGnbDeprecated(t *testing.T) {
253 w, sdlInstanceMock := initSdlInstanceMock()
254 nb := entities.NodebInfo{}
255 nb.ConnectionStatus = 1
258 gnb := entities.Gnb{}
259 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
261 data, err := proto.Marshal(&nb)
263 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureGnb - Failed to marshal ENB instance. Error: %v", err)
265 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
267 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureGnb - failed to validate key parameter")
269 ret := map[string]interface{}{redisKey: string(data)}
270 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
271 _, er := w.GetCellList(name)
273 assert.EqualValues(t, "#rNibReader.GetCellList - served cells not found. Responding node RAN name: name.", er.Error())
276 func TestGetListGnbIdsUnmarshalFailureDeprecated(t *testing.T) {
277 w, sdlInstanceMock := initSdlInstanceMock()
279 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{"data"}, e)
280 ids, er := w.GetListGnbIds()
283 assert.IsType(t, &common.InternalError{}, er)
284 assert.Contains(t, er.Error(), "proto:")
287 func TestGetListGnbIdsSdlgoFailureDeprecated(t *testing.T) {
288 errMsg := "expected Sdlgo error"
289 errMsgExpected := "expected Sdlgo error"
290 w, sdlInstanceMock := initSdlInstanceMock()
291 e := errors.New(errMsg)
293 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(data, e)
294 ids, er := w.GetListGnbIds()
297 assert.IsType(t, &common.InternalError{}, er)
298 assert.EqualValues(t, errMsgExpected, er.Error())
301 func TestGetListNodesIdsGnbSdlgoFailureDeprecated(t *testing.T) {
302 w, sdlInstanceMock := initSdlInstanceMock()
307 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
309 data, err := proto.Marshal(nbIdentity)
311 t.Errorf("#rNibReader_test.TestGetListNodesIdsGnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
313 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data)}, nilError)
315 errMsg := "expected Sdlgo error"
316 errMsgExpected := "expected Sdlgo error"
317 expectedError := errors.New(errMsg)
319 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(nilData, expectedError)
321 ids, er := w.GetListNodebIds()
324 assert.IsType(t, &common.InternalError{}, er)
325 assert.EqualValues(t, errMsgExpected, er.Error())
328 func TestGetListNodesIdsEnbSdlgoFailureDeprecated(t *testing.T) {
329 w, sdlInstanceMock := initSdlInstanceMock()
334 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
336 data, err := proto.Marshal(nbIdentity)
338 t.Errorf("#rNibReader_test.TestGetListNodesIdsEnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
340 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, nilError)
342 errMsg := "expected Sdlgo error"
343 errMsgExpected := "expected Sdlgo error"
344 expectedError := errors.New(errMsg)
346 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(nilData, expectedError)
348 ids, er := w.GetListNodebIds()
351 assert.IsType(t, &common.InternalError{}, er)
352 assert.EqualValues(t, errMsgExpected, er.Error())
355 func TestGetListNodesIdsSuccessDeprecated(t *testing.T) {
356 w, sdlInstanceMock := initSdlInstanceMock()
362 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
363 data, err := proto.Marshal(nbIdentity)
365 t.Errorf("#rNibReader_test.TestGetListNodesIdsSuccess - Failed to marshal nodeb identity entity. Error: %v", err)
371 nbIdentity1 := &entities.NbIdentity{InventoryName: name1, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId1, NbId: nbId1}}
372 data1, err := proto.Marshal(nbIdentity1)
374 t.Errorf("#rNibReader_test.TestGetListNodesIdsSuccess - Failed to marshal nodeb identity entity. Error: %v", err)
377 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, nilError)
378 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data1)}, nilError)
380 ids, er := w.GetListNodebIds()
382 assert.NotNil(t, ids)
383 assert.Len(t, ids, 2)
386 func TestGetListEnbIdsUnmarshalFailureDeprecated(t *testing.T) {
387 w, sdlInstanceMock := initSdlInstanceMock()
389 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{"data"}, e)
390 ids, er := w.GetListEnbIds()
393 assert.IsType(t, &common.InternalError{}, er)
394 assert.Contains(t, er.Error(), "proto:")
397 func TestGetListEnbIdsOneIdDeprecated(t *testing.T) {
401 w, sdlInstanceMock := initSdlInstanceMock()
402 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
404 data, err := proto.Marshal(nbIdentity)
406 t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
408 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data)}, e)
409 ids, er := w.GetListEnbIds()
411 assert.Len(t, ids, 1)
412 assert.Equal(t, (ids)[0].GetInventoryName(), name)
413 assert.Equal(t, (ids)[0].GetGlobalNbId().GetPlmnId(), nbIdentity.GetGlobalNbId().GetPlmnId())
414 assert.Equal(t, (ids)[0].GetGlobalNbId().GetNbId(), nbIdentity.GetGlobalNbId().GetNbId())
417 func TestGetListEnbIdsNoIdsDeprecated(t *testing.T) {
418 w, sdlInstanceMock := initSdlInstanceMock()
420 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{}, e)
421 ids, er := w.GetListEnbIds()
423 assert.Len(t, ids, 0)
426 func TestGetListEnbIdsDeprecated(t *testing.T) {
431 w, sdlInstanceMock := initSdlInstanceMock()
432 idsData := make([]string, listSize)
433 idsEntities := make([]*entities.NbIdentity, listSize)
434 for i := 0; i < listSize; i++ {
435 nbIdentity := &entities.NbIdentity{
437 GlobalNbId: &entities.GlobalNbId{
438 PlmnId: strconv.FormatInt(int64(plmnId+i), 16),
439 NbId: strconv.FormatInt(int64(nbId+i), 16),
442 data, err := proto.Marshal(nbIdentity)
444 t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
446 idsData[i] = string(data)
447 idsEntities[i] = nbIdentity
450 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(idsData, e)
451 ids, er := w.GetListEnbIds()
453 assert.Len(t, ids, listSize)
454 for i, id := range ids {
455 assert.Equal(t, id.GetInventoryName(), name)
456 assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
457 assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
461 func TestGetListGnbIdsOneIdDeprecated(t *testing.T) {
465 w, sdlInstanceMock := initSdlInstanceMock()
466 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
468 data, err := proto.Marshal(nbIdentity)
470 t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
472 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, e)
473 ids, er := w.GetListGnbIds()
475 assert.Len(t, ids, 1)
476 assert.Equal(t, (ids)[0].GetInventoryName(), name)
477 assert.Equal(t, (ids)[0].GetGlobalNbId().GetPlmnId(), nbIdentity.GetGlobalNbId().GetPlmnId())
478 assert.Equal(t, (ids)[0].GetGlobalNbId().GetNbId(), nbIdentity.GetGlobalNbId().GetNbId())
481 func TestGetListGnbIdsNoIdsDeprecated(t *testing.T) {
482 w, sdlInstanceMock := initSdlInstanceMock()
484 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{}, e)
485 ids, er := w.GetListGnbIds()
487 assert.Len(t, ids, 0)
490 func TestGetListGnbIdsDeprecated(t *testing.T) {
495 w, sdlInstanceMock := initSdlInstanceMock()
496 idsData := make([]string, listSize)
497 idsEntities := make([]*entities.NbIdentity, listSize)
498 for i := 0; i < listSize; i++ {
499 nbIdentity := &entities.NbIdentity{
501 GlobalNbId: &entities.GlobalNbId{
502 PlmnId: strconv.FormatInt(int64(plmnId+i), 16),
503 NbId: strconv.FormatInt(int64(nbId+i), 16),
506 data, err := proto.Marshal(nbIdentity)
508 t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
510 idsData[i] = string(data)
511 idsEntities[i] = nbIdentity
514 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(idsData, e)
515 ids, er := w.GetListGnbIds()
517 assert.Len(t, ids, listSize)
518 for i, id := range ids {
519 assert.Equal(t, id.GetInventoryName(), name)
520 assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
521 assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
525 func TestGetListEnbIdsSdlgoFailureDeprecated(t *testing.T) {
526 errMsg := "expected Sdlgo error"
527 errMsgExpected := "expected Sdlgo error"
528 w, sdlInstanceMock := initSdlInstanceMock()
529 e := errors.New(errMsg)
531 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(data, e)
532 ids, er := w.GetListEnbIds()
535 assert.IsType(t, &common.InternalError{}, er)
536 assert.EqualValues(t, errMsgExpected, er.Error())
539 func TestGetCountGnbListOneIdDeprecated(t *testing.T) {
540 w, sdlInstanceMock := initSdlInstanceMock()
542 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(1, e)
543 count, er := w.GetCountGnbList()
545 assert.Equal(t, count, 1)
548 func TestGetCountGnbListDeprecated(t *testing.T) {
549 w, sdlInstanceMock := initSdlInstanceMock()
551 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(3, e)
552 count, er := w.GetCountGnbList()
554 assert.Equal(t, count, 3)
557 func TestGetCountGnbListSdlgoFailureDeprecated(t *testing.T) {
558 errMsg := "expected Sdlgo error"
559 errMsgExpected := "expected Sdlgo error"
560 w, sdlInstanceMock := initSdlInstanceMock()
561 e := errors.New(errMsg)
563 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(count, e)
564 count, er := w.GetCountGnbList()
566 assert.Equal(t, 0, count)
567 assert.IsType(t, &common.InternalError{}, er)
568 assert.EqualValues(t, errMsgExpected, er.Error())
571 func TestGetCellDeprecated(t *testing.T) {
574 w, sdlInstanceMock := initSdlInstanceMock()
575 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
576 cellData, err := proto.Marshal(&cellEntity)
578 t.Errorf("#rNibReader_test.TestGetCell - Failed to marshal Cell entity. Error: %v", err)
581 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
583 t.Errorf("#rNibReader_test.TestGetCell - failed to validate key parameter")
585 ret := map[string]interface{}{key: string(cellData)}
586 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
587 cell, er := w.GetCell(name, pci)
589 assert.NotNil(t, cell)
590 assert.Equal(t, cell.Type, entities.Cell_LTE_CELL)
591 assert.NotNil(t, cell.GetServedCellInfo())
592 assert.Equal(t, cell.GetServedCellInfo().GetPci(), pci)
595 func TestGetCellNotFoundFailureDeprecated(t *testing.T) {
598 w, sdlInstanceMock := initSdlInstanceMock()
600 var ret map[string]interface{}
601 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
603 t.Errorf("#rNibReader_test.TestGetCellNotFoundFailure - failed to validate key parameter")
605 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
606 cell, er := w.GetCell(name, pci)
609 assert.IsType(t, &common.ResourceNotFoundError{}, er)
610 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: PCI:name:00", er.Error())
613 func TestGetCellUnmarshalFailureDeprecated(t *testing.T) {
616 w, sdlInstanceMock := initSdlInstanceMock()
618 ret := make(map[string]interface{}, 1)
619 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
621 t.Errorf("#rNibReader_test.TestGetCellUnmarshalFailure - failed to validate key parameter")
624 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
625 cell, er := w.GetCell(name, pci)
628 assert.IsType(t, &common.InternalError{}, er)
629 assert.Contains(t, er.Error(), "proto:")
632 func TestGetCellSdlgoFailureDeprecated(t *testing.T) {
635 errMsg := "expected Sdlgo error"
636 errMsgExpected := "expected Sdlgo error"
637 w, sdlInstanceMock := initSdlInstanceMock()
638 e := errors.New(errMsg)
639 var ret map[string]interface{}
640 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
642 t.Errorf("#rNibReader_test.TestGetCellSdlgoFailure - failed to validate key parameter")
644 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
645 cell, er := w.GetCell(name, pci)
648 assert.IsType(t, &common.InternalError{}, er)
649 assert.EqualValues(t, errMsgExpected, er.Error())
652 func TestGetNodebByIdDeprecated(t *testing.T) {
653 w, sdlInstanceMock := initSdlInstanceMock()
654 nb := entities.NodebInfo{NodeType: entities.Node_ENB}
655 nb.ConnectionStatus = 1
658 enb := entities.Enb{}
659 cell := entities.ServedCellInfo{Tac: "tac"}
660 enb.ServedCells = []*entities.ServedCellInfo{&cell}
661 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
663 data, err := proto.Marshal(&nb)
665 t.Errorf("#rNibReader_test.TestGetNodebById - Failed to marshal ENB instance. Error: %v", err)
670 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
672 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
674 ret := map[string]interface{}{key: string(data)}
675 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
676 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
677 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
679 assert.Equal(t, getNb.Ip, nb.Ip)
680 assert.Equal(t, getNb.Port, nb.Port)
681 assert.Equal(t, getNb.ConnectionStatus, nb.ConnectionStatus)
682 assert.Len(t, getNb.GetEnb().GetServedCells(), 1)
683 assert.Equal(t, getNb.GetEnb().GetServedCells()[0].Tac, nb.GetEnb().GetServedCells()[0].Tac)
686 func TestGetNodebByIdNotFoundFailureEnbDeprecated(t *testing.T) {
689 w, sdlInstanceMock := initSdlInstanceMock()
691 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
693 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
695 var ret map[string]interface{}
696 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
697 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
698 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
701 assert.IsType(t, &common.ResourceNotFoundError{}, er)
702 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: ENB:02f829:4a952a0a", er.Error())
705 func TestGetNodebByIdNotFoundFailureGnbDeprecated(t *testing.T) {
708 w, sdlInstanceMock := initSdlInstanceMock()
710 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
712 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
714 var ret map[string]interface{}
715 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
716 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
717 getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
720 assert.IsType(t, &common.ResourceNotFoundError{}, er)
721 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: GNB:02f829:4a952a0a", er.Error())
724 func TestGetNodeByIdUnmarshalFailureDeprecated(t *testing.T) {
727 w, sdlInstanceMock := initSdlInstanceMock()
728 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
730 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
733 ret := make(map[string]interface{}, 1)
735 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
736 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
737 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
740 assert.IsType(t, &common.InternalError{}, er)
741 assert.Contains(t, er.Error(), "proto:")
744 func TestGetNodeByIdSdlgoFailureDeprecated(t *testing.T) {
747 errMsg := "expected Sdlgo error"
748 errMsgExpected := "expected Sdlgo error"
749 w, sdlInstanceMock := initSdlInstanceMock()
750 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
752 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
754 e := errors.New(errMsg)
755 var ret map[string]interface{}
756 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
757 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
758 getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
761 assert.IsType(t, &common.InternalError{}, er)
762 assert.EqualValues(t, errMsgExpected, er.Error())
765 func TestGetCellByIdDeprecated(t *testing.T) {
768 w, sdlInstanceMock := initSdlInstanceMock()
769 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
770 cellData, err := proto.Marshal(&cellEntity)
772 t.Errorf("#rNibReader_test.TestGetCellById - Failed to marshal Cell entity. Error: %v", err)
775 key, rNibErr := common.ValidateAndBuildCellIdKey(cellId)
777 t.Errorf("#rNibReader_test.TestGetCellById - failed to validate key parameter")
779 ret := map[string]interface{}{key: string(cellData)}
780 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
781 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
783 assert.NotNil(t, cell)
784 assert.Equal(t, cell.Type, entities.Cell_LTE_CELL)
785 assert.NotNil(t, cell.GetServedCellInfo())
786 assert.Equal(t, cell.GetServedCellInfo().GetPci(), pci)
789 func TestGetCellByIdNotFoundFailureEnbDeprecated(t *testing.T) {
791 w, sdlInstanceMock := initSdlInstanceMock()
793 var ret map[string]interface{}
794 key, rNibErr := common.ValidateAndBuildCellIdKey(cellId)
796 t.Errorf("#rNibReader_test.TestGetCellByIdNotFoundFailure - failed to validate key parameter")
798 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
799 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
802 assert.IsType(t, &common.ResourceNotFoundError{}, er)
803 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: CELL:bbbb", er.Error())
806 func TestGetCellByIdNotFoundFailureGnbDeprecated(t *testing.T) {
808 w, sdlInstanceMock := initSdlInstanceMock()
810 var ret map[string]interface{}
811 key, rNibErr := common.ValidateAndBuildNrCellIdKey(cellId)
813 t.Errorf("#rNibReader_test.TestGetCellByIdNotFoundFailure - failed to validate key parameter")
815 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
816 cell, er := w.GetCellById(entities.Cell_NR_CELL, cellId)
819 assert.IsType(t, &common.ResourceNotFoundError{}, er)
820 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: NRCELL:bbbb", er.Error())
823 func TestGetCellByIdTypeValidationFailureDeprecated(t *testing.T) {
825 w, _ := initSdlInstanceMock()
826 cell, er := w.GetCellById(5, cellId)
829 assert.IsType(t, &common.ValidationError{}, er)
830 assert.EqualValues(t, "#rNibReader.GetCellById - invalid cell type: 5", er.Error())
833 func TestGetCellByIdValidationFailureGnbDeprecated(t *testing.T) {
835 w, _ := initSdlInstanceMock()
836 cell, er := w.GetCellById(entities.Cell_NR_CELL, cellId)
839 assert.IsType(t, &common.ValidationError{}, er)
840 assert.EqualValues(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", er.Error())
843 func TestGetCellByIdValidationFailureEnbDeprecated(t *testing.T) {
845 w, _ := initSdlInstanceMock()
846 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
849 assert.IsType(t, &common.ValidationError{}, er)
850 assert.EqualValues(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", er.Error())
853 func TestGetRanLoadInformationDeprecated(t *testing.T) {
855 w, sdlInstanceMock := initSdlInstanceMock()
856 loadInfo := generateRanLoadInformationDeprecated()
858 data, err := proto.Marshal(loadInfo)
860 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
862 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
864 t.Errorf("#rNibReader_test.TestGetRanLoadInformationNotFoundFailure - failed to validate key parameter")
866 ret := map[string]interface{}{redisKey: string(data)}
867 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
868 getLoadInfo, er := w.GetRanLoadInformation(name)
870 assert.NotNil(t, getLoadInfo)
871 expected, err := json.Marshal(loadInfo)
873 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
875 actual, err := json.Marshal(getLoadInfo)
877 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
879 assert.EqualValues(t, expected, actual)
882 func TestGetRanLoadInformationValidationFailureDeprecated(t *testing.T) {
884 w, _ := initSdlInstanceMock()
885 getNb, er := w.GetRanLoadInformation(name)
888 assert.IsType(t, &common.ValidationError{}, er)
889 assert.EqualValues(t, "#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received", er.Error())
892 func TestGetRanLoadInformationNotFoundFailureDeprecated(t *testing.T) {
894 w, sdlInstanceMock := initSdlInstanceMock()
896 var ret map[string]interface{}
897 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
899 t.Errorf("#rNibReader_test.TestGetRanLoadInformationNotFoundFailure - failed to validate key parameter")
901 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
902 getNb, er := w.GetRanLoadInformation(name)
905 assert.IsType(t, &common.ResourceNotFoundError{}, er)
906 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.RanLoadInformation not found. Key: LOAD:name", er.Error())
909 func TestGetRanLoadInformationUnmarshalFailureDeprecated(t *testing.T) {
911 w, sdlInstanceMock := initSdlInstanceMock()
913 ret := make(map[string]interface{}, 1)
914 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
916 t.Errorf("#rNibReader_test.TestGetRanLoadInformationUnmarshalFailure - failed to validate key parameter")
918 ret[redisKey] = "data"
919 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
920 getNb, er := w.GetRanLoadInformation(name)
923 assert.IsType(t, &common.InternalError{}, er)
924 assert.Contains(t, er.Error(), "proto:")
927 func TestGetRanLoadInformationSdlgoFailureDeprecated(t *testing.T) {
929 errMsg := "expected Sdlgo error"
930 errMsgExpected := "expected Sdlgo error"
931 w, sdlInstanceMock := initSdlInstanceMock()
932 e := errors.New(errMsg)
933 var ret map[string]interface{}
934 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
936 t.Errorf("#rNibReader_test.TestGetRanLoadInformationSdlgoFailure - failed to validate key parameter")
938 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
939 getNb, er := w.GetRanLoadInformation(name)
942 assert.IsType(t, &common.InternalError{}, er)
943 assert.EqualValues(t, errMsgExpected, er.Error())
946 func generateCellLoadInformationDeprecated() *entities.CellLoadInformation {
947 cellLoadInformation := entities.CellLoadInformation{}
949 cellLoadInformation.CellId = "123"
951 ulInterferenceOverloadIndication := entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE
952 cellLoadInformation.UlInterferenceOverloadIndications = []entities.UlInterferenceOverloadIndication{ulInterferenceOverloadIndication}
954 ulHighInterferenceInformation := entities.UlHighInterferenceInformation{
956 UlHighInterferenceIndication: "xxx",
959 cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation}
961 cellLoadInformation.RelativeNarrowbandTxPower = &entities.RelativeNarrowbandTxPower{
963 RntpThreshold: entities.RntpThreshold_NEG_4,
964 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
966 PdcchInterferenceImpact: 2,
967 EnhancedRntp: &entities.EnhancedRntp{
968 EnhancedRntpBitmap: "xxx",
969 RntpHighPowerThreshold: entities.RntpThreshold_NEG_2,
970 EnhancedRntpStartTime: &entities.StartTime{StartSfn: 500, StartSubframeNumber: 5},
974 cellLoadInformation.AbsInformation = &entities.AbsInformation{
975 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
976 AbsPatternInfo: "xxx",
977 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
978 MeasurementSubset: "xxx",
981 cellLoadInformation.InvokeIndication = entities.InvokeIndication_ABS_INFORMATION
983 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = &entities.ExtendedUlInterferenceOverloadInfo{
984 AssociatedSubframes: "xxx",
985 ExtendedUlInterferenceOverloadIndications: cellLoadInformation.UlInterferenceOverloadIndications,
988 compInformationItem := &entities.CompInformationItem{
989 CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "789", CompHypothesis: "xxx"}},
993 cellLoadInformation.CompInformation = &entities.CompInformation{
994 CompInformationItems: []*entities.CompInformationItem{compInformationItem},
995 CompInformationStartTime: &entities.StartTime{StartSfn: 123, StartSubframeNumber: 456},
998 cellLoadInformation.DynamicDlTransmissionInformation = &entities.DynamicDlTransmissionInformation{
999 State: entities.NaicsState_NAICS_ACTIVE,
1000 TransmissionModes: "xxx",
1002 PAList: []entities.PA{entities.PA_DB_NEG_3},
1005 return &cellLoadInformation
1008 func generateRanLoadInformationDeprecated() *entities.RanLoadInformation {
1009 ranLoadInformation := entities.RanLoadInformation{}
1011 ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
1013 cellLoadInformation := generateCellLoadInformationDeprecated()
1014 ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
1016 return &ranLoadInformation
1019 func TestGetE2TInstanceSuccessDeprecated(t *testing.T) {
1020 address := "10.10.2.15:9800"
1021 redisKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
1023 if validationErr != nil {
1024 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to build E2T Instance key. Error: %v", validationErr)
1027 w, sdlInstanceMock := initSdlInstanceMock()
1029 e2tInstance := generateE2tInstanceDeprecated(address)
1030 data, err := json.Marshal(e2tInstance)
1033 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to marshal E2tInstance entity. Error: %v", err)
1037 ret := map[string]interface{}{redisKey: string(data)}
1038 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
1040 res, rNibErr := w.GetE2TInstance(address)
1041 assert.Nil(t, rNibErr)
1042 assert.Equal(t, e2tInstance, res)
1045 func TestUnmarshalDeprecated(t *testing.T) {
1046 e2tInstance := generateE2tInstanceDeprecated("10.0.2.15:5555")
1047 marshaled, _ := json.Marshal(e2tInstance)
1048 m := map[string]interface{}{
1049 "whatever": string(marshaled),
1051 var entity entities.E2TInstance
1052 err := json.Unmarshal([]byte(m["whatever"].(string)), &entity)
1056 func TestGetE2TInstanceEmptyAddressFailureDeprecated(t *testing.T) {
1057 w, _ := initSdlInstanceMock()
1058 res, err := w.GetE2TInstance("")
1059 assert.NotNil(t, err)
1060 assert.IsType(t, &common.ValidationError{}, err)
1064 func TestGetE2TInstanceSdlErrorDeprecated(t *testing.T) {
1065 address := "10.10.2.15:9800"
1066 redisKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
1068 if validationErr != nil {
1069 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to build E2T Instance key. Error: %v", validationErr)
1072 w, sdlInstanceMock := initSdlInstanceMock()
1074 expectedErr := errors.New("expected error")
1075 var ret map[string]interface{}
1076 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, expectedErr)
1078 res, rNibErr := w.GetE2TInstance(address)
1079 assert.NotNil(t, rNibErr)
1083 func generateE2tInstanceDeprecated(address string) *entities.E2TInstance {
1084 e2tInstance := entities.NewE2TInstance(address, "")
1085 e2tInstance.AssociatedRanList = []string{"test1", "test2"}
1086 e2tInstance.DeletionTimestamp = time.Now().UnixNano()
1090 func TestGetE2TAddressesSdlErrorDeprecated(t *testing.T) {
1091 w, sdlInstanceMock := initSdlInstanceMock()
1093 expectedErr := errors.New("expected error")
1094 var ret map[string]interface{}
1095 sdlInstanceMock.On("Get", []string{E2TAddressesKey}).Return(ret, expectedErr)
1097 res, rNibErr := w.GetE2TAddresses()
1098 assert.NotNil(t, rNibErr)
1102 func TestGetE2TAddressesSuccessDeprecated(t *testing.T) {
1103 address := "10.10.2.15:9800"
1104 w, sdlInstanceMock := initSdlInstanceMock()
1106 e2tAddresses := []string{address}
1107 data, err := json.Marshal(e2tAddresses)
1110 t.Errorf("#rNibReader_test.TestGetE2TInfoListSuccess - Failed to marshal E2TInfoList. Error: %v", err)
1114 ret := map[string]interface{}{E2TAddressesKey: string(data)}
1115 sdlInstanceMock.On("Get", []string{E2TAddressesKey}).Return(ret, e)
1117 res, rNibErr := w.GetE2TAddresses()
1118 assert.Nil(t, rNibErr)
1119 assert.Equal(t, e2tAddresses, res)
1122 func TestGetE2TInstancesSuccessDeprecated(t *testing.T) {
1123 address := "10.10.2.15:9800"
1124 address2 := "10.10.2.16:9800"
1125 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1126 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1128 w, sdlInstanceMock := initSdlInstanceMock()
1130 e2tInstance1 := generateE2tInstanceDeprecated(address)
1131 e2tInstance2 := generateE2tInstanceDeprecated(address2)
1133 data1, _ := json.Marshal(e2tInstance1)
1134 data2, _ := json.Marshal(e2tInstance2)
1137 ret := map[string]interface{}{redisKey: string(data1), redisKey2: string(data2)}
1138 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(ret, e)
1140 res, err := w.GetE2TInstances([]string{address, address2})
1142 assert.Equal(t, []*entities.E2TInstance{e2tInstance1, e2tInstance2}, res)
1145 func TestGetE2TInstancesUnmarhalPartialSuccessDeprecated(t *testing.T) {
1146 address := "10.10.2.15:9800"
1147 address2 := "10.10.2.16:9800"
1148 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1149 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1151 w, sdlInstanceMock := initSdlInstanceMock()
1153 e2tInstance1 := generateE2tInstanceDeprecated(address)
1154 data1, _ := json.Marshal(e2tInstance1)
1157 ret := map[string]interface{}{redisKey: string(data1), redisKey2: "abc"}
1158 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(ret, e)
1160 res, err := w.GetE2TInstances([]string{address, address2})
1162 assert.Equal(t, []*entities.E2TInstance{e2tInstance1}, res)
1165 func TestGetE2TInstancesSdlFailureDeprecated(t *testing.T) {
1166 address := "10.10.2.15:9800"
1167 address2 := "10.10.2.16:9800"
1168 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1169 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1171 w, sdlInstanceMock := initSdlInstanceMock()
1173 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(map[string]interface{}{}, fmt.Errorf(""))
1174 _, err := w.GetE2TInstances([]string{address, address2})
1175 assert.IsType(t, &common.InternalError{}, err)
1178 func TestGetE2TInstancesEmptyDataDeprecated(t *testing.T) {
1179 address := "10.10.2.15:9800"
1180 address2 := "10.10.2.16:9800"
1181 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1182 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1184 w, sdlInstanceMock := initSdlInstanceMock()
1186 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(map[string]interface{}{}, nil)
1187 _, err := w.GetE2TInstances([]string{address, address2})
1188 assert.IsType(t, &common.ResourceNotFoundError{}, err)
1191 func TestGetGeneralConfigurationDeprecated(t *testing.T) {
1193 key := common.BuildGeneralConfigurationKey()
1194 w, sdlInstanceMock := initSdlInstanceMock()
1196 configurationData := "{\"enableRic\":true}"
1197 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{key: configurationData}, nil)
1199 res, rNibErr := w.GetGeneralConfiguration()
1200 assert.Nil(t, rNibErr)
1201 assert.Equal(t, true, res.EnableRic)
1204 func TestGetGeneralConfigurationNotFoundDeprecated(t *testing.T) {
1206 key := common.BuildGeneralConfigurationKey()
1207 w, sdlInstanceMock := initSdlInstanceMock()
1209 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{}, nil)
1211 _, rNibErr := w.GetGeneralConfiguration()
1213 assert.NotNil(t, rNibErr)
1214 assert.Equal(t, "#rNibReader.getByKeyAndUnmarshalJson - entity of type *entities.GeneralConfiguration not found. Key: GENERAL", rNibErr.Error())
1217 func TestGetGeneralConfigurationSdlFailureDeprecated(t *testing.T) {
1219 key := common.BuildGeneralConfigurationKey()
1220 w, sdlInstanceMock := initSdlInstanceMock()
1222 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{}, fmt.Errorf("sdl error"))
1224 _, rNibErr := w.GetGeneralConfiguration()
1226 assert.NotNil(t, rNibErr)
1228 assert.Equal(t, "sdl error", rNibErr.Error())
1231 func TestGetGeneralConfigurationUnmarshalErrorDeprecated(t *testing.T) {
1233 key := common.BuildGeneralConfigurationKey()
1234 w, sdlInstanceMock := initSdlInstanceMock()
1236 configurationData := "{\"enableRic :true}"
1237 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{key: configurationData}, nil)
1239 _, rNibErr := w.GetGeneralConfiguration()
1241 assert.NotNil(t, rNibErr)
1242 assert.Equal(t, rNibErr.Error(), "unexpected end of JSON input")
1247 //func TestGetEnbIntegDeprecated(t *testing.T){
1248 // name := "nameEnb1"
1249 // Init("namespace", 1)
1250 // w := GetRNibReader()
1251 // nb, err := w.GetNodeb(name)
1255 // fmt.Printf("#TestGetEnbInteg - responding node type: %v\n", nb)
1259 //func TestGetEnbCellsIntegDeprecated(t *testing.T){
1260 // name := "nameEnb1"
1261 // Init("namespace", 1)
1262 // w := GetRNibReader()
1263 // cells, err := w.GetCellList(name)
1266 // } else if cells != nil{
1267 // for _, cell := range cells.GetServedCellInfos().ServedCells{
1268 // fmt.Printf("responding node type Cell: %v\n", *cell)
1273 //func TestGetGnbIntegDeprecated(t *testing.T){
1274 // name := "nameGnb1"
1275 // Init("namespace", 1)
1276 // w := GetRNibReader()
1277 // nb, err := w.GetNodeb(name)
1281 // fmt.Printf("#TestGetGnbInteg - responding node type: %v\n", nb)
1285 //func TestGetGnbCellsIntegDeprecated(t *testing.T){
1286 // name := "nameGnb1"
1287 // Init("namespace", 1)
1288 // w := GetRNibReader()
1289 // cells, err := w.GetCellList(name)
1292 // } else if cells != nil{
1293 // for _, cell := range cells.GetServedNrCells().ServedCells{
1294 // fmt.Printf("responding node type NR Cell: %v\n", *cell)
1299 //func TestGetListEnbIdsIntegDeprecated(t *testing.T) {
1300 // Init("namespace", 1)
1301 // w := GetRNibReader()
1302 // ids, err := w.GetListEnbIds()
1306 // for _, id := range ids{
1307 // fmt.Printf("#TestGetListEnbIdsInteg - ENB ID: %s\n", id)
1312 //func TestGetListGnbIdsIntegDeprecated(t *testing.T) {
1313 // Init("namespace", 1)
1314 // w := GetRNibReader()
1315 // ids, err := w.GetListGnbIds()
1319 // for _, id := range ids{
1320 // fmt.Printf("#TestGetListGnbIdsInteg - GNB ID: %s\n", id)
1325 //func TestGetCountGnbListIntegDeprecated(t *testing.T) {
1326 // Init("namespace", 1)
1327 // w := GetRNibReader()
1328 // count, err := w.GetCountGnbList()
1332 // fmt.Printf("#TestGetCountGnbListInteg - count Gnb list: %d\n", count)
1336 //func TestGetGnbCellIntegDeprecated(t *testing.T){
1337 // name := "nameGnb7"
1339 // Init("namespace", 1)
1340 // w := GetRNibReader()
1341 // cell, err := w.GetCell(name, uint32(pci))
1344 // } else if cell != nil{
1345 // fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
1349 //func TestGetEnbCellIntegDeprecated(t *testing.T) {
1350 // name := "nameEnb1"
1352 // Init("namespace", 1)
1353 // w := GetRNibReader()
1354 // cell, err := w.GetCell(name, uint32(pci))
1357 // } else if cell != nil {
1358 // fmt.Printf("responding node type LTE Cell: %v\n", cell.GetServedCellInfo())
1362 //func TestGetEnbCellByIdIntegDeprecated(t *testing.T){
1363 // Init("namespace", 1)
1364 // w := GetRNibReader()
1365 // cell, err := w.GetCellById(entities.Cell_NR_CELL, "45d")
1368 // } else if cell != nil{
1369 // fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
1373 //func TestGetListNbIdsIntegDeprecated(t *testing.T) {
1374 // Init("e2Manager", 1)
1375 // w := GetRNibReader()
1376 // ids, err := w.GetListNodebIds()
1380 // for _, id := range ids{
1381 // fmt.Printf("#TestGetListGnbIdsInteg - NB ID: %s\n", id)
1386 //func TestGetRanLoadInformationIntegDeprecated(t *testing.T){
1387 // Init("e2Manager", 1)
1388 // w := GetRNibReader()
1389 // ranLoadInformation, err := w.GetRanLoadInformation("ran_integ")
1391 // t.Errorf("#rNibReader_test.TestGetRanLoadInformationInteg - Failed to get RanLoadInformation entity. Error: %v", err)
1393 // assert.NotNil(t, ranLoadInformation)
1394 // fmt.Printf("#rNibReader_test.TestGetRanLoadInformationInteg - GNB ID: %s\n", ranLoadInformation)
1397 //func TestGetE2TInstancesIntegDeprecated(t *testing.T) {
1398 // db := sdlgo.NewDatabase()
1399 // sdl := sdlgo.NewSdlInstance("e2Manager", db)
1400 // rnibReader := GetRNibReader(sdl)
1401 // e2tInstances, _ := rnibReader.GetE2TInstances([]string{"e2t.att.com:38000","whatever"})
1402 // assert.Len(t, e2tInstances, 1)