+##############################################################################
+#
+# Copyright (c) 2019 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##############################################################################
+#
+# This source code is part of the near-RT RIC (RAN Intelligent Controller)
+# platform project (RICP).
+#
+
*** Settings ***
Suite Setup Prepare Enviorment
Resource ../Resource/resource.robot
Sleep 1s
PUT ${update_gnb_url} ${update_gnb_body}
+Set General Configuration request
+ Sleep 1s
+ PUT ${set_general_configuration} ${set_general_configuration_body}
Update Ran request not valid
Sleep 1s
${url} http://localhost:3800
${ranName} gnb_208_092_303030
${getNodeb} /v1/nodeb/${ranName}
+${set_general_configuration} /v1/nodeb/parameters
+${set_general_configuration_body} {"enableRic":false}
${update_gnb_url} /v1/nodeb/${ranName}/update
${update_gnb_body} {"servedNrCells":[{"servedNrCellInformation":{"cellId":"abcd","choiceNrMode":{"fdd":{}},"nrMode":1,"nrPci":1,"servedPlmns":["whatever"]},"nrNeighbourInfos":[{"nrCgi":"one","choiceNrMode":{"fdd":{}},"nrMode":1,"nrPci":1}]}]}
${update_gnb_body_notvalid} {"servedNrCells":[{"servedNrCellInformation":{"choiceNrMode":{"fdd":{}},"nrMode":1,"nrPci":1,"servedPlmns":["whatever"]},"nrNeighbourInfos":[{"nrCgi":"whatever","choiceNrMode":{"fdd":{}},"nrMode":1,"nrPci":1}]}]}
${third_retry_to_retrieve_from_db} RnibDataService.retry - after 3 attempts of GetNodeb
${RIC_RES_STATUS_REQ_message_type_successfully_sent} Message type: 10090 - Successfully sent RMR message
${E2_TERM_KEEP_ALIVE_REQ_message_type_successfully_sent} Message type: 1101 - Successfully sent RMR message
-
-
+${save_general_configuration} RnibDataService.SaveGeneralConfiguration - configuration: {EnableRic:false}
\ No newline at end of file
--- /dev/null
+##############################################################################
+#
+# Copyright (c) 2019 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##############################################################################
+
+*** Settings ***
+Documentation Resource status
--- /dev/null
+##############################################################################
+#
+# Copyright (c) 2019 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##############################################################################
+#
+# This source code is part of the near-RT RIC (RAN Intelligent Controller)
+# platform project (RICP).
+
+
+
+*** Settings ***
+Suite Setup Prepare Enviorment
+Resource ../Resource/resource.robot
+Resource ../Resource/Keywords.robot
+Library OperatingSystem
+Library REST ${url}
+
+
+
+
+*** Test Cases ***
+
+prepare logs for tests
+ Remove log files
+ Save logs
+
+Set General Configuration
+ Sleep 2s
+ Set General Configuration request
+ Integer response status 200
+ String response body enableRic false
+
+Verify e2mgr logs - Third retry to retrieve from db
+ ${result} find_error_script.find_error ${EXECDIR} ${e2mgr_log_filename} ${save_general_configuration}
+ Should Be Equal As Strings ${result} True
\ No newline at end of file
# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 5.0.2
+tag: 5.0.3
GetNodeb(writer http.ResponseWriter, r *http.Request)
UpdateGnb(writer http.ResponseWriter, r *http.Request)
GetNodebIdList(writer http.ResponseWriter, r *http.Request)
+ SetGeneralConfiguration(writer http.ResponseWriter, r *http.Request)
}
type NodebController struct {
return
}
- request.Gnb = &gnb;
+ request.Gnb = &gnb
request.RanName = ranName
c.handleRequest(writer, &r.Header, httpmsghandlerprovider.UpdateGnbRequest, request, true)
}
+func (c *NodebController) SetGeneralConfiguration(writer http.ResponseWriter, r *http.Request) {
+ c.logger.Infof("[Client -> E2 Manager] #NodebController.SetGeneralConfiguration - request: %v", c.prettifyRequest(r))
+
+ request := models.GeneralConfigurationRequest{}
+
+ if !c.extractJsonBody(r, &request, writer){
+ return
+ }
+ c.handleRequest(writer, &r.Header, httpmsghandlerprovider.SetGeneralConfigurationRequest, request, false)
+}
+
func (c *NodebController) Shutdown(writer http.ResponseWriter, r *http.Request) {
c.logger.Infof("[Client -> E2 Manager] #NodebController.Shutdown - request: %v", c.prettifyRequest(r))
c.handleRequest(writer, &r.Header, httpmsghandlerprovider.ShutdownRequest, nil, false)
assert.Equal(t, errorResponse.Code, e2managererrors.NewRnibDbError().Code)
}
+func TestSetGeneralConfigurationHandlerRnibError(t *testing.T) {
+ controller, readerMock, _, _, _ := setupControllerTest(t)
+
+ configuration := &entities.GeneralConfiguration{}
+ readerMock.On("GetGeneralConfiguration").Return(configuration, e2managererrors.NewRnibDbError())
+
+ writer := httptest.NewRecorder()
+
+ httpRequest, _ := http.NewRequest("PUT", "https://localhost:3800/v1/nodeb/parameters", strings.NewReader("{\"enableRic\":false}"))
+
+ controller.SetGeneralConfiguration(writer, httpRequest)
+
+ var errorResponse = parseJsonRequest(t, writer.Body)
+
+ assert.Equal(t, http.StatusInternalServerError, writer.Result().StatusCode)
+ assert.Equal(t, e2managererrors.NewRnibDbError().Code, errorResponse.Code)
+}
+
+func TestSetGeneralConfigurationInvalidJson(t *testing.T) {
+ controller, _, _, _, _ := setupControllerTest(t)
+
+ writer := httptest.NewRecorder()
+
+ httpRequest, _ := http.NewRequest("PUT", "https://localhost:3800/v1/nodeb/parameters", strings.NewReader("{}{}"))
+
+ controller.SetGeneralConfiguration(writer, httpRequest)
+
+ var errorResponse = parseJsonRequest(t, writer.Body)
+
+ assert.Equal(t, http.StatusBadRequest, writer.Result().StatusCode)
+ assert.Equal(t, e2managererrors.NewInvalidJsonError().Code, errorResponse.Code)
+}
+
func controllerGetNodebTestExecuter(t *testing.T, context *controllerGetNodebTestContext) {
controller, readerMock, _, _, _ := setupControllerTest(t)
writer := httptest.NewRecorder()
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package httpmsghandlers
+
+import "C"
+import (
+ "e2mgr/e2managererrors"
+ "e2mgr/logger"
+ "e2mgr/models"
+ "e2mgr/services"
+)
+
+type SetGeneralConfigurationHandler struct {
+ rnibDataService services.RNibDataService
+ logger *logger.Logger
+}
+
+func NewSetGeneralConfigurationHandler(logger *logger.Logger, rnibDataService services.RNibDataService) *SetGeneralConfigurationHandler {
+ return &SetGeneralConfigurationHandler{
+ logger: logger,
+ rnibDataService: rnibDataService,
+ }
+}
+
+func (h *SetGeneralConfigurationHandler) Handle(request models.Request) (models.IResponse, error) {
+ h.logger.Infof("#SetGeneralConfigurationHandler.Handle - handling set general parameters")
+
+ configuration := request.(models.GeneralConfigurationRequest)
+
+ existingConfig, err := h.rnibDataService.GetGeneralConfiguration()
+
+ if err != nil {
+ h.logger.Errorf("#SetGeneralConfigurationHandler.Handle - Error fetching general configuration from rNib: %s", err)
+ return nil, e2managererrors.NewRnibDbError()
+ }
+
+ if existingConfig.EnableRic != configuration.EnableRic {
+
+ existingConfig.EnableRic = configuration.EnableRic
+ err := h.rnibDataService.SaveGeneralConfiguration(existingConfig)
+
+ if err != nil {
+ h.logger.Errorf("#SetGeneralConfigurationHandler.Handle - failed to save general configuration in RNIB. error: %s", err)
+ return nil, e2managererrors.NewRnibDbError()
+ }
+
+ }
+ response := &models.GeneralConfigurationResponse{EnableRic: configuration.EnableRic}
+
+ return response, nil
+}
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+package httpmsghandlers
+
+import (
+ "e2mgr/configuration"
+ "e2mgr/mocks"
+ "e2mgr/models"
+ "e2mgr/services"
+ "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/pkg/errors"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func setupSetGeneralConfigurationHandlerTest(t *testing.T) (*SetGeneralConfigurationHandler, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {
+ log := initLog(t)
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: 3}
+ readerMock := &mocks.RnibReaderMock{}
+ writerMock := &mocks.RnibWriterMock{}
+ rnibDataService := services.NewRnibDataService(log, config, readerMock, writerMock)
+ handler := NewSetGeneralConfigurationHandler(log, rnibDataService)
+ return handler, readerMock, writerMock
+}
+
+func TestSetGeneralConfigurationFalse_Success(t *testing.T) {
+ handler, readerMock, writerMock := setupSetGeneralConfigurationHandlerTest(t)
+
+ configuration := &entities.GeneralConfiguration{EnableRic: true}
+ readerMock.On("GetGeneralConfiguration").Return(configuration, nil)
+
+ updated := &entities.GeneralConfiguration{EnableRic: false}
+ writerMock.On("SaveGeneralConfiguration", updated).Return(nil)
+
+ response, err := handler.Handle(models.GeneralConfigurationRequest{EnableRic: false})
+
+ assert.Nil(t, err)
+ assert.NotNil(t, response)
+ assert.IsType(t, &models.GeneralConfigurationResponse{}, response)
+}
+
+func TestSetGeneralConfigurationTrue_Success(t *testing.T) {
+ handler, readerMock, writerMock := setupSetGeneralConfigurationHandlerTest(t)
+
+ configuration := &entities.GeneralConfiguration{EnableRic: false}
+ readerMock.On("GetGeneralConfiguration").Return(configuration, nil)
+
+ updated := &entities.GeneralConfiguration{EnableRic: true}
+ writerMock.On("SaveGeneralConfiguration", updated).Return(nil)
+
+ response, err := handler.Handle(models.GeneralConfigurationRequest{EnableRic: true})
+
+ assert.Nil(t, err)
+ assert.NotNil(t, response)
+ assert.IsType(t, &models.GeneralConfigurationResponse{}, response)
+}
+
+func TestSetGeneralConfigurationIgnore_Success(t *testing.T) {
+ handler, readerMock, _ := setupSetGeneralConfigurationHandlerTest(t)
+
+ configuration := &entities.GeneralConfiguration{EnableRic: false}
+ readerMock.On("GetGeneralConfiguration").Return(configuration, nil)
+
+ response, err := handler.Handle(models.GeneralConfigurationRequest{EnableRic: false})
+
+ assert.Nil(t, err)
+ assert.NotNil(t, response)
+ assert.IsType(t, &models.GeneralConfigurationResponse{}, response)
+}
+
+func TestSetGeneralConfigurationHandlerRnibError(t *testing.T) {
+ handler, readerMock, writerMock := setupSetGeneralConfigurationHandlerTest(t)
+
+ configuration := &entities.GeneralConfiguration{EnableRic: false}
+ readerMock.On("GetGeneralConfiguration").Return(configuration, nil)
+
+ updated := &entities.GeneralConfiguration{EnableRic: true}
+ writerMock.On("SaveGeneralConfiguration", updated).Return(common.NewInternalError(errors.New("error")))
+
+ response, err := handler.Handle(models.GeneralConfigurationRequest{EnableRic: true})
+
+ assert.NotNil(t, err)
+ assert.Nil(t, response)
+}
rr.HandleFunc("/{ranName}", nodebController.GetNodeb).Methods(http.MethodGet)
rr.HandleFunc("/{ranName}/update", nodebController.UpdateGnb).Methods(http.MethodPut)
rr.HandleFunc("/shutdown", nodebController.Shutdown).Methods(http.MethodPut)
+ rr.HandleFunc("/parameters", nodebController.SetGeneralConfiguration).Methods(http.MethodPut)
rrr := r.PathPrefix("/e2t").Subrouter()
rrr.HandleFunc("/list", e2tController.GetE2TInstances).Methods(http.MethodGet)
}
nodebControllerMock.On("Shutdown").Return(nil)
nodebControllerMock.On("GetNodeb").Return(nil)
nodebControllerMock.On("GetNodebIdList").Return(nil)
+ nodebControllerMock.On("SetGeneralConfiguration").Return(nil)
e2tControllerMock := &mocks.E2TControllerMock{}
nodebControllerMock.AssertNumberOfCalls(t, "Shutdown", 1)
}
+func TestRoutePutNodebSetGeneralConfiguration(t *testing.T) {
+ router, _, nodebControllerMock, _ := setupRouterAndMocks()
+
+ req, err := http.NewRequest("PUT", "/v1/nodeb/parameters", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rr := httptest.NewRecorder()
+ router.ServeHTTP(rr, req)
+
+ nodebControllerMock.AssertNumberOfCalls(t, "SetGeneralConfiguration", 1)
+}
+
func TestRouteNotFound(t *testing.T) {
router, _, _,_ := setupRouterAndMocks()
c.Called()
}
+
+func (c *NodebControllerMock) SetGeneralConfiguration(writer http.ResponseWriter, r *http.Request) {
+ writer.Header().Set("Content-Type", "application/json")
+ writer.WriteHeader(http.StatusOK)
+
+ c.Called()
+}
\ No newline at end of file
func (rnibWriterMock *RnibWriterMock) UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error {
args := rnibWriterMock.Called(nodebInfo, stateChangeMessageChannel, event)
+
+ return args.Error(0)
+}
+
+func (rnibWriterMock *RnibWriterMock) SaveGeneralConfiguration(config *entities.GeneralConfiguration) error {
+ args := rnibWriterMock.Called(config)
+
return args.Error(0)
}
\ No newline at end of file
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package models
+
+
+type GeneralConfigurationRequest struct {
+ EnableRic bool `json:"enableRic"`
+}
--- /dev/null
+//
+// Copyright 2019 AT&T Intellectual Property
+// Copyright 2019 Nokia
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This source code is part of the near-RT RIC (RAN Intelligent Controller)
+// platform project (RICP).
+
+
+package models
+
+import (
+ "e2mgr/e2managererrors"
+ "encoding/json"
+)
+
+type GeneralConfigurationResponse struct {
+ EnableRic bool `json:"enableRic"`
+}
+
+func (response *GeneralConfigurationResponse) Marshal() ([]byte, error) {
+
+ data, err := json.Marshal(response)
+
+ if err != nil {
+ return nil, e2managererrors.NewInternalError()
+ }
+
+ return data, nil
+}
\ No newline at end of file
type IncomingRequest string
const (
- ShutdownRequest IncomingRequest = "Shutdown"
- ResetRequest IncomingRequest = "Reset"
- X2SetupRequest IncomingRequest = "X2SetupRequest"
- EndcSetupRequest IncomingRequest = "EndcSetupRequest"
- GetNodebRequest IncomingRequest = "GetNodebRequest"
- GetNodebIdListRequest IncomingRequest = "GetNodebIdListRequest"
- GetE2TInstancesRequest IncomingRequest = "GetE2TInstancesRequest"
- UpdateGnbRequest IncomingRequest = "UpdateGnbRequest"
+ SetGeneralConfigurationRequest IncomingRequest = "SetGeneralConfiguration"
+ ShutdownRequest IncomingRequest = "Shutdown"
+ ResetRequest IncomingRequest = "Reset"
+ X2SetupRequest IncomingRequest = "X2SetupRequest"
+ EndcSetupRequest IncomingRequest = "EndcSetupRequest"
+ GetNodebRequest IncomingRequest = "GetNodebRequest"
+ GetNodebIdListRequest IncomingRequest = "GetNodebIdListRequest"
+ GetE2TInstancesRequest IncomingRequest = "GetE2TInstancesRequest"
+ UpdateGnbRequest IncomingRequest = "UpdateGnbRequest"
)
type IncomingRequestHandlerProvider struct {
func initRequestHandlerMap(logger *logger.Logger, rmrSender *rmrsender.RmrSender, config *configuration.Configuration, rNibDataService services.RNibDataService, ranSetupManager *managers.RanSetupManager, e2tInstancesManager managers.IE2TInstancesManager, e2tAssociationManager *managers.E2TAssociationManager, rmClient clients.IRoutingManagerClient) map[IncomingRequest]httpmsghandlers.RequestHandler {
return map[IncomingRequest]httpmsghandlers.RequestHandler{
- ShutdownRequest: httpmsghandlers.NewDeleteAllRequestHandler(logger, rmrSender, config, rNibDataService, e2tInstancesManager, rmClient),
- ResetRequest: httpmsghandlers.NewX2ResetRequestHandler(logger, rmrSender, rNibDataService),
- X2SetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_X2_SETUP_REQUEST, e2tInstancesManager, e2tAssociationManager),
- EndcSetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST, e2tInstancesManager, e2tAssociationManager),
- GetNodebRequest: httpmsghandlers.NewGetNodebRequestHandler(logger, rNibDataService),
- GetNodebIdListRequest: httpmsghandlers.NewGetNodebIdListRequestHandler(logger, rNibDataService),
- GetE2TInstancesRequest: httpmsghandlers.NewGetE2TInstancesRequestHandler(logger, e2tInstancesManager),
- UpdateGnbRequest: httpmsghandlers.NewUpdateGnbRequestHandler(logger, rNibDataService),
+ ShutdownRequest: httpmsghandlers.NewDeleteAllRequestHandler(logger, rmrSender, config, rNibDataService, e2tInstancesManager, rmClient),
+ ResetRequest: httpmsghandlers.NewX2ResetRequestHandler(logger, rmrSender, rNibDataService),
+ X2SetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_X2_SETUP_REQUEST, e2tInstancesManager, e2tAssociationManager),
+ EndcSetupRequest: httpmsghandlers.NewSetupRequestHandler(logger, rNibDataService, ranSetupManager, entities.E2ApplicationProtocol_ENDC_X2_SETUP_REQUEST, e2tInstancesManager, e2tAssociationManager),
+ GetNodebRequest: httpmsghandlers.NewGetNodebRequestHandler(logger, rNibDataService),
+ GetNodebIdListRequest: httpmsghandlers.NewGetNodebIdListRequestHandler(logger, rNibDataService),
+ GetE2TInstancesRequest: httpmsghandlers.NewGetE2TInstancesRequestHandler(logger, e2tInstancesManager),
+ UpdateGnbRequest: httpmsghandlers.NewUpdateGnbRequestHandler(logger, rNibDataService),
+ SetGeneralConfigurationRequest: httpmsghandlers.NewSetGeneralConfigurationHandler(logger, rNibDataService),
}
}
assert.True(t, ok)
}
+func TestSetGeneralConfigurationHandler(t *testing.T) {
+ provider := setupTest(t)
+ handler, err := provider.GetHandler(SetGeneralConfigurationRequest)
+
+ assert.NotNil(t, provider)
+ assert.Nil(t, err)
+
+ _, ok := handler.(*httpmsghandlers.SetGeneralConfigurationHandler)
+
+ assert.True(t, ok)
+}
+
func TestX2SetupRequestHandler(t *testing.T) {
provider := setupTest(t)
handler, err := provider.GetHandler(X2SetupRequest)
UpdateGnbCells(nodebInfo *entities.NodebInfo, servedNrCells []*entities.ServedNRCell) error
RemoveServedNrCells(inventoryName string, servedNrCells []*entities.ServedNRCell) error
UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, stateChangeMessageChannel string, event string) error
+ SaveGeneralConfiguration(config *entities.GeneralConfiguration) error
}
/*
return nil
}
+func (w *rNibWriterInstance) SaveGeneralConfiguration(config *entities.GeneralConfiguration) error {
+
+ err := w.SaveWithKeyAndMarshal(common.BuildGeneralConfigurationKey(), config)
+
+ if err != nil {
+ return common.NewInternalError(err)
+ }
+
+ return nil
+}
+
/*
SaveNodeb saves nodeB entity data in the redis DB according to the specified data model
*/
return nil
}
+func (w *rNibWriterInstance) SaveWithKeyAndMarshal(key string, entity interface{}) error {
+
+ data, err := json.Marshal(entity)
+
+ if err != nil {
+ return common.NewInternalError(err)
+ }
+
+ var pairs []interface{}
+ pairs = append(pairs, key, data)
+
+ err = w.sdl.Set(pairs)
+
+ if err != nil {
+ return common.NewInternalError(err)
+ }
+
+ return nil
+}
+
/*
UpdateNodebInfoOnConnectionStatusInversion...
*/
func isNotEmpty(nbIdentity *entities.NbIdentity) bool {
return nbIdentity.GlobalNbId != nil && nbIdentity.GlobalNbId.PlmnId != "" && nbIdentity.GlobalNbId.NbId != ""
-}
+}
\ No newline at end of file
assert.Nil(t, rNibErr)
}
+func TestSaveGeneralConfiguration(t *testing.T) {
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ key := common.BuildGeneralConfigurationKey()
+ configurationData := "{\"enableRic\":true}"
+ configuration := &entities.GeneralConfiguration{}
+ configuration.EnableRic = true
+
+ sdlInstanceMock.On("Set",[]interface{}{[]interface{}{key, []byte(configurationData)}}).Return(nil)
+ rNibErr := w.SaveGeneralConfiguration(configuration)
+
+ assert.Nil(t, rNibErr)
+ sdlInstanceMock.AssertExpectations(t)
+}
+
+func TestSaveGeneralConfigurationDbError(t *testing.T) {
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ key := common.BuildGeneralConfigurationKey()
+ configurationData := "{\"enableRic\":true}"
+ configuration := &entities.GeneralConfiguration{}
+ configuration.EnableRic = true
+
+ expectedErr := errors.New("expected error")
+
+ sdlInstanceMock.On("Set",[]interface{}{[]interface{}{key, []byte(configurationData)}}).Return(expectedErr)
+ rNibErr := w.SaveGeneralConfiguration(configuration)
+
+ assert.NotNil(t, rNibErr)
+}
+
//Integration tests
//
//func TestSaveEnbGnbInteg(t *testing.T){
RemoveServedNrCells(inventoryName string, servedNrCells []*entities.ServedNRCell) error
GetGeneralConfiguration() (*entities.GeneralConfiguration, error)
UpdateNodebInfoOnConnectionStatusInversion(nodebInfo *entities.NodebInfo, event string) error
+ SaveGeneralConfiguration(config *entities.GeneralConfiguration) error
}
type rNibDataService struct {
return generalConfiguration, err
}
+func (w *rNibDataService) SaveGeneralConfiguration(config *entities.GeneralConfiguration) error {
+ w.logger.Infof("#RnibDataService.SaveGeneralConfiguration - configuration: %+v", *config)
+
+ err := w.retry("SaveGeneralConfiguration", func() (err error) {
+ err = w.rnibWriter.SaveGeneralConfiguration(config)
+ return
+ })
+
+ return err
+}
+
func (w *rNibDataService) PingRnib() bool {
err := w.retry("GetListNodebIds", func() (err error) {
_, err = w.rnibReader.GetListNodebIds()
_ = json.NewEncoder(b).Encode(data)
req, _ := http.NewRequest("POST", "https://localhost:3800/request", b)
return req
-}
+}
\ No newline at end of file