# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 4.4.3
+tag: 4.4.4
"fmt"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
"gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/golang/protobuf/jsonpb"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
ValidationFailureJson = "{\"errorCode\":402,\"errorMessage\":\"Validation error\"}"
ResourceNotFoundJson = "{\"errorCode\":404,\"errorMessage\":\"Resource not found\"}"
RnibErrorJson = "{\"errorCode\":500,\"errorMessage\":\"RNIB error\"}"
+ InternalErrorJson = "{\"errorCode\":501,\"errorMessage\":\"Internal Server Error. Please try again later\"}"
)
var (
rnibError error
}
+type updateGnbCellsParams struct {
+ err error
+}
+
type controllerUpdateGnbTestContext struct {
getNodebInfoResult *getNodebInfoResult
+ updateGnbCellsParams *updateGnbCellsParams
requestBody map[string]interface{}
expectedStatusCode int
expectedJsonResponse string
assert.Equal(t, context.expectedJsonResponse, string(bodyBytes))
}
-func controllerUpdateGnbTestExecuter(t *testing.T, context *controllerUpdateGnbTestContext) {
- controller, readerMock, _, _, _ := setupControllerTest(t)
- writer := httptest.NewRecorder()
-
+func activateControllerUpdateGnbMocks(context *controllerUpdateGnbTestContext, readerMock *mocks.RnibReaderMock, writerMock *mocks.RnibWriterMock) {
if context.getNodebInfoResult != nil {
readerMock.On("GetNodeb", RanName).Return(context.getNodebInfoResult.nodebInfo, context.getNodebInfoResult.rnibError)
}
+ if context.updateGnbCellsParams != nil {
+ updatedNodebInfo := *context.getNodebInfoResult.nodebInfo
+ gnb := entities.Gnb{}
+ _ = jsonpb.Unmarshal(getJsonRequestAsBuffer(context.requestBody), &gnb)
+ updatedNodebInfo.GetGnb().ServedNrCells = gnb.ServedNrCells
+ writerMock.On("UpdateGnbCells", &updatedNodebInfo, gnb.ServedNrCells).Return(context.updateGnbCellsParams.err)
+ }
+}
+
+func assertControllerUpdateGnb(t *testing.T, context *controllerUpdateGnbTestContext, writer *httptest.ResponseRecorder, readerMock *mocks.RnibReaderMock, writerMock *mocks.RnibWriterMock) {
+ assert.Equal(t, context.expectedStatusCode, writer.Result().StatusCode)
+ bodyBytes, _ := ioutil.ReadAll(writer.Body)
+ assert.Equal(t, context.expectedJsonResponse, string(bodyBytes))
+ readerMock.AssertExpectations(t)
+ writerMock.AssertExpectations(t)
+
+ if context.getNodebInfoResult != nil {
+ readerMock.AssertNotCalled(t, "GetNodeb")
+ }
+
+ if context.updateGnbCellsParams != nil {
+ writerMock.AssertNotCalled(t, "UpdateGnb")
+ }
+}
+
+func buildUpdateGnbRequest(context *controllerUpdateGnbTestContext) *http.Request {
updateGnbUrl := fmt.Sprintf("/nodeb/%s/update", RanName)
requestBody := getJsonRequestAsBuffer(context.requestBody)
req, _ := http.NewRequest(http.MethodGet, updateGnbUrl, requestBody)
req.Header.Set("Content-Type", "application/json")
req = mux.SetURLVars(req, map[string]string{"ranName": RanName})
+ return req
+}
+
+func controllerUpdateGnbTestExecuter(t *testing.T, context *controllerUpdateGnbTestContext) {
+ controller, readerMock, writerMock, _, _ := setupControllerTest(t)
+ writer := httptest.NewRecorder()
+
+ activateControllerUpdateGnbMocks(context, readerMock, writerMock)
+ req := buildUpdateGnbRequest(context)
controller.UpdateGnb(writer, req)
- assert.Equal(t, context.expectedStatusCode, writer.Result().StatusCode)
- bodyBytes, _ := ioutil.ReadAll(writer.Body)
- assert.Equal(t, context.expectedJsonResponse, string(bodyBytes))
+ assertControllerUpdateGnb(t, context, writer, readerMock, writerMock)
}
func TestControllerUpdateGnbEmptyServedNrCells(t *testing.T) {
"servedNrCells": []interface{}{
map[string]interface{}{
"servedNrCellInformation": buildServedNrCellInformation(""),
- "nrNeighbourInfos": []interface{}{
+ "nrNeighbourInfos": []interface{}{
nrNeighbourInfo,
},
},
"servedNrCells": []interface{}{
map[string]interface{}{
"servedNrCellInformation": buildServedNrCellInformation(""),
- "nrNeighbourInfos": []interface{}{
+ "nrNeighbourInfos": []interface{}{
buildNrNeighbourInformation(v),
},
},
}
}
-func TestControllerUpdateGnbValidServedNrCellInformationAndNrNeighbourInfoGetNodebSuccess(t *testing.T) {
+func TestControllerUpdateGnbValidServedNrCellInformationGetNodebNotFound(t *testing.T) {
context := controllerUpdateGnbTestContext{
getNodebInfoResult: &getNodebInfoResult{
- nodebInfo: &entities.NodebInfo{RanName: RanName, ConnectionStatus: entities.ConnectionStatus_CONNECTED, AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress},
- rnibError: nil,
+ nodebInfo: nil,
+ rnibError: common.NewResourceNotFoundError("#reader.GetNodeb - Not found Error"),
},
requestBody: map[string]interface{}{
"servedNrCells": []interface{}{
map[string]interface{}{
"servedNrCellInformation": buildServedNrCellInformation(""),
- "nrNeighbourInfos": []interface{}{
- buildNrNeighbourInformation(""),
- },
},
},
},
- expectedStatusCode: http.StatusOK,
- expectedJsonResponse: "{\"ranName\":\"test\",\"connectionStatus\":\"CONNECTED\",\"associatedE2tInstanceAddress\":\"10.0.2.15:38000\"}",
+ expectedStatusCode: http.StatusNotFound,
+ expectedJsonResponse: ResourceNotFoundJson,
}
controllerUpdateGnbTestExecuter(t, &context)
}
-func TestControllerUpdateGnbValidServedNrCellInformationGetNodebNotFound(t *testing.T) {
+func TestControllerUpdateGnbValidServedNrCellInformationGetNodebInternalError(t *testing.T) {
context := controllerUpdateGnbTestContext{
getNodebInfoResult: &getNodebInfoResult{
nodebInfo: nil,
- rnibError: common.NewResourceNotFoundError("#reader.GetNodeb - Not found Error"),
+ rnibError: common.NewInternalError(errors.New("#reader.GetNodeb - Internal Error")),
},
requestBody: map[string]interface{}{
"servedNrCells": []interface{}{
},
},
},
- expectedStatusCode: http.StatusNotFound,
- expectedJsonResponse: ResourceNotFoundJson,
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: RnibErrorJson,
}
controllerUpdateGnbTestExecuter(t, &context)
}
-func TestControllerUpdateGnbValidServedNrCellInformationGetNodebInternalError(t *testing.T) {
+func TestControllerUpdateGnbGetNodebSuccessInvalidGnbConfiguration(t *testing.T) {
context := controllerUpdateGnbTestContext{
getNodebInfoResult: &getNodebInfoResult{
- nodebInfo: nil,
- rnibError: common.NewInternalError(errors.New("#reader.GetNodeb - Internal Error")),
+ nodebInfo: &entities.NodebInfo{
+ RanName: RanName,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
+ },
+ rnibError: nil,
+ },
+ requestBody: map[string]interface{}{
+ "servedNrCells": []interface{}{
+ map[string]interface{}{
+ "servedNrCellInformation": buildServedNrCellInformation(""),
+ "nrNeighbourInfos": []interface{}{
+ buildNrNeighbourInformation(""),
+ },
+ },
+ },
+ },
+ expectedStatusCode: http.StatusInternalServerError,
+ expectedJsonResponse: InternalErrorJson,
+ }
+
+ controllerUpdateGnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateGnbGetNodebSuccessUpdateGnbCellsFailure(t *testing.T) {
+ context := controllerUpdateGnbTestContext{
+ updateGnbCellsParams: &updateGnbCellsParams{
+ err: common.NewInternalError(errors.New("#writer.UpdateGnbCells - Internal Error")),
+ },
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: &entities.NodebInfo{
+ RanName: RanName,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
+ Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
+ },
+ rnibError: nil,
},
requestBody: map[string]interface{}{
"servedNrCells": []interface{}{
map[string]interface{}{
"servedNrCellInformation": buildServedNrCellInformation(""),
+ "nrNeighbourInfos": []interface{}{
+ buildNrNeighbourInformation(""),
+ },
},
},
},
controllerUpdateGnbTestExecuter(t, &context)
}
+func TestControllerUpdateGnbSuccess(t *testing.T) {
+ context := controllerUpdateGnbTestContext{
+ updateGnbCellsParams: &updateGnbCellsParams{
+ err: nil,
+ },
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: &entities.NodebInfo{
+ RanName: RanName,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
+ Configuration: &entities.NodebInfo_Gnb{Gnb: &entities.Gnb{}},
+ },
+ rnibError: nil,
+ },
+ requestBody: map[string]interface{}{
+ "servedNrCells": []interface{}{
+ map[string]interface{}{
+ "servedNrCellInformation": buildServedNrCellInformation(""),
+ "nrNeighbourInfos": []interface{}{
+ buildNrNeighbourInformation(""),
+ },
+ },
+ },
+ },
+ expectedStatusCode: http.StatusOK,
+ expectedJsonResponse: "{\"ranName\":\"test\",\"connectionStatus\":\"CONNECTED\",\"gnb\":{\"servedNrCells\":[{\"servedNrCellInformation\":{\"nrPci\":1,\"cellId\":\"whatever\",\"servedPlmns\":[\"whatever\"],\"nrMode\":\"FDD\",\"choiceNrMode\":{\"fdd\":{}}},\"nrNeighbourInfos\":[{\"nrPci\":1,\"nrCgi\":\"whatever\",\"nrMode\":\"FDD\",\"choiceNrMode\":{\"tdd\":{}}}]}]},\"associatedE2tInstanceAddress\":\"10.0.2.15:38000\"}",
+ }
+
+ controllerUpdateGnbTestExecuter(t, &context)
+}
+
func getJsonRequestAsBuffer(requestJson map[string]interface{}) *bytes.Buffer {
b := new(bytes.Buffer)
_ = json.NewEncoder(b).Encode(requestJson)
return nil, e2managererrors.NewResourceNotFoundError()
}
- //gnb := nodebInfo.GetGnb()
- //
- //if gnb == nil {
- // // TODO: log and return appropriate error
- // return nil, e2managererrors.NewRnibDbError()
- //}
- //
- //gnb.ServedNrCells = updateGnbRequest.ServedNrCells
- //
- //err = h.rNibDataService.UpdateGnbCells(nodebInfo, updateGnbRequest.ServedNrCells)
- //
- //if err != nil {
- // // TODO: handle error
- // return nil, err
- //}
+ ranName:= nodebInfo.RanName
+ gnb := nodebInfo.GetGnb()
+
+ if gnb == nil {
+ h.logger.Errorf("#UpdateGnbRequestHandler.Handle - RAN name: %s - nodeb missing gnb configuration", ranName)
+ return nil, e2managererrors.NewInternalError()
+ }
+
+ gnb.ServedNrCells = updateGnbRequest.ServedNrCells
+
+ err = h.rNibDataService.UpdateGnbCells(nodebInfo, updateGnbRequest.ServedNrCells)
+
+ if err != nil {
+ h.logger.Errorf("#UpdateGnbRequestHandler.Handle - RAN name: %s - Failed updating GNB cells. Error: %s", ranName, err)
+ return nil, e2managererrors.NewRnibDbError()
+ }
return models.NewUpdateGnbResponse(nodebInfo), nil
}
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
-
package mocks
import (
return args.Error(0)
}
+
+func (rnibWriterMock *RnibWriterMock) UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error {
+ args := rnibWriterMock.Called(nodebInfo, servedNrCells)
+ return args.Error(0)
+}
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
-
package rNibWriter
import (
SaveE2TInstance(e2tInstance *entities.E2TInstance) error
SaveE2TAddresses(addresses []string) error
RemoveE2TInstance(e2tAddress string) error
+ UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error
}
/*
}
if entity.GetEnb() != nil {
- pairs, rNibErr = appendEnbCells(nbIdentity, entity.GetEnb().GetServedCells(), pairs)
+ pairs, rNibErr = appendEnbCells(nbIdentity.InventoryName, entity.GetEnb().GetServedCells(), pairs)
if rNibErr != nil {
return rNibErr
}
}
if entity.GetGnb() != nil {
- pairs, rNibErr = appendGnbCells(nbIdentity, entity.GetGnb().GetServedNrCells(), pairs)
+ pairs, rNibErr = appendGnbCells(nbIdentity.InventoryName, entity.GetGnb().GetServedNrCells(), pairs)
if rNibErr != nil {
return rNibErr
}
return nil
}
-/*
-UpdateNodebInfo...
-*/
-func (w *rNibWriterInstance) UpdateNodebInfo(nodebInfo *entities.NodebInfo) error {
+func (w *rNibWriterInstance) UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error {
+
+ pairs, err := buildUpdateNodebInfoPairs(nodebInfo)
+
+ if err != nil {
+ return err
+ }
+
+ pairs, err = appendGnbCells(nodebInfo.RanName, servedNrCells, pairs)
+
+ if err != nil {
+ return err
+ }
+
+ err = w.sdl.Set(pairs)
+
+ if err != nil {
+ return common.NewInternalError(err)
+ }
+ return nil
+}
+
+func buildUpdateNodebInfoPairs(nodebInfo *entities.NodebInfo) ([]interface{}, error) {
nodebNameKey, rNibErr := common.ValidateAndBuildNodeBNameKey(nodebInfo.GetRanName())
if rNibErr != nil {
- return rNibErr
+ return []interface{}{}, rNibErr
}
nodebIdKey, buildNodebIdKeyError := common.ValidateAndBuildNodeBIdKey(nodebInfo.GetNodeType().String(), nodebInfo.GlobalNbId.GetPlmnId(), nodebInfo.GlobalNbId.GetNbId())
data, err := proto.Marshal(nodebInfo)
if err != nil {
- return common.NewInternalError(err)
+ return []interface{}{}, common.NewInternalError(err)
}
- var pairs []interface{}
- pairs = append(pairs, nodebNameKey, data)
+ pairs := []interface{}{nodebNameKey, data}
if buildNodebIdKeyError == nil {
pairs = append(pairs, nodebIdKey, data)
}
+ return pairs, nil
+}
+
+/*
+UpdateNodebInfo...
+*/
+func (w *rNibWriterInstance) UpdateNodebInfo(nodebInfo *entities.NodebInfo) error {
+
+ pairs, err := buildUpdateNodebInfoPairs(nodebInfo)
+
+ if err != nil {
+ return err
+ }
+
err = w.sdl.Set(pairs)
if err != nil {
return nil
}
-
func (w *rNibWriterInstance) RemoveE2TInstance(address string) error {
key, rNibErr := common.ValidateAndBuildE2TInstanceKey(address)
if rNibErr != nil {
//Nothing to do
}
-func appendEnbCells(nbIdentity *entities.NbIdentity, cells []*entities.ServedCellInfo, pairs []interface{}) ([]interface{}, error) {
+func appendEnbCells(inventoryName string, cells []*entities.ServedCellInfo, pairs []interface{}) ([]interface{}, error) {
for _, cell := range cells {
cellEntity := entities.Cell{Type: entities.Cell_LTE_CELL, Cell: &entities.Cell_ServedCellInfo{ServedCellInfo: cell}}
cellData, err := proto.Marshal(&cellEntity)
return pairs, rNibErr
}
pairs = append(pairs, key, cellData)
- key, rNibErr = common.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetPci())
+ key, rNibErr = common.ValidateAndBuildCellNamePciKey(inventoryName, cell.GetPci())
if rNibErr != nil {
return pairs, rNibErr
}
return pairs, nil
}
-func appendGnbCells(nbIdentity *entities.NbIdentity, cells []*entities.ServedNRCell, pairs []interface{}) ([]interface{}, error) {
+func appendGnbCells(inventoryName string, cells []*entities.ServedNRCell, pairs []interface{}) ([]interface{}, error) {
for _, cell := range cells {
cellEntity := entities.Cell{Type: entities.Cell_NR_CELL, Cell: &entities.Cell_ServedNrCell{ServedNrCell: cell}}
cellData, err := proto.Marshal(&cellEntity)
return pairs, rNibErr
}
pairs = append(pairs, key, cellData)
- key, rNibErr = common.ValidateAndBuildCellNamePciKey(nbIdentity.InventoryName, cell.GetServedNrCellInformation().GetNrPci())
+ key, rNibErr = common.ValidateAndBuildCellNamePciKey(inventoryName, cell.GetServedNrCellInformation().GetNrPci())
if rNibErr != nil {
return pairs, rNibErr
}
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
-
package rNibWriter
import (
"time"
)
+var namespace = "namespace"
+
func initSdlInstanceMock(namespace string) (w RNibWriter, sdlInstanceMock *mocks.MockSdlInstance) {
sdlInstanceMock = new(mocks.MockSdlInstance)
w = GetRNibWriter(sdlInstanceMock)
return
}
-var namespace = "namespace"
+func generateNodebInfo(inventoryName string, nodeType entities.Node_Type, plmnId string, nbId string) *entities.NodebInfo {
+ nodebInfo := &entities.NodebInfo{
+ RanName: inventoryName,
+ GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId},
+ NodeType: nodeType,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ }
+
+ if nodeType == entities.Node_ENB {
+ nodebInfo.Configuration = &entities.NodebInfo_Enb{
+ Enb: &entities.Enb{},
+ }
+ } else if nodeType == entities.Node_GNB {
+ nodebInfo.Configuration = &entities.NodebInfo_Gnb{
+ Gnb: &entities.Gnb{},
+ }
+ }
+
+ return nodebInfo
+}
+
+func generateServedNrCells(cellIds ...string) []*entities.ServedNRCell {
+
+ servedNrCells := []*entities.ServedNRCell{}
+
+ for _, v := range cellIds {
+ servedNrCells = append(servedNrCells, &entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{
+ CellId: v,
+ ChoiceNrMode: &entities.ServedNRCellInformation_ChoiceNRMode{
+ Fdd: &entities.ServedNRCellInformation_ChoiceNRMode_FddInfo{
+
+ },
+ },
+ NrMode: entities.Nr_FDD,
+ NrPci: 5,
+ ServedPlmns: []string{"whatever"},
+ }})
+ }
+
+ return servedNrCells
+}
+
+func TestUpdateGnbCellsInvalidNodebInfoFailure(t *testing.T) {
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ servedNrCells := generateServedNrCells("test1", "test2")
+ nodebInfo := &entities.NodebInfo{}
+ sdlInstanceMock.AssertNotCalled(t, "Set")
+ rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+}
+
+func TestUpdateGnbCellsInvalidCellFailure(t *testing.T) {
+ inventoryName := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ servedNrCells := []*entities.ServedNRCell{{ServedNrCellInformation: &entities.ServedNRCellInformation{}}}
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_GNB, plmnId, nbId)
+ nodebInfo.GetGnb().ServedNrCells = servedNrCells
+ sdlInstanceMock.AssertNotCalled(t, "Set")
+ rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+}
+
+func getUpdateGnbCellsSetExpected(t *testing.T, nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) []interface{} {
+
+ nodebInfoData, err := proto.Marshal(nodebInfo)
+ if err != nil {
+ t.Fatalf("#rNibWriter_test.getUpdateGnbCellsSetExpected - Failed to marshal NodeB entity. Error: %s", err)
+ }
+
+ nodebNameKey, _ := common.ValidateAndBuildNodeBNameKey(nodebInfo.RanName)
+ nodebIdKey, _ := common.ValidateAndBuildNodeBIdKey(nodebInfo.NodeType.String(), nodebInfo.GlobalNbId.PlmnId, nodebInfo.GlobalNbId.NbId)
+ setExpected := []interface{}{nodebNameKey, nodebInfoData, nodebIdKey, nodebInfoData}
+
+ for _, v := range servedNrCells {
+
+ cellEntity := entities.Cell{Type: entities.Cell_NR_CELL, Cell: &entities.Cell_ServedNrCell{ServedNrCell: v}}
+ cellData, err := proto.Marshal(&cellEntity)
+
+ if err != nil {
+ t.Fatalf("#rNibWriter_test.getUpdateGnbCellsSetExpected - Failed to marshal cell entity. Error: %s", err)
+ }
+
+ nrCellIdKey, _ := common.ValidateAndBuildNrCellIdKey(v.GetServedNrCellInformation().GetCellId())
+ cellNamePciKey, _ := common.ValidateAndBuildCellNamePciKey(nodebInfo.RanName, v.GetServedNrCellInformation().GetNrPci())
+ setExpected = append(setExpected, nrCellIdKey, cellData, cellNamePciKey, cellData)
+ }
+
+ return setExpected
+}
+
+func TestUpdateGnbCellsSdlFailure(t *testing.T) {
+ inventoryName := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ servedNrCells := generateServedNrCells("test1", "test2")
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_GNB, plmnId, nbId)
+ nodebInfo.GetGnb().ServedNrCells = servedNrCells
+ setExpected := getUpdateGnbCellsSetExpected(t, nodebInfo, servedNrCells)
+ sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(errors.New("expected error"))
+ rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
+ assert.IsType(t, &common.InternalError{}, rNibErr)
+}
+
+func TestUpdateGnbCellsSuccess(t *testing.T) {
+ inventoryName := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ servedNrCells := generateServedNrCells("test1", "test2")
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_GNB, plmnId, nbId)
+ nodebInfo.GetGnb().ServedNrCells = servedNrCells
+ setExpected := getUpdateGnbCellsSetExpected(t, nodebInfo, servedNrCells)
+ var e error
+ sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+ rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
+ assert.Nil(t, rNibErr)
+}
func TestUpdateNodebInfoSuccess(t *testing.T) {
inventoryName := "name"
plmnId := "02f829"
nbId := "4a952a0a"
w, sdlInstanceMock := initSdlInstanceMock(namespace)
- nodebInfo := &entities.NodebInfo{}
- nodebInfo.RanName = inventoryName
- nodebInfo.GlobalNbId = &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}
- nodebInfo.NodeType = entities.Node_ENB
- nodebInfo.ConnectionStatus = 1
- enb := entities.Enb{}
- nodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_ENB, plmnId, nbId)
data, err := proto.Marshal(nodebInfo)
if err != nil {
t.Errorf("#rNibWriter_test.TestSaveEnb - Failed to marshal NodeB entity. Error: %v", err)
}
compInformationItem := &entities.CompInformationItem{
- CompHypothesisSets: []*entities.CompHypothesisSet{&entities.CompHypothesisSet{CellId: "789", CompHypothesis: "xxx"}},
+ CompHypothesisSets: []*entities.CompHypothesisSet{{CellId: "789", CompHypothesis: "xxx"}},
BenefitMetric: 50,
}
SaveE2TInstanceNoLogs(e2tInstance *entities.E2TInstance) error
GetE2TAddressesNoLogs() ([]string, error)
RemoveE2TInstance(e2tAddress string) error
+ UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error
}
type rNibDataService struct {
}
}
+func (w *rNibDataService) UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error {
+ w.logger.Infof("#RnibDataService.UpdateGnbCells - nodebInfo: %s, servedNrCells: %s", nodebInfo, servedNrCells)
+
+ err := w.retry("UpdateGnbCells", func() (err error) {
+ err = w.rnibWriter.UpdateGnbCells(nodebInfo, servedNrCells)
+ return
+ })
+
+ return err
+}
+
func (w *rNibDataService) UpdateNodebInfo(nodebInfo *entities.NodebInfo) error {
w.logger.Infof("#RnibDataService.UpdateNodebInfo - nodebInfo: %s", nodebInfo)