Add new unit tests to improve E2 manager's unit test coverage.
Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I770ea21a6c07a515256ebe448e963940e3ececfb
func TestDeleteE2TInstanceFailure(t *testing.T) {
rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
- data := models.NewRoutingManagerDeleteRequestModel(E2TAddress, []string{"test1"},nil)
+ data := models.NewRoutingManagerDeleteRequestModel(E2TAddress, []string{"test1"}, nil)
marshaled, _ := json.Marshal(data)
body := bytes.NewBuffer(marshaled)
url := config.RoutingManager.BaseUrl + "e2t"
func TestDeleteE2TInstanceDeleteFailure(t *testing.T) {
rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
- data := models.NewRoutingManagerDeleteRequestModel(E2TAddress, []string{"test1"},nil)
+ data := models.NewRoutingManagerDeleteRequestModel(E2TAddress, []string{"test1"}, nil)
marshaled, _ := json.Marshal(data)
body := bytes.NewBuffer(marshaled)
url := config.RoutingManager.BaseUrl + "e2t"
assert.IsType(t, &e2managererrors.RoutingManagerError{}, err)
}
+func TestDissociateAllRans_Success(t *testing.T) {
+ rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
+
+ data := models.RoutingManagerE2TDataList{
+ models.NewRoutingManagerE2TData(E2TAddress),
+ models.NewRoutingManagerE2TData(E2TAddress2),
+ }
+ marshaled, _ := json.Marshal(data)
+ body := bytes.NewBuffer(marshaled)
+ url := config.RoutingManager.BaseUrl + DissociateRanE2TInstanceApiSuffix
+ respBody := ioutil.NopCloser(bytes.NewBufferString(""))
+ httpClientMock.On("Post", url, "application/json", body).Return(&http.Response{StatusCode: http.StatusCreated, Body: respBody}, nil)
+ err := rmClient.DissociateAllRans([]string{E2TAddress, E2TAddress2})
+ assert.Nil(t, err)
+}
+
+func TestDissociateAllRans_RoutingManagerError(t *testing.T) {
+ rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
+
+ data := models.RoutingManagerE2TDataList{
+ models.NewRoutingManagerE2TData(E2TAddress),
+ models.NewRoutingManagerE2TData(E2TAddress2),
+ }
+ marshaled, _ := json.Marshal(data)
+ body := bytes.NewBuffer(marshaled)
+ url := config.RoutingManager.BaseUrl + DissociateRanE2TInstanceApiSuffix
+ httpClientMock.On("Post", url, "application/json", body).Return(&http.Response{}, errors.New("error"))
+ err := rmClient.DissociateAllRans([]string{E2TAddress, E2TAddress2})
+ assert.IsType(t, &e2managererrors.RoutingManagerError{}, err)
+}
+
+func TestDissociateAllRans_RoutingManager_400(t *testing.T) {
+ rmClient, httpClientMock, config := initRoutingManagerClientTest(t)
+
+ data := models.RoutingManagerE2TDataList{
+ models.NewRoutingManagerE2TData(E2TAddress),
+ models.NewRoutingManagerE2TData(E2TAddress2),
+ }
+ marshaled, _ := json.Marshal(data)
+ body := bytes.NewBuffer(marshaled)
+ url := config.RoutingManager.BaseUrl + DissociateRanE2TInstanceApiSuffix
+ respBody := ioutil.NopCloser(bytes.NewBufferString(""))
+ httpClientMock.On("Post", url, "application/json", body).Return(&http.Response{StatusCode: http.StatusBadRequest, Body: respBody}, nil)
+ err := rmClient.DissociateAllRans([]string{E2TAddress, E2TAddress2})
+ assert.IsType(t, &e2managererrors.RoutingManagerError{}, err)
+}
+
// TODO: extract to test_utils
func initLog(t *testing.T) *logger.Logger {
log, err := logger.InitLogger(logger.InfoLevel)
assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
}
+func TestX2ResetHandleFailureBodyReadError(t *testing.T) {
+ controller, _, _, _, _, _ := setupControllerTest(t)
+
+ ranName := "test1"
+ writer := httptest.NewRecorder()
+
+ // Fake reader to return reading error.
+ req, _ := http.NewRequest("PUT", "https://localhost:3800/nodeb-reset", errReader(0))
+ req = mux.SetURLVars(req, map[string]string{"ranName": ranName})
+
+ controller.X2Reset(writer, req)
+ assert.Equal(t, http.StatusBadRequest, writer.Result().StatusCode)
+
+}
+
func TestX2ResetHandleFailureInvalidBody(t *testing.T) {
controller, _, _, _, _, _ := setupControllerTest(t)
}
+/*
+func TestControllerHealthCheckRequestSuccess(t *testing.T) {
+ controller, readerMock, _, rmrMessengerMock, _, _ := setupControllerTest(t)
+
+ ranName := "test1"
+ // o&m intervention
+ payload := []byte{0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x05, 0x40, 0x01, 0x64}
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ msg := rmrCgo.NewMBuf(rmrCgo.RIC_X2_RESET, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("SendMsg", msg, true).Return(msg, nil)
+
+ writer := httptest.NewRecorder()
+
+ var nodeb = &entities.NodebInfo{ConnectionStatus: entities.ConnectionStatus_CONNECTED}
+ readerMock.On("GetNodeb", ranName).Return(nodeb, nil)
+
+ data4Req := map[string]interface{}{"ranList": []string{"abcd"}}
+ b := new(bytes.Buffer)
+ _ = json.NewEncoder(b).Encode(data4Req)
+ req, _ := http.NewRequest("PUT", "https://localhost:3800/v1/nodeb/health", b)
+ req = mux.SetURLVars(req, map[string]string{"ranName": ranName})
+
+ controller.HealthCheckRequest(writer, req)
+ assert.Equal(t, http.StatusNoContent, writer.Result().StatusCode)
+}
+*/
+
func TestHandleErrorResponse(t *testing.T) {
controller, _, _, _, _, _ := setupControllerTest(t)
rmrMessengerMock.On("Init", tests.GetPort(), tests.MaxMsgSize, tests.Flags, log).Return(&rmrMessenger)
return rmrsender.NewRmrSender(log, rmrMessenger)
}
+
+type errReader int
+
+func (errReader) Read(p []byte) (n int, err error) {
+ return 0, errors.New("test error")
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+var testAddEnb = map[string]interface{}{
+ "ranName": "test",
+ "globalNbId": map[string]interface{}{
+ "plmnId": "whatever",
+ "nbId": "whatever2",
+ },
+ "enb": map[string]interface{}{
+ "enbType": 1,
+ "servedCells": []interface{}{
+ map[string]interface{}{
+ "cellId": "whatever",
+ "choiceEutraMode": map[string]interface{}{
+ "fdd": map[string]interface{}{},
+ },
+ "eutraMode": 1,
+ "pci": 1,
+ "tac": "whatever3",
+ "broadcastPlmns": []interface{}{
+ "whatever",
+ },
+ },
+ },
+ },
+}
+
+func TestAddEnbRequestSuccess(t *testing.T) {
+ addEnbRequest := models.AddEnbRequest{}
+ buf, err := json.Marshal(testAddEnb)
+ assert.Nil(t, err)
+
+ err = addEnbRequest.UnmarshalJSON(buf)
+ assert.Nil(t, err)
+ assert.Equal(t, "test", addEnbRequest.RanName)
+ assert.Equal(t, "whatever", addEnbRequest.GlobalNbId.PlmnId)
+ assert.Equal(t, "whatever2", addEnbRequest.GlobalNbId.NbId)
+ assert.Equal(t, entities.EnbType_MACRO_ENB, addEnbRequest.Enb.EnbType)
+ assert.Equal(t, uint32(1), addEnbRequest.Enb.ServedCells[0].Pci)
+ assert.Equal(t, "whatever", addEnbRequest.Enb.ServedCells[0].CellId)
+ assert.Equal(t, "whatever3", addEnbRequest.Enb.ServedCells[0].Tac)
+ assert.Equal(t, "whatever", addEnbRequest.Enb.ServedCells[0].BroadcastPlmns[0])
+ assert.Equal(t, entities.Eutra_FDD, addEnbRequest.Enb.ServedCells[0].EutraMode)
+}
+
+func TestAddEnbRequestJsonUnmarshalError(t *testing.T) {
+ addEnbRequest := models.AddEnbRequest{}
+
+ // Invalid json: attribute name without quotes (should be "cause":).
+ err := addEnbRequest.UnmarshalJSON([]byte("{ranName:\"test\""))
+ assert.NotNil(t, err)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "e2mgr/utils"
+ "encoding/xml"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+const (
+ e2SetupReqGnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_gnb.xml"
+ e2SetupReqEnGnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_en-gNB.xml"
+ e2SetupReqEnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_enb.xml"
+ e2SetupReqNgEnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_ng-eNB.xml"
+)
+
+func getTestE2SetupRequest(t *testing.T, reqXmlPath string) *models.E2SetupRequestMessage {
+ xmlGnb := utils.ReadXmlFile(t, reqXmlPath)
+ setupRequest := &models.E2SetupRequestMessage{}
+ err := xml.Unmarshal(utils.NormalizeXml(xmlGnb), &setupRequest.E2APPDU)
+ assert.Nil(t, err)
+ return setupRequest
+}
+
+func TestExtractRanFunctionsListFromGnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqGnbSetupRequestXmlPath)
+
+ ranFuncList := setupRequest.ExtractRanFunctionsList()
+ assert.Equal(t, uint32(1), ranFuncList[0].RanFunctionId)
+ assert.Equal(t, uint32(2), ranFuncList[1].RanFunctionId)
+ assert.Equal(t, uint32(3), ranFuncList[2].RanFunctionId)
+ assert.Equal(t, uint32(1), ranFuncList[0].RanFunctionRevision)
+ assert.Equal(t, uint32(1), ranFuncList[1].RanFunctionRevision)
+ assert.Equal(t, uint32(1), ranFuncList[2].RanFunctionRevision)
+}
+
+func TestGetPlmnIdFromGnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqGnbSetupRequestXmlPath)
+
+ plmnID := setupRequest.GetPlmnId()
+ assert.Equal(t, "02F829", plmnID)
+}
+
+func TestGetPlmnIdFromEnGnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqEnGnbSetupRequestXmlPath)
+
+ plmnID := setupRequest.GetPlmnId()
+ assert.Equal(t, "131014", plmnID)
+}
+
+func TestGetPlmnIdFromEnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqEnbSetupRequestXmlPath)
+
+ plmnID := setupRequest.GetPlmnId()
+ assert.Equal(t, "6359AB", plmnID)
+}
+
+func TestGetPlmnIdFromNgEnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqNgEnbSetupRequestXmlPath)
+
+ plmnID := setupRequest.GetPlmnId()
+ assert.Equal(t, "131014", plmnID)
+}
+
+func TestGetNbIdFromGnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqGnbSetupRequestXmlPath)
+
+ nbID := setupRequest.GetNbId()
+ assert.Equal(t, "001100000011000000110000", nbID)
+}
+
+func TestGetNbIdFromEnGnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqEnGnbSetupRequestXmlPath)
+
+ nbID := setupRequest.GetNbId()
+ assert.Equal(t, "11000101110001101100011111111000", nbID)
+}
+
+func TestGetNbIdFromEnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqEnbSetupRequestXmlPath)
+
+ nbID := setupRequest.GetNbId()
+ assert.Equal(t, "101010101010101010", nbID)
+}
+
+func TestGetNbIdFromNgEnbRequestSuccess(t *testing.T) {
+ setupRequest := getTestE2SetupRequest(t, e2SetupReqNgEnbSetupRequestXmlPath)
+
+ nbID := setupRequest.GetNbId()
+ assert.Equal(t, "101010101010101010", nbID)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "e2mgr/utils"
+ "encoding/xml"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+const (
+ e2SetupRespGnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_gnb.xml"
+ e2SetupRespEnGnbSetupRequestXmlPath = "../tests/resources/setupRequest/setupRequest_gnb_without_functions.xml"
+)
+
+func getE2SetupRespTestE2SetupRequest(t *testing.T, reqXmlPath string) *models.E2SetupRequestMessage {
+ xmlGnb := utils.ReadXmlFile(t, reqXmlPath)
+ setupRequest := &models.E2SetupRequestMessage{}
+ err := xml.Unmarshal(utils.NormalizeXml(xmlGnb), &setupRequest.E2APPDU)
+ assert.Nil(t, err)
+ return setupRequest
+}
+
+func TestNewE2SetupSuccessResponseMessageSuccess(t *testing.T) {
+ plmn := "23F749"
+ ricNearRtId := "10101010110011001110"
+ setupRequest := getE2SetupRespTestE2SetupRequest(t, e2SetupRespGnbSetupRequestXmlPath)
+
+ resp := models.NewE2SetupSuccessResponseMessage(plmn, ricNearRtId, setupRequest)
+ respIEs := resp.E2APPDU.Outcome.(models.SuccessfulOutcome).Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs
+ assert.Equal(t, "4", respIEs[0].ID)
+ assert.Equal(t, plmn, respIEs[0].Value.(models.GlobalRICID).GlobalRICID.PLMNIdentity)
+ assert.Equal(t, ricNearRtId, respIEs[0].Value.(models.GlobalRICID).GlobalRICID.RicID)
+ assert.Equal(t, "9", respIEs[1].ID)
+}
+
+func TestNewE2SetupSuccessResponseMessageWithoutRanFunctionsSuccess(t *testing.T) {
+ plmn := "23F749"
+ ricNearRtId := "10101010110011001110"
+ setupRequest := getE2SetupRespTestE2SetupRequest(t, e2SetupRespEnGnbSetupRequestXmlPath)
+
+ resp := models.NewE2SetupSuccessResponseMessage(plmn, ricNearRtId, setupRequest)
+ respIEs := resp.E2APPDU.Outcome.(models.SuccessfulOutcome).Value.E2setupResponse.ProtocolIEs.E2setupResponseIEs
+ assert.Equal(t, "4", respIEs[0].ID)
+ assert.Equal(t, plmn, respIEs[0].Value.(models.GlobalRICID).GlobalRICID.PLMNIdentity)
+ assert.Equal(t, ricNearRtId, respIEs[0].Value.(models.GlobalRICID).GlobalRICID.RicID)
+ assert.Equal(t, 1, len(respIEs))
+}
+
+func TestNewE2SetupFailureResponseMessageSuccess(t *testing.T) {
+ waitTime := models.TimeToWaitEnum.V60s
+ cause := models.Cause{Misc: &models.CauseMisc{OmIntervention: &struct{}{}}}
+
+ resp := models.NewE2SetupFailureResponseMessage(waitTime, cause)
+ respIEs := resp.E2APPDU.Outcome.(models.UnsuccessfulOutcome).Value.E2setupFailure.ProtocolIEs.E2setupFailureIEs
+ assert.Equal(t, "1", respIEs[0].ID)
+ assert.Equal(t, cause, respIEs[0].Value.Value.(models.Cause))
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestGeneralConfigurationResponseMarshalSuccess(t *testing.T) {
+ expectedGeneralConfigurationResponse := models.GeneralConfigurationResponse{
+ EnableRic: true,
+ }
+ expectedData, _ := json.Marshal(expectedGeneralConfigurationResponse)
+
+ response := &models.GeneralConfigurationResponse{EnableRic: true}
+ resp, err := response.Marshal()
+ assert.Nil(t, err)
+ assert.Equal(t, expectedData, resp)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestGetE2tInstancesResponseMarshalSuccess(t *testing.T) {
+ E2TAddress := "10.0.2.15:38000"
+ E2TAddress2 := "10.0.2.16:38001"
+ ranNames1 := []string{"test1", "test2", "test3"}
+ expectedE2TInstancesResponse := models.E2TInstancesResponse{
+ &models.E2TInstanceResponseModel{
+ E2TAddress: E2TAddress,
+ RanNames: ranNames1,
+ },
+ &models.E2TInstanceResponseModel{
+ E2TAddress: E2TAddress2,
+ RanNames: []string{},
+ },
+ }
+ e2tInstanceResponseModel1 := models.NewE2TInstanceResponseModel(E2TAddress, ranNames1)
+ e2tInstanceResponseModel2 := models.NewE2TInstanceResponseModel(E2TAddress2, []string{})
+ e2tInstancesResponse := models.E2TInstancesResponse{e2tInstanceResponseModel1, e2tInstanceResponseModel2}
+ expectedData, _ := json.Marshal(expectedE2TInstancesResponse)
+
+ resp, err := e2tInstancesResponse.Marshal()
+ assert.Nil(t, err)
+ assert.Equal(t, expectedData, resp)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestGetNodebIdListResponseMarshalSuccess(t *testing.T) {
+ nodebIdList := []*entities.NbIdentity{
+ {InventoryName: "test1", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"}},
+ {InventoryName: "test2", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId2", NbId: "nbId2"}},
+ }
+
+ nodebIdListResponse := models.NewGetNodebIdListResponse(nodebIdList)
+ _, err := nodebIdListResponse.Marshal()
+ assert.Nil(t, err)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestGetNodebIdResponseMarshalSuccess(t *testing.T) {
+ nodebId := &entities.NbIdentity{
+ InventoryName: "test1", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"},
+ }
+
+ nodebIdResponse := models.NewNodebIdResponse(nodebId)
+ _, err := nodebIdResponse.Marshal()
+ assert.Nil(t, err)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestHealthCheckResponseMarshalSuccess(t *testing.T) {
+ healthMsg := "OK"
+ expectedResponse := models.HealthCheckSuccessResponse{
+ Message: healthMsg,
+ }
+ expectedData, _ := json.Marshal(expectedResponse)
+
+ healthCheckSuccessResponse := models.NewHealthCheckSuccessResponse(healthMsg)
+ resp, err := healthCheckSuccessResponse.Marshal()
+ assert.Nil(t, err)
+ assert.Equal(t, expectedData, resp)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/golang/protobuf/jsonpb"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestNodebIdResponseMarshalSuccess(t *testing.T) {
+ nodebInfo := &entities.NodebInfo{
+ RanName: "test",
+ Ip: "10.20.30.40",
+ Port: 1234,
+ NodeType: entities.Node_GNB,
+ GlobalNbId: &entities.GlobalNbId{PlmnId: "02f829", NbId: "4a952a0a"},
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ }
+ response := models.NewNodebResponse(nodebInfo)
+ resp, err := response.Marshal()
+
+ m := jsonpb.Marshaler{}
+ expectedData, _ := m.MarshalToString(nodebInfo)
+ assert.Nil(t, err)
+ assert.Equal(t, []byte(expectedData), resp)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "github.com/stretchr/testify/assert"
+ "testing"
+ "time"
+ "unsafe"
+)
+
+func TestNotificationRequestGetMsgSrcSuccess(t *testing.T) {
+ testMsgSrc := unsafe.Pointer(new(int))
+ request := models.NewNotificationRequest("test", []byte{}, time.Now(), []byte("123456aa"), testMsgSrc)
+ msgSrc := request.GetMsgSrc()
+ assert.Equal(t, testMsgSrc, msgSrc)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestRedButtonPartialSuccessResponseModelMarshalSuccess(t *testing.T) {
+ message := "test"
+ expectedResponse := models.RedButtonPartialSuccessResponseModel{
+ Message: message,
+ }
+ expectedData, _ := json.Marshal(expectedResponse)
+
+ response := models.NewRedButtonPartialSuccessResponseModel(message)
+ resp, err := response.Marshal()
+ assert.Nil(t, err)
+ assert.Equal(t, expectedData, resp)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/enums"
+ "e2mgr/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestResourceStatusPayloadSuccess(t *testing.T) {
+ expectedResourceStatusPayload := &models.ResourceStatusPayload{
+ NodeType: entities.Node_ENB,
+ MessageDirection: enums.RIC_TO_RAN,
+ }
+
+ payload := models.NewResourceStatusPayload(entities.Node_ENB, enums.RIC_TO_RAN)
+ assert.Equal(t, expectedResourceStatusPayload, payload)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "e2mgr/utils"
+ "encoding/xml"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func getTestRicServiceQueryRanFunctions(t *testing.T) []*entities.RanFunction {
+ gnbSetupRequestXmlPath := "../tests/resources/setupRequest/setupRequest_gnb.xml"
+ xmlgnb := utils.ReadXmlFile(t, gnbSetupRequestXmlPath)
+
+ setupRequest := &models.E2SetupRequestMessage{}
+ err := xml.Unmarshal(utils.NormalizeXml(xmlgnb), &setupRequest.E2APPDU)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ranFunctionList := setupRequest.ExtractRanFunctionsList()
+ return ranFunctionList
+}
+
+func TestRicServiceQueryMessageSuccess(t *testing.T) {
+ ranFunctionList := getTestRicServiceQueryRanFunctions(t)
+
+ serviceQuery := models.NewRicServiceQueryMessage(ranFunctionList)
+ initMsg := serviceQuery.E2APPDU.InitiatingMessage
+ assert.Equal(t, "6", initMsg.ProcedureCode)
+ assert.Equal(t, "9", initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Id)
+ assert.Equal(t, 3, len(initMsg.Value.RICServiceQuery.ProtocolIEs.RICServiceQueryIEs[0].Value.RANFunctionIdList.ProtocolIESingleContainer))
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestRicServiceUpdateAckMessageSuccess(t *testing.T) {
+ item1 := models.RicServiceAckRANFunctionIDItem{RanFunctionID: 100, RanFunctionRevision: 200}
+ item2 := models.RicServiceAckRANFunctionIDItem{RanFunctionID: 101, RanFunctionRevision: 201}
+ serviceupdateAckFunctionIds := []models.RicServiceAckRANFunctionIDItem{
+ item1,
+ item2,
+ }
+
+ serviceUpdateAck := models.NewServiceUpdateAck(serviceupdateAckFunctionIds)
+ ies := serviceUpdateAck.InitiatingMessage.(models.RicServiceUpdateAckSuccessfulOutcome).Value.RICserviceUpdateAcknowledge.ProtocolIEs.RICserviceUpdateAcknowledgeIEs
+ assert.Equal(t, "9", ies[0].ID)
+ assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Id)
+ assert.Equal(t, "6", ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Id)
+ assert.Equal(t, item1, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[0].Value.RANfunctionIDItem)
+ assert.Equal(t, item2, ies[0].Value.RANfunctionsIDList.ProtocolIESingleContainer[1].Value.RANfunctionIDItem)
+}
+
+func TestRicServiceUpdateAckMessageNoRanFunctionIdItemsSuccess(t *testing.T) {
+ successfulOutcome := models.RicServiceUpdateAckSuccessfulOutcome{}
+ successfulOutcome.ProcedureCode = "7"
+
+ expectedAck := models.RicServiceUpdateAckE2APPDU{InitiatingMessage: successfulOutcome}
+ serviceUpdateAck := models.NewServiceUpdateAck(nil)
+ assert.Equal(t, expectedAck, serviceUpdateAck)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "e2mgr/utils"
+ "encoding/xml"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func getTestRicServiceUpdate(t *testing.T, xmlPath string) *models.RICServiceUpdateMessage {
+ xmlServiceUpdate := utils.ReadXmlFile(t, xmlPath)
+ ricServiceUpdate := &models.RICServiceUpdateMessage{}
+ err := xml.Unmarshal(utils.NormalizeXml(xmlServiceUpdate), &ricServiceUpdate.E2APPDU)
+ assert.Nil(t, err)
+ return ricServiceUpdate
+}
+
+func TestRicServiceUpdateMessageSuccess(t *testing.T) {
+ serviceUpdate := getTestRicServiceUpdate(t, "../tests/resources/serviceUpdate/RicServiceUpdate_AddedFunction.xml")
+
+ ranFunctions := serviceUpdate.E2APPDU.ExtractRanFunctionsList()
+ assert.Equal(t, uint32(20), ranFunctions[0].RanFunctionId)
+ assert.Equal(t, uint32(2), ranFunctions[0].RanFunctionRevision)
+}
+
+func TestRicServiceUpdateMessageNoRanFunctions(t *testing.T) {
+ serviceUpdate := getTestRicServiceUpdate(t, "../tests/resources/serviceUpdate/RicServiceUpdate_Empty.xml")
+ assert.Nil(t, serviceUpdate.E2APPDU.ExtractRanFunctionsList())
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "github.com/stretchr/testify/assert"
+ "testing"
+ "unsafe"
+)
+
+func TestRmrMessageGetMsgSrcSuccess(t *testing.T) {
+ testMsgSrc := unsafe.Pointer(new(int))
+ rmrMsg := models.NewRmrMessage(123, "test", []byte("some payload"), []byte{}, testMsgSrc)
+ msgSrc := rmrMsg.GetMsgSrc()
+ assert.Equal(t, testMsgSrc, msgSrc)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestRoutingManagerDeleteRequestModelSuccess(t *testing.T) {
+ address := "10.0.2.15:38000"
+ ranNames := []string{"test1", "test2"}
+ expectedDelReqModel := &models.RoutingManagerDeleteRequestModel{
+ E2TAddress: address,
+ RanNameListToBeDissociated: ranNames,
+ }
+
+ delReqModel := models.NewRoutingManagerDeleteRequestModel(address, ranNames, nil)
+ assert.Equal(t, expectedDelReqModel, delReqModel)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+func TestRoutingManagerE2tDataSuccess(t *testing.T) {
+ address := "10.0.2.15:38000"
+ ranNames := []string{"test1", "test2"}
+ expectedE2tData := &models.RoutingManagerE2TData{
+ E2TAddress: address,
+ RanNamelist: ranNames,
+ }
+
+ e2tDataModel := models.NewRoutingManagerE2TData(address, ranNames...)
+ assert.Equal(t, expectedE2tData, e2tDataModel)
+}
+
+func TestRoutingManagerE2tDataNoRanNameListSuccess(t *testing.T) {
+ address := "10.0.2.15:38000"
+ expectedE2tData := &models.RoutingManagerE2TData{
+ E2TAddress: address,
+ }
+
+ e2tDataModel := models.NewRoutingManagerE2TData(address)
+ assert.Equal(t, expectedE2tData, e2tDataModel)
+}
--- /dev/null
+//
+// Copyright 2020 AT&T Intellectual Property
+// Copyright 2020 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_test
+
+import (
+ "e2mgr/models"
+ "encoding/json"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+var testUpdateEnb = map[string]interface{}{
+ "enb": map[string]interface{}{
+ "enbType": 1,
+ "servedCells": []interface{}{
+ map[string]interface{}{
+ "cellId": "whatever",
+ "choiceEutraMode": map[string]interface{}{
+ "fdd": map[string]interface{}{},
+ },
+ "eutraMode": 1,
+ "pci": 1,
+ "tac": "whatever3",
+ "broadcastPlmns": []interface{}{
+ "whatever",
+ },
+ },
+ },
+ },
+}
+
+func TestUpdateEnbRequestUnmarshalJsonSuccess(t *testing.T) {
+ updateEnbRequest := models.UpdateEnbRequest{}
+ buf, err := json.Marshal(testUpdateEnb)
+ assert.Nil(t, err)
+
+ err = updateEnbRequest.UnmarshalJSON(buf)
+ assert.Nil(t, err)
+ assert.Equal(t, entities.EnbType_MACRO_ENB, updateEnbRequest.Enb.EnbType)
+ assert.Equal(t, uint32(1), updateEnbRequest.Enb.ServedCells[0].Pci)
+ assert.Equal(t, "whatever", updateEnbRequest.Enb.ServedCells[0].CellId)
+ assert.Equal(t, "whatever3", updateEnbRequest.Enb.ServedCells[0].Tac)
+ assert.Equal(t, "whatever", updateEnbRequest.Enb.ServedCells[0].BroadcastPlmns[0])
+ assert.Equal(t, entities.Eutra_FDD, updateEnbRequest.Enb.ServedCells[0].EutraMode)
+}
+
+func TestUpdateEnbRequestJsonUnmarshalError(t *testing.T) {
+ updateEnbRequest := models.UpdateEnbRequest{}
+ // Invalid json: attribute name without quotes (should be "cause":).
+ err := updateEnbRequest.UnmarshalJSON([]byte("{ranName:\"test\""))
+ assert.NotNil(t, err)
+}
const (
RanName = "test"
- PlmnId = "02f829"
- NbId = "4a952a0a"
+ PlmnId = "02f829"
+ NbId = "4a952a0a"
)
func initSdlInstanceMock(namespace string) (w RNibWriter, sdlInstanceMock *mocks.MockSdlInstance) {
servedNrCells = append(servedNrCells, &entities.ServedNRCell{ServedNrCellInformation: &entities.ServedNRCellInformation{
CellId: v,
ChoiceNrMode: &entities.ServedNRCellInformation_ChoiceNRMode{
- Fdd: &entities.ServedNRCellInformation_ChoiceNRMode_FddInfo{
-
- },
+ Fdd: &entities.ServedNRCellInformation_ChoiceNRMode_FddInfo{},
},
NrMode: entities.Nr_FDD,
NrPci: uint32(i + 1),
func TestAddNbIdentitySuccess(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
- nbIdentity := &entities.NbIdentity{InventoryName: RanName, GlobalNbId: &entities.GlobalNbId{PlmnId: PlmnId, NbId: NbId}}
+ nbIdentity := &entities.NbIdentity{InventoryName: RanName, GlobalNbId: &entities.GlobalNbId{PlmnId: PlmnId, NbId: NbId}}
nbIdData, err := proto.Marshal(nbIdentity)
if err != nil {
t.Fatalf("#rNibWriter_test.TestAddNbIdentitySuccess - Failed to marshal NodeB Identity entity. Error: %v", err)
}
sdlInstanceMock.On("AddMember", "ENB", []interface{}{nbIdData}).Return(nil)
- rNibErr := w.AddNbIdentity(entities.Node_ENB,nbIdentity)
+ rNibErr := w.AddNbIdentity(entities.Node_ENB, nbIdentity)
assert.Nil(t, rNibErr)
}
+func TestAddNbIdentityMarshalNilFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+
+ rNibErr := w.AddNbIdentity(entities.Node_ENB, nil)
+ expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
+ assert.Equal(t, expectedErr, rNibErr)
+}
+
func TestAddNbIdentitySdlFailure(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
- nbIdentity := &entities.NbIdentity{InventoryName: RanName, GlobalNbId: &entities.GlobalNbId{PlmnId: PlmnId, NbId: NbId}}
+ nbIdentity := &entities.NbIdentity{InventoryName: RanName, GlobalNbId: &entities.GlobalNbId{PlmnId: PlmnId, NbId: NbId}}
nbIdData, err := proto.Marshal(nbIdentity)
if err != nil {
t.Fatalf("#rNibWriter_test.TestAddNbIdentitySdlFailure - Failed to marshal NodeB Identity entity. Error: %v", err)
}
sdlInstanceMock.On("AddMember", "ENB", []interface{}{nbIdData}).Return(errors.New("expected error"))
- rNibErr := w.AddNbIdentity(entities.Node_ENB,nbIdentity)
+ rNibErr := w.AddNbIdentity(entities.Node_ENB, nbIdentity)
assert.IsType(t, &common.InternalError{}, rNibErr)
}
assert.IsType(t, &common.InternalError{}, rNibErr)
}
+func TestUpdateGnbCellsRnibKeyValidationError(t *testing.T) {
+ //Empty RAN name fails RNIB validation
+ inventoryName := ""
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, _ := initSdlInstanceMock(namespace)
+ servedNrCells := generateServedNrCells("test1", "test2")
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_GNB, plmnId, nbId)
+ nodebInfo.GetGnb().ServedNrCells = servedNrCells
+
+ rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+}
+
func TestUpdateGnbCellsSuccess(t *testing.T) {
inventoryName := "name"
plmnId := "02f829"
nodebInfo.GetGnb().ServedNrCells = servedNrCells
setExpected := getUpdateGnbCellsSetExpected(t, nodebInfo, servedNrCells)
var e error
- sdlInstanceMock.On("SetAndPublish",[]string{"RAN_MANIPULATION", inventoryName + "_" + RanUpdatedEvent}, []interface{}{setExpected}).Return(e)
+ sdlInstanceMock.On("SetAndPublish", []string{"RAN_MANIPULATION", inventoryName + "_" + RanUpdatedEvent}, []interface{}{setExpected}).Return(e)
rNibErr := w.UpdateGnbCells(nodebInfo, servedNrCells)
assert.Nil(t, rNibErr)
}
setExpected = append(setExpected, nodebNameKey, data)
setExpected = append(setExpected, nodebIdKey, data)
- sdlInstanceMock.On("SetAndPublish",[]string{"RAN_MANIPULATION", inventoryName + "_" + RanUpdatedEvent}, []interface{}{setExpected}).Return(e)
+ sdlInstanceMock.On("SetAndPublish", []string{"RAN_MANIPULATION", inventoryName + "_" + RanUpdatedEvent}, []interface{}{setExpected}).Return(e)
rNibErr := w.UpdateNodebInfoAndPublish(nodebInfo)
assert.Nil(t, rNibErr)
sdlInstanceMock.AssertExpectations(t)
}
-
func TestUpdateNodebInfoMissingInventoryNameFailure(t *testing.T) {
inventoryName := "name"
plmnId := "02f829"
assert.Nil(t, rNibErr)
}
+func TestUpdateNodebInfoSdlSetFailure(t *testing.T) {
+ inventoryName := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ 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)
+ }
+ e := errors.New("expected error")
+ var setExpected []interface{}
+
+ nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
+ nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
+ setExpected = append(setExpected, nodebNameKey, data)
+ setExpected = append(setExpected, nodebIdKey, data)
+
+ sdlInstanceMock.On("Set", []interface{}{setExpected}).Return(e)
+
+ rNibErr := w.UpdateNodebInfo(nodebInfo)
+ assert.NotNil(t, rNibErr)
+ assert.IsType(t, &common.InternalError{}, rNibErr)
+ sdlInstanceMock.AssertExpectations(t)
+}
+
func TestSaveEnb(t *testing.T) {
ranName := "RAN:" + RanName
w, sdlInstanceMock := initSdlInstanceMock(namespace)
assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
}
+func TestSaveEnbGlobalNbIdPlmnValidationFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+ nb := entities.NodebInfo{
+ RanName: RanName,
+ NodeType: entities.Node_ENB,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ Ip: "localhost",
+ Port: 5656,
+ GlobalNbId: &entities.GlobalNbId{
+ NbId: "4a952a0a",
+ //Empty PLMNID fails RNIB validation
+ PlmnId: "",
+ },
+ }
+ enb := entities.Enb{}
+ cell := &entities.ServedCellInfo{CellId: "aaa", Pci: 3}
+ enb.ServedCells = []*entities.ServedCellInfo{cell}
+ nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
+ rNibErr := w.SaveNodeb(&nb)
+ assert.NotNil(t, rNibErr)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+ assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received", rNibErr.Error())
+}
+
func TestSaveGnbCellIdValidationFailure(t *testing.T) {
w, _ := initSdlInstanceMock(namespace)
nb := entities.NodebInfo{}
ranName := "RAN:" + RanName
w, sdlInstanceMock := initSdlInstanceMock(namespace)
nb := entities.NodebInfo{
- RanName: RanName,
+ RanName: RanName,
NodeType: entities.Node_GNB,
ConnectionStatus: 1,
GlobalNbId: &entities.GlobalNbId{
w, sdlInstanceMock := initSdlInstanceMock(namespace)
gnb := entities.NodebInfo{
- RanName: name,
+ RanName: name,
NodeType: entities.Node_GNB,
ConnectionStatus: 1,
GlobalNbId: &entities.GlobalNbId{
w, sdlInstanceMock := initSdlInstanceMock(namespace)
enb := entities.NodebInfo{
- RanName: name,
+ RanName: name,
NodeType: entities.Node_ENB,
ConnectionStatus: 1,
GlobalNbId: &entities.GlobalNbId{
assert.Nil(t, rNibErr)
}
+func TestUpdateNodebInfoOnConnectionStatusInversionSdlFailure(t *testing.T) {
+ inventoryName := "name"
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ channelName := "RAN_CONNECTION_STATUS_CHANGE"
+ eventName := inventoryName + "_" + "CONNECTED"
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_ENB, plmnId, nbId)
+ data, err := proto.Marshal(nodebInfo)
+ if err != nil {
+ t.Errorf("#rNibWriter_test.TestUpdateNodebInfoOnConnectionStatusInversionSuccess - Failed to marshal NodeB entity. Error: %v", err)
+ }
+ e := errors.New("expected error")
+ var setExpected []interface{}
+
+ nodebNameKey := fmt.Sprintf("RAN:%s", inventoryName)
+ nodebIdKey := fmt.Sprintf("ENB:%s:%s", plmnId, nbId)
+ setExpected = append(setExpected, nodebNameKey, data)
+ setExpected = append(setExpected, nodebIdKey, data)
+
+ sdlInstanceMock.On("SetAndPublish", []string{channelName, eventName}, []interface{}{setExpected}).Return(e)
+
+ rNibErr := w.UpdateNodebInfoOnConnectionStatusInversion(nodebInfo, eventName)
+ assert.NotNil(t, rNibErr)
+ assert.IsType(t, &common.InternalError{}, rNibErr)
+}
+
func TestSaveGeneralConfiguration(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
assert.IsType(t, &common.ValidationError{}, rNibErr)
}
+func TestUpdateEnbRnibKeyValidationError(t *testing.T) {
+ //Empty RAN name fails RNIB validation
+ inventoryName := ""
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, _ := initSdlInstanceMock(namespace)
+ servedCells := generateServedCells("test1", "test2")
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_ENB, plmnId, nbId)
+ nodebInfo.GetEnb().ServedCells = servedCells
+
+ rNibErr := w.UpdateEnb(nodebInfo, servedCells)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+}
+
func TestUpdateEnbSdlFailure(t *testing.T) {
inventoryName := "name"
plmnId := "02f829"
sdlInstanceMock.AssertExpectations(t)
}
+func TestRemoveEnbRnibKeyValidationError(t *testing.T) {
+ //Empty RAN name fails RNIB key validation
+ inventoryName := ""
+ plmnId := "02f829"
+ nbId := "4a952a0a"
+ w, _ := initSdlInstanceMock(namespace)
+ nodebInfo := generateNodebInfo(inventoryName, entities.Node_ENB, plmnId, nbId)
+ nodebInfo.GetEnb().ServedCells = generateServedCellInfos("cell1", "cell2")
+
+ rNibErr := w.RemoveEnb(nodebInfo)
+ assert.NotNil(t, rNibErr)
+}
+
func TestRemoveEnbRemoveAndPublishError(t *testing.T) {
inventoryName := "name"
plmnId := "02f829"
sdlInstanceMock.AssertExpectations(t)
}
+func TestRemoveNbIdentityMarshalNilFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+
+ rNibErr := w.RemoveNbIdentity(entities.Node_ENB, nil)
+ expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
+ assert.Equal(t, expectedErr, rNibErr)
+}
+
func TestRemoveNbIdentityError(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
nbIdentity := &entities.NbIdentity{InventoryName: "ran1", ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"}}
assert.Nil(t, rNibErr)
}
+func TestAddEnbMarshalNilFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+
+ rNibErr := w.AddEnb(nil)
+ expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
+ assert.Equal(t, expectedErr, rNibErr)
+}
+
func TestAddEnbCellIdValidationFailure(t *testing.T) {
w, _ := initSdlInstanceMock(namespace)
nb := entities.NodebInfo{}
assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", rNibErr.Error())
}
+func TestAddEnbGlobalNbIdPlmnValidationFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+ nb := entities.NodebInfo{
+ RanName: "name",
+ NodeType: entities.Node_ENB,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ Ip: "localhost",
+ Port: 5656,
+ GlobalNbId: &entities.GlobalNbId{
+ NbId: "4a952a0a",
+ //Empty PLMNID fails RNIB validation
+ PlmnId: "",
+ },
+ }
+ enb := entities.Enb{}
+ cell := &entities.ServedCellInfo{CellId: "aaa", Pci: 3}
+ enb.ServedCells = []*entities.ServedCellInfo{cell}
+ nb.Configuration = &entities.NodebInfo_Enb{Enb: &enb}
+ rNibErr := w.AddEnb(&nb)
+ assert.NotNil(t, rNibErr)
+ assert.IsType(t, &common.ValidationError{}, rNibErr)
+ assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received", rNibErr.Error())
+}
+
func TestUpdateNbIdentityOneMemberSuccess(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
sdlInstanceMock.AssertExpectations(t)
}
+func TestUpdateNbIdentityOldIdentityMarshalNilFailure(t *testing.T) {
+ w, _ := initSdlInstanceMock(namespace)
+
+ oldNbIdIdentities := []*entities.NbIdentity{nil}
+ newNbIdIdentities := []*entities.NbIdentity{
+ &entities.NbIdentity{
+ InventoryName: "ran1_add",
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1_add", NbId: "nbId1_add"},
+ },
+ }
+
+ expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
+ rNibErr := w.UpdateNbIdentities(entities.Node_ENB, oldNbIdIdentities, newNbIdIdentities)
+ assert.Equal(t, expectedErr, rNibErr)
+}
+
+func TestUpdateNbIdentityNewIdentityMarshalNilFailure(t *testing.T) {
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ var nbIdIdentitiesProtoToRemove []interface{}
+ protoRan1, _ := createNbIdentityProto(t, "ran1", "plmnId1", "nbId1", entities.ConnectionStatus_DISCONNECTED)
+ nbIdIdentitiesProtoToRemove = append(nbIdIdentitiesProtoToRemove, protoRan1)
+ sdlInstanceMock.On("RemoveMember", entities.Node_ENB.String(), nbIdIdentitiesProtoToRemove).Return(nil)
+
+ oldNbIdIdentities := []*entities.NbIdentity{
+ &entities.NbIdentity{
+ InventoryName: "ran1",
+ ConnectionStatus: entities.ConnectionStatus_DISCONNECTED,
+ GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"},
+ },
+ }
+ newNbIdIdentities := []*entities.NbIdentity{nil}
+
+ expectedErr := common.NewInternalError(errors.New("proto: Marshal called with nil"))
+ rNibErr := w.UpdateNbIdentities(entities.Node_ENB, oldNbIdIdentities, newNbIdIdentities)
+ assert.Equal(t, expectedErr, rNibErr)
+}
+
func TestUpdateNbIdentityRemoveFailure(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
sdlInstanceMock.AssertExpectations(t)
}
+func TestUpdateNbIdentitySdlAddMemberFailure(t *testing.T) {
+ w, sdlInstanceMock := initSdlInstanceMock(namespace)
+
+ var nbIdIdentitiesProtoToRemove []interface{}
+ protoRan1, _ := createNbIdentityProto(t, "ran1", "plmnId1", "nbId1", entities.ConnectionStatus_DISCONNECTED)
+ nbIdIdentitiesProtoToRemove = append(nbIdIdentitiesProtoToRemove, protoRan1)
+ sdlInstanceMock.On("RemoveMember", entities.Node_ENB.String(), nbIdIdentitiesProtoToRemove).Return(nil)
+
+ var nbIdIdentitiesProtoToAdd []interface{}
+ protoRan1Add, _ := createNbIdentityProto(t, "ran1_add", "plmnId1_add", "nbId1_add", entities.ConnectionStatus_CONNECTED)
+ nbIdIdentitiesProtoToAdd = append(nbIdIdentitiesProtoToAdd, protoRan1Add)
+ sdlInstanceMock.On("AddMember", entities.Node_ENB.String(), nbIdIdentitiesProtoToAdd).Return(fmt.Errorf("for test"))
+
+ var oldNbIdIdentities []*entities.NbIdentity
+ firstOldNbIdIdentity := &entities.NbIdentity{InventoryName: "ran1", ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"}}
+ oldNbIdIdentities = append(oldNbIdIdentities, firstOldNbIdIdentity)
+
+ var newNbIdIdentities []*entities.NbIdentity
+ firstNewNbIdIdentity := &entities.NbIdentity{InventoryName: "ran1_add", ConnectionStatus: entities.ConnectionStatus_CONNECTED, GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1_add", NbId: "nbId1_add"}}
+ newNbIdIdentities = append(newNbIdIdentities, firstNewNbIdIdentity)
+
+ rNibErr := w.UpdateNbIdentities(entities.Node_ENB, oldNbIdIdentities, newNbIdIdentities)
+ assert.NotNil(t, rNibErr)
+ sdlInstanceMock.AssertExpectations(t)
+}
+
func TestUpdateNbIdentityAddFailure(t *testing.T) {
w, sdlInstanceMock := initSdlInstanceMock(namespace)
nbIdentity := &entities.NbIdentity{InventoryName: "ran1", ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"}}
sdlInstanceMock.AssertExpectations(t)
}
-func createNbIdentityProto(t *testing.T, ranName string, plmnId string, nbId string, connectionStatus entities.ConnectionStatus) ([]byte, *entities.NbIdentity){
+func createNbIdentityProto(t *testing.T, ranName string, plmnId string, nbId string, connectionStatus entities.ConnectionStatus) ([]byte, *entities.NbIdentity) {
nbIdentity := &entities.NbIdentity{InventoryName: ranName, ConnectionStatus: connectionStatus, GlobalNbId: &entities.GlobalNbId{PlmnId: plmnId, NbId: nbId}}
nbIdData, err := proto.Marshal(nbIdentity)
if err != nil {
t.Errorf("#createNbIdentityProto - failed to Marshal NbIdentity")
}
return nbIdData, nbIdentity
-}
\ No newline at end of file
+}
// This source code is part of the near-RT RIC (RAN Intelligent Controller)
// platform project (RICP).
-
package rmrsender
import (
rmrSender := NewRmrSender(logger, rmrMessenger)
err := rmrSender.Send(rmrMsg)
assert.Nil(t, err)
- rmrMessengerMock.AssertCalled(t, "SendMsg",mbuf, true)
+ rmrMessengerMock.AssertCalled(t, "SendMsg", mbuf, true)
}
rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
rmrSender := NewRmrSender(logger, rmrMessenger)
err := rmrSender.Send(rmrMsg)
- rmrMessengerMock.AssertCalled(t, "SendMsg",mbuf, true)
+ rmrMessengerMock.AssertCalled(t, "SendMsg", mbuf, true)
+ assert.NotNil(t, err)
+}
+
+func TestRmrSenderSendWithoutLogsSuccess(t *testing.T) {
+ logger, rmrMessengerMock := initRmrSenderTest(t)
+
+ ranName := "test"
+ payload := []byte("some payload")
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ mbuf := rmrCgo.NewMBuf(123, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("SendMsg", mbuf, false).Return(&rmrCgo.MBuf{}, nil)
+ rmrMsg := models.NewRmrMessage(123, ranName, payload, xAction, nil)
+ rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
+ rmrSender := NewRmrSender(logger, rmrMessenger)
+ err := rmrSender.SendWithoutLogs(rmrMsg)
+ assert.Nil(t, err)
+ rmrMessengerMock.AssertCalled(t, "SendMsg", mbuf, false)
+
+}
+
+func TestRmrSenderSendWithoutLogsFailure(t *testing.T) {
+ logger, rmrMessengerMock := initRmrSenderTest(t)
+
+ ranName := "test"
+ payload := []byte("some payload")
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ mbuf := rmrCgo.NewMBuf(123, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("SendMsg", mbuf, false).Return(mbuf, fmt.Errorf("rmr send failure"))
+ rmrMsg := models.NewRmrMessage(123, ranName, payload, xAction, nil)
+ rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
+ rmrSender := NewRmrSender(logger, rmrMessenger)
+ err := rmrSender.SendWithoutLogs(rmrMsg)
+ rmrMessengerMock.AssertCalled(t, "SendMsg", mbuf, false)
+ assert.NotNil(t, err)
+}
+
+func TestRmrSenderWhSendSuccess(t *testing.T) {
+ logger, rmrMessengerMock := initRmrSenderTest(t)
+
+ ranName := "test"
+ payload := []byte("some payload")
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ mbuf := rmrCgo.NewMBuf(123, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("WhSendMsg", mbuf, true).Return(&rmrCgo.MBuf{}, nil)
+ rmrMsg := models.NewRmrMessage(123, ranName, payload, xAction, nil)
+ rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
+ rmrSender := NewRmrSender(logger, rmrMessenger)
+ err := rmrSender.WhSend(rmrMsg)
+ assert.Nil(t, err)
+ rmrMessengerMock.AssertCalled(t, "WhSendMsg", mbuf, true)
+}
+
+func TestRmrSenderWhSendFailure(t *testing.T) {
+ logger, rmrMessengerMock := initRmrSenderTest(t)
+
+ ranName := "test"
+ payload := []byte("some payload")
+ var xAction []byte
+ var msgSrc unsafe.Pointer
+ mbuf := rmrCgo.NewMBuf(123, len(payload), ranName, &payload, &xAction, msgSrc)
+ rmrMessengerMock.On("WhSendMsg", mbuf, true).Return(mbuf, fmt.Errorf("rmr send failure"))
+ rmrMsg := models.NewRmrMessage(123, ranName, payload, xAction, nil)
+ rmrMessenger := rmrCgo.RmrMessenger(rmrMessengerMock)
+ rmrSender := NewRmrSender(logger, rmrMessenger)
+ err := rmrSender.WhSend(rmrMsg)
+ rmrMessengerMock.AssertCalled(t, "WhSendMsg", mbuf, true)
assert.NotNil(t, err)
}
writerMock.AssertNumberOfCalls(t, "UpdateNodebInfo", 3)
}
+func TestSuccessfulUpdateNodebInfoAndPublish(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateNodebInfoAndPublish", nodebInfo).Return(nil)
+
+ rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoAndPublish", 1)
+}
+
+func TestConnFailureUpdateNodebInfoAndPublish(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNodebInfoAndPublish", nodebInfo).Return(mockErr)
+
+ rnibDataService.UpdateNodebInfoAndPublish(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebInfoAndPublish", 3)
+}
+
func TestSuccessfulSaveRanLoadInformation(t *testing.T) {
rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
assert.Equal(t, nodeIds, res)
}
+func TestGetGeneralConfigurationConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var config *entities.GeneralConfiguration = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetGeneralConfiguration").Return(config, mockErr)
+
+ res, err := rnibDataService.GetGeneralConfiguration()
+ readerMock.AssertNumberOfCalls(t, "GetGeneralConfiguration", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetGeneralConfigurationOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ config := &entities.GeneralConfiguration{}
+ readerMock.On("GetGeneralConfiguration").Return(config, nil)
+
+ res, err := rnibDataService.GetGeneralConfiguration()
+ readerMock.AssertNumberOfCalls(t, "GetGeneralConfiguration", 1)
+ assert.Equal(t, config, res)
+ assert.Nil(t, err)
+}
+
+func TestGetGeneralConfigurationOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var config *entities.GeneralConfiguration = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetGeneralConfiguration").Return(config, mockErr)
+
+ res, err := rnibDataService.GetGeneralConfiguration()
+ readerMock.AssertNumberOfCalls(t, "GetGeneralConfiguration", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestSaveGeneralConfigurationConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ config := &entities.GeneralConfiguration{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("SaveGeneralConfiguration", config).Return(mockErr)
+
+ err := rnibDataService.SaveGeneralConfiguration(config)
+ writerMock.AssertNumberOfCalls(t, "SaveGeneralConfiguration", 3)
+ assert.NotNil(t, err)
+}
+
+func TestSaveGeneralConfigurationOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ config := &entities.GeneralConfiguration{}
+ writerMock.On("SaveGeneralConfiguration", config).Return(nil)
+
+ err := rnibDataService.SaveGeneralConfiguration(config)
+ writerMock.AssertNumberOfCalls(t, "SaveGeneralConfiguration", 1)
+ assert.Nil(t, err)
+}
+
+func TestSaveGeneralConfigurationOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ config := &entities.GeneralConfiguration{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("SaveGeneralConfiguration", config).Return(mockErr)
+
+ err := rnibDataService.SaveGeneralConfiguration(config)
+ writerMock.AssertNumberOfCalls(t, "SaveGeneralConfiguration", 1)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveServedCellsConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ var ranName string = "abcd"
+ cellIds := []*entities.ServedCellInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("RemoveServedCells", ranName, cellIds).Return(mockErr)
+
+ err := rnibDataService.RemoveServedCells(ranName, cellIds)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedCells", 3)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveServedCellsOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ var ranName string = "abcd"
+ cellIds := []*entities.ServedCellInfo{}
+ writerMock.On("RemoveServedCells", ranName, cellIds).Return(nil)
+
+ err := rnibDataService.RemoveServedCells(ranName, cellIds)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedCells", 1)
+ assert.Nil(t, err)
+}
+
+func TestRemoveServedCellsOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ var ranName string = "abcd"
+ cellIds := []*entities.ServedCellInfo{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("RemoveServedCells", ranName, cellIds).Return(mockErr)
+
+ err := rnibDataService.RemoveServedCells(ranName, cellIds)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedCells", 1)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateEnbConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ cellIds := []*entities.ServedCellInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateEnb", nodebInfo, cellIds).Return(mockErr)
+
+ err := rnibDataService.UpdateEnb(nodebInfo, cellIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateEnb", 3)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateEnbOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ cellIds := []*entities.ServedCellInfo{}
+ writerMock.On("UpdateEnb", nodebInfo, cellIds).Return(nil)
+
+ err := rnibDataService.UpdateEnb(nodebInfo, cellIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateEnb", 1)
+ assert.Nil(t, err)
+}
+
+func TestUpdateEnbOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ cellIds := []*entities.ServedCellInfo{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("UpdateEnb", nodebInfo, cellIds).Return(mockErr)
+
+ err := rnibDataService.UpdateEnb(nodebInfo, cellIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateEnb", 1)
+ assert.NotNil(t, err)
+}
+
+func TestAddEnbConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("AddEnb", nodebInfo).Return(mockErr)
+
+ err := rnibDataService.AddEnb(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "AddEnb", 3)
+ assert.NotNil(t, err)
+}
+
+func TestAddEnbOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("AddEnb", nodebInfo).Return(nil)
+
+ err := rnibDataService.AddEnb(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "AddEnb", 1)
+ assert.Nil(t, err)
+}
+
+func TestAddEnbOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("AddEnb", nodebInfo).Return(mockErr)
+
+ err := rnibDataService.AddEnb(nodebInfo)
+ writerMock.AssertNumberOfCalls(t, "AddEnb", 1)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateNbIdentityConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeId := &entities.NbIdentity{}
+ newNodeId := &entities.NbIdentity{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNbIdentities", gnbType, []*entities.NbIdentity{oldNodeId},
+ []*entities.NbIdentity{newNodeId}).Return(mockErr)
+
+ err := rnibDataService.UpdateNbIdentity(gnbType, oldNodeId, newNodeId)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 3)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateNbIdentityOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeId := &entities.NbIdentity{}
+ newNodeId := &entities.NbIdentity{}
+ writerMock.On("UpdateNbIdentities", gnbType, []*entities.NbIdentity{oldNodeId},
+ []*entities.NbIdentity{newNodeId}).Return(nil)
+
+ err := rnibDataService.UpdateNbIdentity(gnbType, oldNodeId, newNodeId)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 1)
+ assert.Nil(t, err)
+}
+
+func TestUpdateNbIdentityOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeId := &entities.NbIdentity{}
+ newNodeId := &entities.NbIdentity{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("UpdateNbIdentities", gnbType, []*entities.NbIdentity{oldNodeId},
+ []*entities.NbIdentity{newNodeId}).Return(mockErr)
+
+ err := rnibDataService.UpdateNbIdentity(gnbType, oldNodeId, newNodeId)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 1)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateNbIdentitiesConnFailure(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeIds := []*entities.NbIdentity{}
+ newNodeIds := []*entities.NbIdentity{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNbIdentities", gnbType, oldNodeIds, newNodeIds).Return(mockErr)
+
+ err := rnibDataService.UpdateNbIdentities(gnbType, oldNodeIds, newNodeIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 3)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateNbIdentitiesOkNoError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeIds := []*entities.NbIdentity{}
+ newNodeIds := []*entities.NbIdentity{}
+ writerMock.On("UpdateNbIdentities", gnbType, oldNodeIds, newNodeIds).Return(nil)
+
+ err := rnibDataService.UpdateNbIdentities(gnbType, oldNodeIds, newNodeIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 1)
+ assert.Nil(t, err)
+}
+
+func TestUpdateNbIdentitiesOtherError(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ gnbType := entities.Node_GNB
+ oldNodeIds := []*entities.NbIdentity{}
+ newNodeIds := []*entities.NbIdentity{}
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ writerMock.On("UpdateNbIdentities", gnbType, oldNodeIds, newNodeIds).Return(mockErr)
+
+ err := rnibDataService.UpdateNbIdentities(gnbType, oldNodeIds, newNodeIds)
+ writerMock.AssertNumberOfCalls(t, "UpdateNbIdentities", 1)
+ assert.NotNil(t, err)
+}
+
func TestPingRnibConnFailure(t *testing.T) {
rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
assert.Equal(t, e2tInstance, res)
}
-func TestGetE2TInstanceOkOtherError(t *testing.T) {
+func TestGetE2TInstanceOtherError(t *testing.T) {
rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
address := "10.10.5.20:3200"
assert.NotNil(t, err)
}
+func TestGetE2TInstanceNoLogsConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ address := "10.10.5.20:3200"
+ var e2tInstance *entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetE2TInstance", address).Return(e2tInstance, mockErr)
+
+ res, err := rnibDataService.GetE2TInstanceNoLogs(address)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstance", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TInstanceNoLogsOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ address := "10.10.5.20:3200"
+ e2tInstance := &entities.E2TInstance{}
+ readerMock.On("GetE2TInstance", address).Return(e2tInstance, nil)
+
+ res, err := rnibDataService.GetE2TInstanceNoLogs(address)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstance", 1)
+ assert.Nil(t, err)
+ assert.Equal(t, e2tInstance, res)
+}
+
+func TestGetE2TInstanceNoLogsOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ address := "10.10.5.20:3200"
+ var e2tInstance *entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetE2TInstance", address).Return(e2tInstance, mockErr)
+
+ res, err := rnibDataService.GetE2TInstanceNoLogs(address)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstance", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TInstancesConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ var e2tInstances []*entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstances, mockErr)
+
+ res, err := rnibDataService.GetE2TInstances(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TInstancesOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ e2tInstance := []*entities.E2TInstance{}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstance, nil)
+
+ res, err := rnibDataService.GetE2TInstances(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 1)
+ assert.Nil(t, err)
+ assert.Equal(t, e2tInstance, res)
+}
+
+func TestGetE2TInstancesOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ var e2tInstances []*entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstances, mockErr)
+
+ res, err := rnibDataService.GetE2TInstances(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TInstancesNoLogsConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ var e2tInstances []*entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstances, mockErr)
+
+ res, err := rnibDataService.GetE2TInstancesNoLogs(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TInstancesNoLogsOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ e2tInstance := []*entities.E2TInstance{}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstance, nil)
+
+ res, err := rnibDataService.GetE2TInstancesNoLogs(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 1)
+ assert.Nil(t, err)
+ assert.Equal(t, e2tInstance, res)
+}
+
+func TestGetE2TInstancesNoLogsOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ var e2tInstances []*entities.E2TInstance = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetE2TInstances", addresses).Return(e2tInstances, mockErr)
+
+ res, err := rnibDataService.GetE2TInstancesNoLogs(addresses)
+ readerMock.AssertNumberOfCalls(t, "GetE2TInstances", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TAddressesConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var addresses []string = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetE2TAddresses").Return(addresses, mockErr)
+
+ res, err := rnibDataService.GetE2TAddresses()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TAddressesOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ readerMock.On("GetE2TAddresses").Return(addresses, nil)
+
+ res, err := rnibDataService.GetE2TAddresses()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 1)
+ assert.Nil(t, err)
+ assert.Equal(t, addresses, res)
+}
+
+func TestGetE2TAddressesOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var addresses []string = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetE2TAddresses").Return(addresses, mockErr)
+
+ res, err := rnibDataService.GetE2TAddresses()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TAddressesNoLogsConnFailure(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var addresses []string = nil
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ readerMock.On("GetE2TAddresses").Return(addresses, mockErr)
+
+ res, err := rnibDataService.GetE2TAddressesNoLogs()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 3)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestGetE2TAddressesNoLogsOkNoError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ readerMock.On("GetE2TAddresses").Return(addresses, nil)
+
+ res, err := rnibDataService.GetE2TAddressesNoLogs()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 1)
+ assert.Nil(t, err)
+ assert.Equal(t, addresses, res)
+}
+
+func TestGetE2TAddressesNoLogsOtherError(t *testing.T) {
+ rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
+
+ var addresses []string = nil
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ readerMock.On("GetE2TAddresses").Return(addresses, mockErr)
+
+ res, err := rnibDataService.GetE2TAddressesNoLogs()
+ readerMock.AssertNumberOfCalls(t, "GetE2TAddresses", 1)
+ assert.Nil(t, res)
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TInstanceConnFailure(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(mockErr)
+
+ err := rnibDataService.SaveE2TInstance(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 3)
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TInstanceOkNoError(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(nil)
+
+ err := rnibDataService.SaveE2TInstance(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 1)
+ assert.Nil(t, err)
+}
+
+func TestSaveE2TInstanceOtherError(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(mockErr)
+
+ err := rnibDataService.SaveE2TInstance(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 1)
+
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TInstanceNoLogsConnFailure(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(mockErr)
+
+ err := rnibDataService.SaveE2TInstanceNoLogs(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 3)
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TInstanceNoLogsOkNoError(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(nil)
+
+ err := rnibDataService.SaveE2TInstanceNoLogs(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 1)
+ assert.Nil(t, err)
+}
+
+func TestSaveE2TInstanceNoLogsOtherError(t *testing.T) {
+ e2tInstance := &entities.E2TInstance{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("SaveE2TInstance", e2tInstance).Return(mockErr)
+
+ err := rnibDataService.SaveE2TInstanceNoLogs(e2tInstance)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TInstance", 1)
+
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TAddressesConnFailure(t *testing.T) {
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("SaveE2TAddresses", addresses).Return(mockErr)
+
+ err := rnibDataService.SaveE2TAddresses(addresses)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TAddresses", 3)
+ assert.NotNil(t, err)
+}
+
+func TestSaveE2TAddressesOkNoError(t *testing.T) {
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("SaveE2TAddresses", addresses).Return(nil)
+
+ err := rnibDataService.SaveE2TAddresses(addresses)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TAddresses", 1)
+ assert.Nil(t, err)
+}
+
+func TestSaveE2TAddressesOtherError(t *testing.T) {
+ addresses := []string{"10.10.5.20:3200", "10.10.5.21:3200"}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("SaveE2TAddresses", addresses).Return(mockErr)
+
+ err := rnibDataService.SaveE2TAddresses(addresses)
+ writerMock.AssertNumberOfCalls(t, "SaveE2TAddresses", 1)
+
+ assert.NotNil(t, err)
+}
+
+func TestRemoveE2TInstanceConnFailure(t *testing.T) {
+ address := "10.10.5.20:3200"
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("RemoveE2TInstance", address).Return(mockErr)
+
+ err := rnibDataService.RemoveE2TInstance(address)
+ writerMock.AssertNumberOfCalls(t, "RemoveE2TInstance", 3)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveE2TInstanceOkNoError(t *testing.T) {
+ address := "10.10.5.20:3200"
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("RemoveE2TInstance", address).Return(nil)
+
+ err := rnibDataService.RemoveE2TInstance(address)
+ writerMock.AssertNumberOfCalls(t, "RemoveE2TInstance", 1)
+ assert.Nil(t, err)
+}
+
+func TestRemoveE2TInstanceOtherError(t *testing.T) {
+ address := "10.10.5.20:3200"
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("RemoveE2TInstance", address).Return(mockErr)
+
+ err := rnibDataService.RemoveE2TInstance(address)
+ writerMock.AssertNumberOfCalls(t, "RemoveE2TInstance", 1)
+
+ assert.NotNil(t, err)
+}
+
+func TestAddNbIdentityConnFailure(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("AddNbIdentity", gnbType, nbIdentity).Return(mockErr)
+
+ err := rnibDataService.AddNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "AddNbIdentity", 3)
+ assert.NotNil(t, err)
+}
+
+func TestAddNbIdentityOkNoError(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("AddNbIdentity", gnbType, nbIdentity).Return(nil)
+
+ err := rnibDataService.AddNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "AddNbIdentity", 1)
+ assert.Nil(t, err)
+}
+
+func TestAddNbIdentityOtherError(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("AddNbIdentity", gnbType, nbIdentity).Return(mockErr)
+
+ err := rnibDataService.AddNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "AddNbIdentity", 1)
+
+ assert.NotNil(t, err)
+}
+
+func TestRemoveNbIdentityConnFailure(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("RemoveNbIdentity", gnbType, nbIdentity).Return(mockErr)
+
+ err := rnibDataService.RemoveNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "RemoveNbIdentity", 3)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveNbIdentityOkNoError(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("RemoveNbIdentity", gnbType, nbIdentity).Return(nil)
+
+ err := rnibDataService.RemoveNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "RemoveNbIdentity", 1)
+ assert.Nil(t, err)
+}
+
+func TestRemoveNbIdentityOtherError(t *testing.T) {
+ gnbType := entities.Node_GNB
+ nbIdentity := &entities.NbIdentity{}
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("RemoveNbIdentity", gnbType, nbIdentity).Return(mockErr)
+
+ err := rnibDataService.RemoveNbIdentity(gnbType, nbIdentity)
+ writerMock.AssertNumberOfCalls(t, "RemoveNbIdentity", 1)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveServedNrCellsConnFailure(t *testing.T) {
+ var ranName string = "abcd"
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+
+ writerMock.On("RemoveServedNrCells", ranName, servedNrCells).Return(mockErr)
+
+ err := rnibDataService.RemoveServedNrCells(ranName, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedNrCells", 3)
+ assert.NotNil(t, err)
+}
+
+func TestRemoveServedNrCellsOkNoError(t *testing.T) {
+ var ranName string = "abcd"
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ writerMock.On("RemoveServedNrCells", ranName, servedNrCells).Return(nil)
+
+ err := rnibDataService.RemoveServedNrCells(ranName, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedNrCells", 1)
+ assert.Nil(t, err)
+}
+
+func TestRemoveServedNrCellsOtherError(t *testing.T) {
+ var ranName string = "abcd"
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+
+ writerMock.On("RemoveServedNrCells", ranName, servedNrCells).Return(mockErr)
+
+ err := rnibDataService.RemoveServedNrCells(ranName, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "RemoveServedNrCells", 1)
+ assert.NotNil(t, err)
+}
+
func TestRemoveEnbConnFailure(t *testing.T) {
rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
writerMock.AssertNumberOfCalls(t, "RemoveEnb", 1)
assert.NotNil(t, err)
}
+
+func TestUpdateGnbCellsConnFailure(t *testing.T) {
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateGnbCells", nodebInfo, servedNrCells).Return(mockErr)
+
+ err := rnibDataService.UpdateGnbCells(nodebInfo, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "UpdateGnbCells", 3)
+ assert.NotNil(t, err)
+}
+
+func TestUpdateGnbCellsOkNoError(t *testing.T) {
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateGnbCells", nodebInfo, servedNrCells).Return(nil)
+
+ err := rnibDataService.UpdateGnbCells(nodebInfo, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "UpdateGnbCells", 1)
+ assert.Nil(t, err)
+}
+
+func TestUpdateGnbCellsOtherError(t *testing.T) {
+ var servedNrCells []*entities.ServedNRCell
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+
+ mockErr := &common.InternalError{Err: fmt.Errorf("non connection error")}
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateGnbCells", nodebInfo, servedNrCells).Return(mockErr)
+
+ err := rnibDataService.UpdateGnbCells(nodebInfo, servedNrCells)
+ writerMock.AssertNumberOfCalls(t, "UpdateGnbCells", 1)
+ assert.NotNil(t, err)
+}