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"
34 //Deprecated: This file will be removed in a future release when SDL SdlInstance usage will be replaced by SynchStorage.
35 //Valid RNIB Reader unit tests are in rNibReader_test.go file, rNibReaderDeprecated_test.go will exist until SdlInstance
36 //usage will be removed from the RNIB source code.
38 func initSdlInstanceMock() (w RNibReader, sdlInstanceMock *MockSdlInstance) {
39 sdlInstanceMock = new(MockSdlInstance)
40 w = GetRNibReader(sdlInstanceMock)
44 func TestGetNodeBDeprecated(t *testing.T) {
46 w, sdlInstanceMock := initSdlInstanceMock()
47 nb := entities.NodebInfo{}
48 nb.ConnectionStatus = 1
52 cell := entities.ServedCellInfo{Tac: "tac"}
53 enb.ServedCells = []*entities.ServedCellInfo{&cell}
54 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
56 data, err := proto.Marshal(&nb)
58 t.Errorf("#rNibReader_test.TestGetNb - Failed to marshal ENB instance. Error: %v", err)
60 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
62 t.Errorf("#rNibReader_test.TestGetNodeB - failed to validate key parameter")
64 ret := map[string]interface{}{redisKey: string(data)}
65 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
66 getNb, er := w.GetNodeb(name)
68 assert.Equal(t, getNb.Ip, nb.Ip)
69 assert.Equal(t, getNb.Port, nb.Port)
70 assert.Equal(t, getNb.ConnectionStatus, nb.ConnectionStatus)
71 assert.Len(t, getNb.GetEnb().GetServedCells(), 1)
72 assert.Equal(t, getNb.GetEnb().GetServedCells()[0].Tac, nb.GetEnb().GetServedCells()[0].Tac)
75 func TestGetNodeBNotFoundFailureDeprecated(t *testing.T) {
77 w, sdlInstanceMock := initSdlInstanceMock()
79 var ret map[string]interface{}
80 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
82 t.Errorf("#rNibReader_test.TestGetNodeBNotFoundFailure - failed to validate key parameter")
84 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
85 getNb, er := w.GetNodeb(name)
88 assert.IsType(t, &common.ResourceNotFoundError{}, er)
89 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: RAN:name", er.Error())
92 func TestGetNodeBUnmarshalFailureDeprecated(t *testing.T) {
94 w, sdlInstanceMock := initSdlInstanceMock()
96 ret := make(map[string]interface{}, 1)
97 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
99 t.Errorf("#rNibReader_test.TestGetNodeBUnmarshalFailure - failed to validate key parameter")
101 ret[redisKey] = "data"
102 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
103 getNb, er := w.GetNodeb(name)
106 assert.IsType(t, &common.InternalError{}, er)
107 assert.Contains(t, er.Error(), "proto:")
110 func TestGetNodeBSdlgoFailureDeprecated(t *testing.T) {
112 errMsg := "expected Sdlgo error"
113 errMsgExpected := "expected Sdlgo error"
114 w, sdlInstanceMock := initSdlInstanceMock()
115 e := errors.New(errMsg)
116 var ret map[string]interface{}
117 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
119 t.Errorf("#rNibReader_test.TestGetNodeBSdlgoFailure - failed to validate key parameter")
121 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
122 getNb, er := w.GetNodeb(name)
125 assert.IsType(t, &common.InternalError{}, er)
126 assert.EqualValues(t, errMsgExpected, er.Error())
129 func TestGetNodeBCellsListEnbDeprecated(t *testing.T) {
131 w, sdlInstanceMock := initSdlInstanceMock()
132 nb := entities.NodebInfo{}
133 nb.ConnectionStatus = 1
136 enb := entities.Enb{}
137 cell := entities.ServedCellInfo{Tac: "tac"}
138 enb.ServedCells = []*entities.ServedCellInfo{&cell}
139 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
141 data, err := proto.Marshal(&nb)
143 t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal ENB instance. Error: %v", err)
145 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
147 t.Errorf("#rNibReader_test.TestGetNodeBCellsListEnb - failed to validate key parameter")
149 ret := map[string]interface{}{redisKey: string(data)}
150 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
151 cells, er := w.GetCellList(name)
153 assert.NotNil(t, cells)
154 assert.Len(t, cells.GetServedCellInfos().GetServedCells(), 1)
155 retCell := cells.GetServedCellInfos().GetServedCells()[0]
156 assert.Equal(t, retCell.Tac, "tac")
159 func TestGetNodeBCellsListGnbDeprecated(t *testing.T) {
161 w, sdlInstanceMock := initSdlInstanceMock()
162 nb := entities.NodebInfo{}
163 nb.ConnectionStatus = 1
166 nb.NodeType = entities.Node_GNB
167 gnb := entities.Gnb{}
168 cell := entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{NrPci: 10}}
169 gnb.ServedNrCells = []*entities.ServedNRCell{&cell}
170 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
172 data, err := proto.Marshal(&nb)
174 t.Errorf("#rNibReader_test.GetNodeBCellsList - Failed to marshal GNB instance. Error: %v", err)
176 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
178 t.Errorf("#rNibReader_test.TestGetNodeBCellsListGnb - failed to validate key parameter")
180 ret := map[string]interface{}{redisKey: string(data)}
181 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
182 cells, er := w.GetCellList(name)
184 assert.NotNil(t, cells)
185 assert.Len(t, cells.GetServedNrCells().GetServedCells(), 1)
186 retCell := cells.GetServedNrCells().GetServedCells()[0]
187 assert.Equal(t, retCell.GetServedNrCellInformation().GetNrPci(), uint32(10))
190 func TestGetNodeBCellsListNodeUnmarshalFailureDeprecated(t *testing.T) {
192 w, sdlInstanceMock := initSdlInstanceMock()
194 ret := make(map[string]interface{}, 1)
195 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
197 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNodeUnmarshalFailure - failed to validate key parameter")
199 ret[redisKey] = "data"
200 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
201 cells, er := w.GetCellList(name)
204 assert.IsType(t, &common.InternalError{}, er)
205 assert.Contains(t, er.Error(), "proto:")
208 func TestGetNodeBCellsListNodeNotFoundFailureDeprecated(t *testing.T) {
210 w, sdlInstanceMock := initSdlInstanceMock()
212 var ret map[string]interface{}
213 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
215 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNodeNotFoundFailure - failed to validate key parameter")
217 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
218 cells, er := w.GetCellList(name)
221 assert.IsType(t, &common.ResourceNotFoundError{}, er)
222 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: RAN:name", er.Error())
225 func TestGetNodeBCellsListNotFoundFailureEnbDeprecated(t *testing.T) {
227 w, sdlInstanceMock := initSdlInstanceMock()
228 nb := entities.NodebInfo{}
229 nb.ConnectionStatus = 1
232 enb := entities.Enb{}
233 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
235 data, err := proto.Marshal(&nb)
237 t.Errorf("#rNibReader_test.TestGetNbCellsListNotFoundFailure - Failed to marshal ENB instance. Error: %v", err)
239 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
241 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureEnb - failed to validate key parameter")
243 ret := map[string]interface{}{redisKey: string(data)}
244 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
245 _, er := w.GetCellList(name)
247 assert.EqualValues(t, "#rNibReader.GetCellList - served cells not found. Responding node RAN name: name.", er.Error())
250 func TestGetNodeBCellsListNotFoundFailureGnbDeprecated(t *testing.T) {
252 w, sdlInstanceMock := initSdlInstanceMock()
253 nb := entities.NodebInfo{}
254 nb.ConnectionStatus = 1
257 gnb := entities.Gnb{}
258 nb.Configuration = &entities.NodebInfo_Gnb{Gnb: &gnb}
260 data, err := proto.Marshal(&nb)
262 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureGnb - Failed to marshal ENB instance. Error: %v", err)
264 redisKey, rNibErr := common.ValidateAndBuildNodeBNameKey(name)
266 t.Errorf("#rNibReader_test.TestGetNodeBCellsListNotFoundFailureGnb - failed to validate key parameter")
268 ret := map[string]interface{}{redisKey: string(data)}
269 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
270 _, er := w.GetCellList(name)
272 assert.EqualValues(t, "#rNibReader.GetCellList - served cells not found. Responding node RAN name: name.", er.Error())
275 func TestGetListGnbIdsUnmarshalFailureDeprecated(t *testing.T) {
276 w, sdlInstanceMock := initSdlInstanceMock()
278 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{"data"}, e)
279 ids, er := w.GetListGnbIds()
282 assert.IsType(t, &common.InternalError{}, er)
283 assert.Contains(t, er.Error(), "proto:")
286 func TestGetListGnbIdsSdlgoFailureDeprecated(t *testing.T) {
287 errMsg := "expected Sdlgo error"
288 errMsgExpected := "expected Sdlgo error"
289 w, sdlInstanceMock := initSdlInstanceMock()
290 e := errors.New(errMsg)
292 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(data, e)
293 ids, er := w.GetListGnbIds()
296 assert.IsType(t, &common.InternalError{}, er)
297 assert.EqualValues(t, errMsgExpected, er.Error())
300 func TestGetListNodesIdsGnbSdlgoFailureDeprecated(t *testing.T) {
301 w, sdlInstanceMock := initSdlInstanceMock()
306 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
308 data, err := proto.Marshal(nbIdentity)
310 t.Errorf("#rNibReader_test.TestGetListNodesIdsGnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
312 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data)}, nilError)
314 errMsg := "expected Sdlgo error"
315 errMsgExpected := "expected Sdlgo error"
316 expectedError := errors.New(errMsg)
318 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(nilData, expectedError)
320 ids, er := w.GetListNodebIds()
323 assert.IsType(t, &common.InternalError{}, er)
324 assert.EqualValues(t, errMsgExpected, er.Error())
327 func TestGetListNodesIdsEnbSdlgoFailureDeprecated(t *testing.T) {
328 w, sdlInstanceMock := initSdlInstanceMock()
333 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
335 data, err := proto.Marshal(nbIdentity)
337 t.Errorf("#rNibReader_test.TestGetListNodesIdsEnbSdlgoFailure - Failed to marshal nodeb identity entity. Error: %v", err)
339 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, nilError)
341 errMsg := "expected Sdlgo error"
342 errMsgExpected := "expected Sdlgo error"
343 expectedError := errors.New(errMsg)
345 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(nilData, expectedError)
347 ids, er := w.GetListNodebIds()
350 assert.IsType(t, &common.InternalError{}, er)
351 assert.EqualValues(t, errMsgExpected, er.Error())
354 func TestGetListNodesIdsSuccessDeprecated(t *testing.T) {
355 w, sdlInstanceMock := initSdlInstanceMock()
361 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
362 data, err := proto.Marshal(nbIdentity)
364 t.Errorf("#rNibReader_test.TestGetListNodesIdsSuccess - Failed to marshal nodeb identity entity. Error: %v", err)
370 nbIdentity1 := &entities.NbIdentity{InventoryName: name1, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId1, NbId: nbId1}}
371 data1, err := proto.Marshal(nbIdentity1)
373 t.Errorf("#rNibReader_test.TestGetListNodesIdsSuccess - Failed to marshal nodeb identity entity. Error: %v", err)
376 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, nilError)
377 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data1)}, nilError)
379 ids, er := w.GetListNodebIds()
381 assert.NotNil(t, ids)
382 assert.Len(t, ids, 2)
385 func TestGetListEnbIdsUnmarshalFailureDeprecated(t *testing.T) {
386 w, sdlInstanceMock := initSdlInstanceMock()
388 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{"data"}, e)
389 ids, er := w.GetListEnbIds()
392 assert.IsType(t, &common.InternalError{}, er)
393 assert.Contains(t, er.Error(), "proto:")
396 func TestGetListEnbIdsOneIdDeprecated(t *testing.T) {
400 w, sdlInstanceMock := initSdlInstanceMock()
401 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
403 data, err := proto.Marshal(nbIdentity)
405 t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
407 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{string(data)}, e)
408 ids, er := w.GetListEnbIds()
410 assert.Len(t, ids, 1)
411 assert.Equal(t, (ids)[0].GetInventoryName(), name)
412 assert.Equal(t, (ids)[0].GetGlobalNbId().GetPlmnId(), nbIdentity.GetGlobalNbId().GetPlmnId())
413 assert.Equal(t, (ids)[0].GetGlobalNbId().GetNbId(), nbIdentity.GetGlobalNbId().GetNbId())
416 func TestGetListEnbIdsNoIdsDeprecated(t *testing.T) {
417 w, sdlInstanceMock := initSdlInstanceMock()
419 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return([]string{}, e)
420 ids, er := w.GetListEnbIds()
422 assert.Len(t, ids, 0)
425 func TestGetListEnbIdsDeprecated(t *testing.T) {
430 w, sdlInstanceMock := initSdlInstanceMock()
431 idsData := make([]string, listSize)
432 idsEntities := make([]*entities.NbIdentity, listSize)
433 for i := 0; i < listSize; i++ {
434 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
435 data, err := proto.Marshal(nbIdentity)
437 t.Errorf("#rNibReader_test.TestGetListEnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
439 idsData[i] = string(data)
440 idsEntities[i] = nbIdentity
443 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(idsData, e)
444 ids, er := w.GetListEnbIds()
446 assert.Len(t, ids, listSize)
447 for i, id := range ids {
448 assert.Equal(t, id.GetInventoryName(), name)
449 assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
450 assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
454 func TestGetListGnbIdsOneIdDeprecated(t *testing.T) {
458 w, sdlInstanceMock := initSdlInstanceMock()
459 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
461 data, err := proto.Marshal(nbIdentity)
463 t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
465 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{string(data)}, e)
466 ids, er := w.GetListGnbIds()
468 assert.Len(t, ids, 1)
469 assert.Equal(t, (ids)[0].GetInventoryName(), name)
470 assert.Equal(t, (ids)[0].GetGlobalNbId().GetPlmnId(), nbIdentity.GetGlobalNbId().GetPlmnId())
471 assert.Equal(t, (ids)[0].GetGlobalNbId().GetNbId(), nbIdentity.GetGlobalNbId().GetNbId())
474 func TestGetListGnbIdsNoIdsDeprecated(t *testing.T) {
475 w, sdlInstanceMock := initSdlInstanceMock()
477 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return([]string{}, e)
478 ids, er := w.GetListGnbIds()
480 assert.Len(t, ids, 0)
483 func TestGetListGnbIdsDeprecated(t *testing.T) {
488 w, sdlInstanceMock := initSdlInstanceMock()
489 idsData := make([]string, listSize)
490 idsEntities := make([]*entities.NbIdentity, listSize)
491 for i := 0; i < listSize; i++ {
492 nbIdentity := &entities.NbIdentity{InventoryName: name, GlobalNbId: &entities.GlobalNbId{PlmnId: string(plmnId + i), NbId: string(nbId + i)}}
493 data, err := proto.Marshal(nbIdentity)
495 t.Errorf("#rNibReader_test.TestGetListGnbIds - Failed to marshal nodeb identity entity. Error: %v", err)
497 idsData[i] = string(data)
498 idsEntities[i] = nbIdentity
501 sdlInstanceMock.On("GetMembers", entities.Node_GNB.String()).Return(idsData, e)
502 ids, er := w.GetListGnbIds()
504 assert.Len(t, ids, listSize)
505 for i, id := range ids {
506 assert.Equal(t, id.GetInventoryName(), name)
507 assert.Equal(t, id.GetGlobalNbId().GetPlmnId(), idsEntities[i].GetGlobalNbId().GetPlmnId())
508 assert.Equal(t, id.GetGlobalNbId().GetNbId(), idsEntities[i].GetGlobalNbId().GetNbId())
512 func TestGetListEnbIdsSdlgoFailureDeprecated(t *testing.T) {
513 errMsg := "expected Sdlgo error"
514 errMsgExpected := "expected Sdlgo error"
515 w, sdlInstanceMock := initSdlInstanceMock()
516 e := errors.New(errMsg)
518 sdlInstanceMock.On("GetMembers", entities.Node_ENB.String()).Return(data, e)
519 ids, er := w.GetListEnbIds()
522 assert.IsType(t, &common.InternalError{}, er)
523 assert.EqualValues(t, errMsgExpected, er.Error())
526 func TestGetCountGnbListOneIdDeprecated(t *testing.T) {
527 w, sdlInstanceMock := initSdlInstanceMock()
529 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(1, e)
530 count, er := w.GetCountGnbList()
532 assert.Equal(t, count, 1)
535 func TestGetCountGnbListDeprecated(t *testing.T) {
536 w, sdlInstanceMock := initSdlInstanceMock()
538 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(3, e)
539 count, er := w.GetCountGnbList()
541 assert.Equal(t, count, 3)
544 func TestGetCountGnbListSdlgoFailureDeprecated(t *testing.T) {
545 errMsg := "expected Sdlgo error"
546 errMsgExpected := "expected Sdlgo error"
547 w, sdlInstanceMock := initSdlInstanceMock()
548 e := errors.New(errMsg)
550 sdlInstanceMock.On("GroupSize", entities.Node_GNB.String()).Return(count, e)
551 count, er := w.GetCountGnbList()
553 assert.Equal(t, 0, count)
554 assert.IsType(t, &common.InternalError{}, er)
555 assert.EqualValues(t, errMsgExpected, er.Error())
558 func TestGetCellDeprecated(t *testing.T) {
561 w, sdlInstanceMock := initSdlInstanceMock()
562 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
563 cellData, err := proto.Marshal(&cellEntity)
565 t.Errorf("#rNibReader_test.TestGetCell - Failed to marshal Cell entity. Error: %v", err)
568 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
570 t.Errorf("#rNibReader_test.TestGetCell - failed to validate key parameter")
572 ret := map[string]interface{}{key: string(cellData)}
573 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
574 cell, er := w.GetCell(name, pci)
576 assert.NotNil(t, cell)
577 assert.Equal(t, cell.Type, entities.Cell_LTE_CELL)
578 assert.NotNil(t, cell.GetServedCellInfo())
579 assert.Equal(t, cell.GetServedCellInfo().GetPci(), pci)
582 func TestGetCellNotFoundFailureDeprecated(t *testing.T) {
585 w, sdlInstanceMock := initSdlInstanceMock()
587 var ret map[string]interface{}
588 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
590 t.Errorf("#rNibReader_test.TestGetCellNotFoundFailure - failed to validate key parameter")
592 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
593 cell, er := w.GetCell(name, pci)
596 assert.IsType(t, &common.ResourceNotFoundError{}, er)
597 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: PCI:name:00", er.Error())
600 func TestGetCellUnmarshalFailureDeprecated(t *testing.T) {
603 w, sdlInstanceMock := initSdlInstanceMock()
605 ret := make(map[string]interface{}, 1)
606 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
608 t.Errorf("#rNibReader_test.TestGetCellUnmarshalFailure - failed to validate key parameter")
611 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
612 cell, er := w.GetCell(name, pci)
615 assert.IsType(t, &common.InternalError{}, er)
616 assert.Contains(t, er.Error(), "proto:")
619 func TestGetCellSdlgoFailureDeprecated(t *testing.T) {
622 errMsg := "expected Sdlgo error"
623 errMsgExpected := "expected Sdlgo error"
624 w, sdlInstanceMock := initSdlInstanceMock()
625 e := errors.New(errMsg)
626 var ret map[string]interface{}
627 key, rNibErr := common.ValidateAndBuildCellNamePciKey(name, pci)
629 t.Errorf("#rNibReader_test.TestGetCellSdlgoFailure - failed to validate key parameter")
631 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
632 cell, er := w.GetCell(name, pci)
635 assert.IsType(t, &common.InternalError{}, er)
636 assert.EqualValues(t, errMsgExpected, er.Error())
639 func TestGetNodebByIdDeprecated(t *testing.T) {
640 w, sdlInstanceMock := initSdlInstanceMock()
641 nb := entities.NodebInfo{NodeType: entities.Node_ENB}
642 nb.ConnectionStatus = 1
645 enb := entities.Enb{}
646 cell := entities.ServedCellInfo{Tac: "tac"}
647 enb.ServedCells = []*entities.ServedCellInfo{&cell}
648 nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
650 data, err := proto.Marshal(&nb)
652 t.Errorf("#rNibReader_test.TestGetNodebById - Failed to marshal ENB instance. Error: %v", err)
657 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
659 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
661 ret := map[string]interface{}{key: string(data)}
662 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
663 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
664 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
666 assert.Equal(t, getNb.Ip, nb.Ip)
667 assert.Equal(t, getNb.Port, nb.Port)
668 assert.Equal(t, getNb.ConnectionStatus, nb.ConnectionStatus)
669 assert.Len(t, getNb.GetEnb().GetServedCells(), 1)
670 assert.Equal(t, getNb.GetEnb().GetServedCells()[0].Tac, nb.GetEnb().GetServedCells()[0].Tac)
673 func TestGetNodebByIdNotFoundFailureEnbDeprecated(t *testing.T) {
676 w, sdlInstanceMock := initSdlInstanceMock()
678 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
680 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
682 var ret map[string]interface{}
683 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
684 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
685 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
688 assert.IsType(t, &common.ResourceNotFoundError{}, er)
689 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: ENB:02f829:4a952a0a", er.Error())
692 func TestGetNodebByIdNotFoundFailureGnbDeprecated(t *testing.T) {
695 w, sdlInstanceMock := initSdlInstanceMock()
697 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
699 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
701 var ret map[string]interface{}
702 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
703 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
704 getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
707 assert.IsType(t, &common.ResourceNotFoundError{}, er)
708 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.NodebInfo not found. Key: GNB:02f829:4a952a0a", er.Error())
711 func TestGetNodeByIdUnmarshalFailureDeprecated(t *testing.T) {
714 w, sdlInstanceMock := initSdlInstanceMock()
715 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_ENB.String(), plmnId, nbId)
717 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
720 ret := make(map[string]interface{}, 1)
722 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
723 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
724 getNb, er := w.GetNodebByGlobalNbId(entities.Node_ENB, globalNbId)
727 assert.IsType(t, &common.InternalError{}, er)
728 assert.Contains(t, er.Error(), "proto:")
731 func TestGetNodeByIdSdlgoFailureDeprecated(t *testing.T) {
734 errMsg := "expected Sdlgo error"
735 errMsgExpected := "expected Sdlgo error"
736 w, sdlInstanceMock := initSdlInstanceMock()
737 key, rNibErr := common.ValidateAndBuildNodeBIdKey(entities.Node_GNB.String(), plmnId, nbId)
739 t.Errorf("Failed to validate nodeb identity, plmnId: %s, nbId: %s", plmnId, nbId)
741 e := errors.New(errMsg)
742 var ret map[string]interface{}
743 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
744 globalNbId := &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
745 getNb, er := w.GetNodebByGlobalNbId(entities.Node_GNB, globalNbId)
748 assert.IsType(t, &common.InternalError{}, er)
749 assert.EqualValues(t, errMsgExpected, er.Error())
752 func TestGetCellByIdDeprecated(t *testing.T) {
755 w, sdlInstanceMock := initSdlInstanceMock()
756 cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: &entities.ServedCellInfo{Pci: pci}}}
757 cellData, err := proto.Marshal(&cellEntity)
759 t.Errorf("#rNibReader_test.TestGetCellById - Failed to marshal Cell entity. Error: %v", err)
762 key, rNibErr := common.ValidateAndBuildCellIdKey(cellId)
764 t.Errorf("#rNibReader_test.TestGetCellById - failed to validate key parameter")
766 ret := map[string]interface{}{key: string(cellData)}
767 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
768 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
770 assert.NotNil(t, cell)
771 assert.Equal(t, cell.Type, entities.Cell_LTE_CELL)
772 assert.NotNil(t, cell.GetServedCellInfo())
773 assert.Equal(t, cell.GetServedCellInfo().GetPci(), pci)
776 func TestGetCellByIdNotFoundFailureEnbDeprecated(t *testing.T) {
778 w, sdlInstanceMock := initSdlInstanceMock()
780 var ret map[string]interface{}
781 key, rNibErr := common.ValidateAndBuildCellIdKey(cellId)
783 t.Errorf("#rNibReader_test.TestGetCellByIdNotFoundFailure - failed to validate key parameter")
785 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
786 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
789 assert.IsType(t, &common.ResourceNotFoundError{}, er)
790 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: CELL:bbbb", er.Error())
793 func TestGetCellByIdNotFoundFailureGnbDeprecated(t *testing.T) {
795 w, sdlInstanceMock := initSdlInstanceMock()
797 var ret map[string]interface{}
798 key, rNibErr := common.ValidateAndBuildNrCellIdKey(cellId)
800 t.Errorf("#rNibReader_test.TestGetCellByIdNotFoundFailure - failed to validate key parameter")
802 sdlInstanceMock.On("Get", []string{key}).Return(ret, e)
803 cell, er := w.GetCellById(entities.Cell_NR_CELL, cellId)
806 assert.IsType(t, &common.ResourceNotFoundError{}, er)
807 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.Cell not found. Key: NRCELL:bbbb", er.Error())
810 func TestGetCellByIdTypeValidationFailureDeprecated(t *testing.T) {
812 w, _ := initSdlInstanceMock()
813 cell, er := w.GetCellById(5, cellId)
816 assert.IsType(t, &common.ValidationError{}, er)
817 assert.EqualValues(t, "#rNibReader.GetCellById - invalid cell type: 5", er.Error())
820 func TestGetCellByIdValidationFailureGnbDeprecated(t *testing.T) {
822 w, _ := initSdlInstanceMock()
823 cell, er := w.GetCellById(entities.Cell_NR_CELL, cellId)
826 assert.IsType(t, &common.ValidationError{}, er)
827 assert.EqualValues(t, "#utils.ValidateAndBuildNrCellIdKey - an empty cell id received", er.Error())
830 func TestGetCellByIdValidationFailureEnbDeprecated(t *testing.T) {
832 w, _ := initSdlInstanceMock()
833 cell, er := w.GetCellById(entities.Cell_LTE_CELL, cellId)
836 assert.IsType(t, &common.ValidationError{}, er)
837 assert.EqualValues(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", er.Error())
840 func TestGetRanLoadInformationDeprecated(t *testing.T) {
842 w, sdlInstanceMock := initSdlInstanceMock()
843 loadInfo := generateRanLoadInformationDeprecated()
845 data, err := proto.Marshal(loadInfo)
847 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
849 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
851 t.Errorf("#rNibReader_test.TestGetRanLoadInformationNotFoundFailure - failed to validate key parameter")
853 ret := map[string]interface{}{redisKey: string(data)}
854 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
855 getLoadInfo, er := w.GetRanLoadInformation(name)
857 assert.NotNil(t, getLoadInfo)
858 expected, err := json.Marshal(loadInfo)
860 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
862 actual, err := json.Marshal(getLoadInfo)
864 t.Errorf("#rNibReader_test.TestGetRanLoadInformation - Failed to marshal RanLoadInformation entity. Error: %v", err)
866 assert.EqualValues(t, expected, actual)
869 func TestGetRanLoadInformationValidationFailureDeprecated(t *testing.T) {
871 w, _ := initSdlInstanceMock()
872 getNb, er := w.GetRanLoadInformation(name)
875 assert.IsType(t, &common.ValidationError{}, er)
876 assert.EqualValues(t, "#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received", er.Error())
879 func TestGetRanLoadInformationNotFoundFailureDeprecated(t *testing.T) {
881 w, sdlInstanceMock := initSdlInstanceMock()
883 var ret map[string]interface{}
884 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
886 t.Errorf("#rNibReader_test.TestGetRanLoadInformationNotFoundFailure - failed to validate key parameter")
888 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
889 getNb, er := w.GetRanLoadInformation(name)
892 assert.IsType(t, &common.ResourceNotFoundError{}, er)
893 assert.EqualValues(t, "#rNibReader.getByKeyAndUnmarshal - entity of type *entities.RanLoadInformation not found. Key: LOAD:name", er.Error())
896 func TestGetRanLoadInformationUnmarshalFailureDeprecated(t *testing.T) {
898 w, sdlInstanceMock := initSdlInstanceMock()
900 ret := make(map[string]interface{}, 1)
901 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
903 t.Errorf("#rNibReader_test.TestGetRanLoadInformationUnmarshalFailure - failed to validate key parameter")
905 ret[redisKey] = "data"
906 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
907 getNb, er := w.GetRanLoadInformation(name)
910 assert.IsType(t, &common.InternalError{}, er)
911 assert.Contains(t, er.Error(), "proto:")
914 func TestGetRanLoadInformationSdlgoFailureDeprecated(t *testing.T) {
916 errMsg := "expected Sdlgo error"
917 errMsgExpected := "expected Sdlgo error"
918 w, sdlInstanceMock := initSdlInstanceMock()
919 e := errors.New(errMsg)
920 var ret map[string]interface{}
921 redisKey, rNibErr := common.ValidateAndBuildRanLoadInformationKey(name)
923 t.Errorf("#rNibReader_test.TestGetRanLoadInformationSdlgoFailure - failed to validate key parameter")
925 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
926 getNb, er := w.GetRanLoadInformation(name)
929 assert.IsType(t, &common.InternalError{}, er)
930 assert.EqualValues(t, errMsgExpected, er.Error())
933 func generateCellLoadInformationDeprecated() *entities.CellLoadInformation {
934 cellLoadInformation := entities.CellLoadInformation{}
936 cellLoadInformation.CellId = "123"
938 ulInterferenceOverloadIndication := entities.UlInterferenceOverloadIndication_HIGH_INTERFERENCE
939 cellLoadInformation.UlInterferenceOverloadIndications = []entities.UlInterferenceOverloadIndication{ulInterferenceOverloadIndication}
941 ulHighInterferenceInformation := entities.UlHighInterferenceInformation{
943 UlHighInterferenceIndication: "xxx",
946 cellLoadInformation.UlHighInterferenceInfos = []*entities.UlHighInterferenceInformation{&ulHighInterferenceInformation}
948 cellLoadInformation.RelativeNarrowbandTxPower = &entities.RelativeNarrowbandTxPower{
950 RntpThreshold: entities.RntpThreshold_NEG_4,
951 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V1_ANT_PRT,
953 PdcchInterferenceImpact: 2,
954 EnhancedRntp: &entities.EnhancedRntp{
955 EnhancedRntpBitmap: "xxx",
956 RntpHighPowerThreshold: entities.RntpThreshold_NEG_2,
957 EnhancedRntpStartTime: &entities.StartTime{StartSfn: 500, StartSubframeNumber: 5},
961 cellLoadInformation.AbsInformation = &entities.AbsInformation{
962 Mode: entities.AbsInformationMode_ABS_INFO_FDD,
963 AbsPatternInfo: "xxx",
964 NumberOfCellSpecificAntennaPorts: entities.NumberOfCellSpecificAntennaPorts_V2_ANT_PRT,
965 MeasurementSubset: "xxx",
968 cellLoadInformation.InvokeIndication = entities.InvokeIndication_ABS_INFORMATION
970 cellLoadInformation.ExtendedUlInterferenceOverloadInfo = &entities.ExtendedUlInterferenceOverloadInfo{
971 AssociatedSubframes: "xxx",
972 ExtendedUlInterferenceOverloadIndications: cellLoadInformation.UlInterferenceOverloadIndications,
975 compInformationItem := &entities.CompInformationItem{
976 CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "789", CompHypothesis: "xxx"}},
980 cellLoadInformation.CompInformation = &entities.CompInformation{
981 CompInformationItems: []*entities.CompInformationItem{compInformationItem},
982 CompInformationStartTime: &entities.StartTime{StartSfn: 123, StartSubframeNumber: 456},
985 cellLoadInformation.DynamicDlTransmissionInformation = &entities.DynamicDlTransmissionInformation{
986 State: entities.NaicsState_NAICS_ACTIVE,
987 TransmissionModes: "xxx",
989 PAList: []entities.PA{entities.PA_DB_NEG_3},
992 return &cellLoadInformation
995 func generateRanLoadInformationDeprecated() *entities.RanLoadInformation {
996 ranLoadInformation := entities.RanLoadInformation{}
998 ranLoadInformation.LoadTimestamp = uint64(time.Now().UnixNano())
1000 cellLoadInformation := generateCellLoadInformationDeprecated()
1001 ranLoadInformation.CellLoadInfos = []*entities.CellLoadInformation{cellLoadInformation}
1003 return &ranLoadInformation
1006 func TestGetE2TInstanceSuccessDeprecated(t *testing.T) {
1007 address := "10.10.2.15:9800"
1008 redisKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
1010 if validationErr != nil {
1011 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to build E2T Instance key. Error: %v", validationErr)
1014 w, sdlInstanceMock := initSdlInstanceMock()
1016 e2tInstance := generateE2tInstanceDeprecated(address)
1017 data, err := json.Marshal(e2tInstance)
1020 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to marshal E2tInstance entity. Error: %v", err)
1024 ret := map[string]interface{}{redisKey: string(data)}
1025 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, e)
1027 res, rNibErr := w.GetE2TInstance(address)
1028 assert.Nil(t, rNibErr)
1029 assert.Equal(t, e2tInstance, res)
1032 func TestUnmarshalDeprecated(t *testing.T) {
1033 e2tInstance := generateE2tInstanceDeprecated("10.0.2.15:5555")
1034 marshaled, _ := json.Marshal(e2tInstance)
1035 m := map[string]interface{}{
1036 "whatever": string(marshaled),
1038 var entity entities.E2TInstance
1039 err := json.Unmarshal([]byte(m["whatever"].(string)), &entity)
1043 func TestGetE2TInstanceEmptyAddressFailureDeprecated(t *testing.T) {
1044 w, _ := initSdlInstanceMock()
1045 res, err := w.GetE2TInstance("")
1046 assert.NotNil(t, err)
1047 assert.IsType(t, &common.ValidationError{}, err)
1051 func TestGetE2TInstanceSdlErrorDeprecated(t *testing.T) {
1052 address := "10.10.2.15:9800"
1053 redisKey, validationErr := common.ValidateAndBuildE2TInstanceKey(address)
1055 if validationErr != nil {
1056 t.Errorf("#rNibReader_test.TestGetE2TInstanceSuccess - Failed to build E2T Instance key. Error: %v", validationErr)
1059 w, sdlInstanceMock := initSdlInstanceMock()
1061 expectedErr := errors.New("expected error")
1062 var ret map[string]interface{}
1063 sdlInstanceMock.On("Get", []string{redisKey}).Return(ret, expectedErr)
1065 res, rNibErr := w.GetE2TInstance(address)
1066 assert.NotNil(t, rNibErr)
1070 func generateE2tInstanceDeprecated(address string) *entities.E2TInstance {
1071 e2tInstance := entities.NewE2TInstance(address, "")
1072 e2tInstance.AssociatedRanList = []string{"test1", "test2"}
1073 e2tInstance.DeletionTimestamp = time.Now().UnixNano()
1077 func TestGetE2TAddressesSdlErrorDeprecated(t *testing.T) {
1078 w, sdlInstanceMock := initSdlInstanceMock()
1080 expectedErr := errors.New("expected error")
1081 var ret map[string]interface{}
1082 sdlInstanceMock.On("Get", []string{E2TAddressesKey}).Return(ret, expectedErr)
1084 res, rNibErr := w.GetE2TAddresses()
1085 assert.NotNil(t, rNibErr)
1089 func TestGetE2TAddressesSuccessDeprecated(t *testing.T) {
1090 address := "10.10.2.15:9800"
1091 w, sdlInstanceMock := initSdlInstanceMock()
1093 e2tAddresses := []string{address}
1094 data, err := json.Marshal(e2tAddresses)
1097 t.Errorf("#rNibReader_test.TestGetE2TInfoListSuccess - Failed to marshal E2TInfoList. Error: %v", err)
1101 ret := map[string]interface{}{E2TAddressesKey: string(data)}
1102 sdlInstanceMock.On("Get", []string{E2TAddressesKey}).Return(ret, e)
1104 res, rNibErr := w.GetE2TAddresses()
1105 assert.Nil(t, rNibErr)
1106 assert.Equal(t, e2tAddresses, res)
1109 func TestGetE2TInstancesSuccessDeprecated(t *testing.T) {
1110 address := "10.10.2.15:9800"
1111 address2 := "10.10.2.16:9800"
1112 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1113 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1115 w, sdlInstanceMock := initSdlInstanceMock()
1117 e2tInstance1 := generateE2tInstanceDeprecated(address)
1118 e2tInstance2 := generateE2tInstanceDeprecated(address2)
1120 data1, _ := json.Marshal(e2tInstance1)
1121 data2, _ := json.Marshal(e2tInstance2)
1124 ret := map[string]interface{}{redisKey: string(data1), redisKey2: string(data2)}
1125 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(ret, e)
1127 res, err := w.GetE2TInstances([]string{address, address2})
1129 assert.Equal(t, []*entities.E2TInstance{e2tInstance1, e2tInstance2}, res)
1132 func TestGetE2TInstancesUnmarhalPartialSuccessDeprecated(t *testing.T) {
1133 address := "10.10.2.15:9800"
1134 address2 := "10.10.2.16:9800"
1135 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1136 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1138 w, sdlInstanceMock := initSdlInstanceMock()
1140 e2tInstance1 := generateE2tInstanceDeprecated(address)
1141 data1, _ := json.Marshal(e2tInstance1)
1144 ret := map[string]interface{}{redisKey: string(data1), redisKey2: "abc"}
1145 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(ret, e)
1147 res, err := w.GetE2TInstances([]string{address, address2})
1149 assert.Equal(t, []*entities.E2TInstance{e2tInstance1}, res)
1152 func TestGetE2TInstancesSdlFailureDeprecated(t *testing.T) {
1153 address := "10.10.2.15:9800"
1154 address2 := "10.10.2.16:9800"
1155 redisKey, _ := common.ValidateAndBuildE2TInstanceKey(address)
1156 redisKey2, _ := common.ValidateAndBuildE2TInstanceKey(address2)
1158 w, sdlInstanceMock := initSdlInstanceMock()
1160 sdlInstanceMock.On("Get", []string{redisKey, redisKey2}).Return(map[string]interface{}{}, fmt.Errorf(""))
1161 _, err := w.GetE2TInstances([]string{address, address2})
1162 assert.IsType(t, &common.InternalError{}, err)
1165 func TestGetE2TInstancesEmptyDataDeprecated(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{}{}, nil)
1174 _, err := w.GetE2TInstances([]string{address, address2})
1175 assert.IsType(t, &common.ResourceNotFoundError{}, err)
1178 func TestGetGeneralConfigurationDeprecated(t *testing.T) {
1180 key := common.BuildGeneralConfigurationKey()
1181 w, sdlInstanceMock := initSdlInstanceMock()
1183 configurationData := "{\"enableRic\":true}"
1184 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{key: configurationData}, nil)
1186 res, rNibErr := w.GetGeneralConfiguration()
1187 assert.Nil(t, rNibErr)
1188 assert.Equal(t, true, res.EnableRic)
1191 func TestGetGeneralConfigurationNotFoundDeprecated(t *testing.T) {
1193 key := common.BuildGeneralConfigurationKey()
1194 w, sdlInstanceMock := initSdlInstanceMock()
1196 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{}, nil)
1198 _, rNibErr := w.GetGeneralConfiguration()
1200 assert.NotNil(t, rNibErr)
1201 assert.Equal(t, "#rNibReader.getByKeyAndUnmarshalJson - entity of type *entities.GeneralConfiguration not found. Key: GENERAL", rNibErr.Error())
1204 func TestGetGeneralConfigurationSdlFailureDeprecated(t *testing.T) {
1206 key := common.BuildGeneralConfigurationKey()
1207 w, sdlInstanceMock := initSdlInstanceMock()
1209 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{}, fmt.Errorf("sdl error"))
1211 _, rNibErr := w.GetGeneralConfiguration()
1213 assert.NotNil(t, rNibErr)
1215 assert.Equal(t, "sdl error", rNibErr.Error())
1218 func TestGetGeneralConfigurationUnmarshalErrorDeprecated(t *testing.T) {
1220 key := common.BuildGeneralConfigurationKey()
1221 w, sdlInstanceMock := initSdlInstanceMock()
1223 configurationData := "{\"enableRic :true}"
1224 sdlInstanceMock.On("Get", []string{key}).Return(map[string]interface{}{key: configurationData}, nil)
1226 _, rNibErr := w.GetGeneralConfiguration()
1228 assert.NotNil(t, rNibErr)
1229 assert.Equal(t, rNibErr.Error(), "unexpected end of JSON input")
1234 //func TestGetEnbIntegDeprecated(t *testing.T){
1235 // name := "nameEnb1"
1236 // Init("namespace", 1)
1237 // w := GetRNibReader()
1238 // nb, err := w.GetNodeb(name)
1242 // fmt.Printf("#TestGetEnbInteg - responding node type: %v\n", nb)
1246 //func TestGetEnbCellsIntegDeprecated(t *testing.T){
1247 // name := "nameEnb1"
1248 // Init("namespace", 1)
1249 // w := GetRNibReader()
1250 // cells, err := w.GetCellList(name)
1253 // } else if cells != nil{
1254 // for _, cell := range cells.GetServedCellInfos().ServedCells{
1255 // fmt.Printf("responding node type Cell: %v\n", *cell)
1260 //func TestGetGnbIntegDeprecated(t *testing.T){
1261 // name := "nameGnb1"
1262 // Init("namespace", 1)
1263 // w := GetRNibReader()
1264 // nb, err := w.GetNodeb(name)
1268 // fmt.Printf("#TestGetGnbInteg - responding node type: %v\n", nb)
1272 //func TestGetGnbCellsIntegDeprecated(t *testing.T){
1273 // name := "nameGnb1"
1274 // Init("namespace", 1)
1275 // w := GetRNibReader()
1276 // cells, err := w.GetCellList(name)
1279 // } else if cells != nil{
1280 // for _, cell := range cells.GetServedNrCells().ServedCells{
1281 // fmt.Printf("responding node type NR Cell: %v\n", *cell)
1286 //func TestGetListEnbIdsIntegDeprecated(t *testing.T) {
1287 // Init("namespace", 1)
1288 // w := GetRNibReader()
1289 // ids, err := w.GetListEnbIds()
1293 // for _, id := range ids{
1294 // fmt.Printf("#TestGetListEnbIdsInteg - ENB ID: %s\n", id)
1299 //func TestGetListGnbIdsIntegDeprecated(t *testing.T) {
1300 // Init("namespace", 1)
1301 // w := GetRNibReader()
1302 // ids, err := w.GetListGnbIds()
1306 // for _, id := range ids{
1307 // fmt.Printf("#TestGetListGnbIdsInteg - GNB ID: %s\n", id)
1312 //func TestGetCountGnbListIntegDeprecated(t *testing.T) {
1313 // Init("namespace", 1)
1314 // w := GetRNibReader()
1315 // count, err := w.GetCountGnbList()
1319 // fmt.Printf("#TestGetCountGnbListInteg - count Gnb list: %d\n", count)
1323 //func TestGetGnbCellIntegDeprecated(t *testing.T){
1324 // name := "nameGnb7"
1326 // Init("namespace", 1)
1327 // w := GetRNibReader()
1328 // cell, err := w.GetCell(name, uint32(pci))
1331 // } else if cell != nil{
1332 // fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
1336 //func TestGetEnbCellIntegDeprecated(t *testing.T) {
1337 // name := "nameEnb1"
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 LTE Cell: %v\n", cell.GetServedCellInfo())
1349 //func TestGetEnbCellByIdIntegDeprecated(t *testing.T){
1350 // Init("namespace", 1)
1351 // w := GetRNibReader()
1352 // cell, err := w.GetCellById(entities.Cell_NR_CELL, "45d")
1355 // } else if cell != nil{
1356 // fmt.Printf("responding node type NR Cell: %v\n", cell.GetServedNrCell())
1360 //func TestGetListNbIdsIntegDeprecated(t *testing.T) {
1361 // Init("e2Manager", 1)
1362 // w := GetRNibReader()
1363 // ids, err := w.GetListNodebIds()
1367 // for _, id := range ids{
1368 // fmt.Printf("#TestGetListGnbIdsInteg - NB ID: %s\n", id)
1373 //func TestGetRanLoadInformationIntegDeprecated(t *testing.T){
1374 // Init("e2Manager", 1)
1375 // w := GetRNibReader()
1376 // ranLoadInformation, err := w.GetRanLoadInformation("ran_integ")
1378 // t.Errorf("#rNibReader_test.TestGetRanLoadInformationInteg - Failed to get RanLoadInformation entity. Error: %v", err)
1380 // assert.NotNil(t, ranLoadInformation)
1381 // fmt.Printf("#rNibReader_test.TestGetRanLoadInformationInteg - GNB ID: %s\n", ranLoadInformation)
1384 //func TestGetE2TInstancesIntegDeprecated(t *testing.T) {
1385 // db := sdlgo.NewDatabase()
1386 // sdl := sdlgo.NewSdlInstance("e2Manager", db)
1387 // rnibReader := GetRNibReader(sdl)
1388 // e2tInstances, _ := rnibReader.GetE2TInstances([]string{"e2t.att.com:38000","whatever"})
1389 // assert.Len(t, e2tInstances, 1)