--- /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 ***
+Variables ../Scripts/variables.py
+Resource ../Resource/resource.robot
+Resource ../Resource/Keywords.robot
+Library OperatingSystem
+Library ../Scripts/find_rmr_message.py
+Library ../Scripts/log_scripts.py
+Library REST ${url}
+
+*** Variables ***
+${url} ${e2mgr_address}
+
+*** Test Cases ***
+[Setup]
+ Start Redis Monitor
+ Prepare Enviorment ${True}
+
+
+Restart Simulator
+ Restart simulator
+ wait until keyword succeeds 2 min 10 sec Validate Required Dockers
+
+Prepare Logs For Tests
+ Remove log files
+ Save logs
+
+Redis Monitor Logs - Verify Publish
+ Redis Monitor Logs - Verify Publish To Connection Status Channel ${ranName} CONNECTED
+ Redis Monitor Logs - Verify NOT Published To Manipulation Channel ${ranName} UPDATED
+
+
+[Teardown]
+ Stop Redis Monitor
+
+
+
+
+
#
*** Settings ***
-Documentation Setup eNB
+Documentation E2 Setup
Save logs
E2M Logs - Verify Update
+ Sleep 2s
${result} log_scripts.verify_log_message ${EXECDIR}/${e2mgr_log_filename} ${update_gnb_log_message}
Should Be Equal As Strings ${result} True
# The Jenkins job requires a tag to build the Docker image.
# Global-JJB script assumes this file is in the repo root.
---
-tag: 5.4.3
+tag: 5.4.4
if context.updateEnbCellsParams != nil {
updatedNodebInfo := *context.getNodebInfoResult.nodebInfo
+
+ if context.getNodebInfoResult.nodebInfo.SetupFromNetwork {
+ updateEnbRequest.Enb.EnbType = context.getNodebInfoResult.nodebInfo.GetEnb().EnbType
+ }
+
updatedNodebInfo.Configuration = &entities.NodebInfo_Enb{Enb: updateEnbRequest.Enb}
writerMock.On("UpdateEnb", &updatedNodebInfo, updateEnbRequest.Enb.ServedCells).Return(context.updateEnbCellsParams.err)
func controllerDeleteEnbTestExecuter(t *testing.T, context *controllerDeleteEnbTestContext, preAddNbIdentity bool) {
controller, readerMock, writerMock, nbIdentity := setupDeleteEnbControllerTest(t, preAddNbIdentity)
readerMock.On("GetNodeb", RanName).Return(context.getNodebInfoResult.nodebInfo, context.getNodebInfoResult.rnibError)
- if context.getNodebInfoResult.rnibError == nil && context.getNodebInfoResult.nodebInfo.GetNodeType() == entities.Node_ENB {
+ if context.getNodebInfoResult.rnibError == nil && context.getNodebInfoResult.nodebInfo.GetNodeType() == entities.Node_ENB &&
+ !context.getNodebInfoResult.nodebInfo.SetupFromNetwork {
writerMock.On("RemoveEnb", context.getNodebInfoResult.nodebInfo).Return(nil)
if preAddNbIdentity {
writerMock.On("RemoveNbIdentity", entities.Node_ENB, nbIdentity).Return(nil)
controllerUpdateEnbTestExecuter(t, &context)
}
+func TestControllerUpdateEnbNgEnbFailure(t *testing.T) {
+
+ requestBody := map[string]interface{}{
+ "enb": map[string]interface{}{
+ "enbType": 5,
+ "servedCells": []interface{}{
+ buildServedCell(""),
+ }},
+ }
-func TestControllerUpdateEnbSuccess(t *testing.T) {
+ context := controllerUpdateEnbTestContext{
+ getNodebInfoResult: nil,
+ requestBody: requestBody,
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: ValidationFailureJson,
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
+func TestControllerUpdateEnbSuccessSetupFromNwFalse(t *testing.T) {
oldServedCells := generateServedCells("whatever1", "whatever2")
context := controllerUpdateEnbTestContext{
removeServedCellsParams: &removeServedCellsParams{
ConnectionStatus: entities.ConnectionStatus_CONNECTED,
AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
NodeType: entities.Node_ENB,
- Configuration: &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells, EnbType: entities.EnbType_MACRO_ENB}},
+ Configuration: &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells, EnbType: entities.EnbType_LONG_MACRO_ENB}},
},
rnibError: nil,
},
controllerUpdateEnbTestExecuter(t, &context)
}
+func TestControllerUpdateEnbSuccessSetupFromNwTrue(t *testing.T) {
+ oldServedCells := generateServedCells("whatever1", "whatever2")
+ context := controllerUpdateEnbTestContext{
+ removeServedCellsParams: &removeServedCellsParams{
+ err: nil,
+ servedCellInfo: oldServedCells,
+ },
+ updateEnbCellsParams: &updateEnbCellsParams{
+ err: nil,
+ },
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: &entities.NodebInfo{
+ RanName: RanName,
+ ConnectionStatus: entities.ConnectionStatus_CONNECTED,
+ AssociatedE2TInstanceAddress: AssociatedE2TInstanceAddress,
+ NodeType: entities.Node_ENB,
+ Configuration: &entities.NodebInfo_Enb{Enb: &entities.Enb{ServedCells: oldServedCells, EnbType: entities.EnbType_LONG_MACRO_ENB}},
+ SetupFromNetwork: true,
+ },
+ rnibError: nil,
+ },
+ requestBody: getUpdateEnbRequest(""),
+ expectedStatusCode: http.StatusOK,
+ expectedJsonResponse: "{\"ranName\":\"test\",\"connectionStatus\":\"CONNECTED\",\"nodeType\":\"ENB\",\"enb\":{\"enbType\":\"LONG_MACRO_ENB\",\"servedCells\":[{\"pci\":1,\"cellId\":\"whatever\",\"tac\":\"whatever3\",\"broadcastPlmns\":[\"whatever\"],\"choiceEutraMode\":{\"fdd\":{}},\"eutraMode\":\"FDD\"}]},\"associatedE2tInstanceAddress\":\"10.0.2.15:38000\",\"setupFromNetwork\":true}",
+ }
+
+ controllerUpdateEnbTestExecuter(t, &context)
+}
+
/*
AddEnb UTs
*/
}
}
+func TestControllerAddEnbNgEnbFailure(t *testing.T) {
+
+ requestBody := map[string]interface{}{
+ "ranName": RanName,
+ "globalNbId": buildGlobalNbId(""),
+ "enb": map[string]interface{}{
+ "enbType": 5,
+ "servedCells": []interface{}{
+ buildServedCell(""),
+ },
+ },
+ }
+
+ context := controllerAddEnbTestContext{
+ requestBody: requestBody,
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: ValidationFailureJson,
+ }
+
+ controllerAddEnbTestExecuter(t, &context)
+}
+
func TestControllerAddEnbSuccess(t *testing.T) {
context := controllerAddEnbTestContext{
addEnbParams: &addEnbParams{
controllerDeleteEnbTestExecuter(t, &context, false)
}
+func TestControllerDeleteEnbSetupFromNetworkTrueFailure(t *testing.T) {
+ context := controllerDeleteEnbTestContext{
+ getNodebInfoResult: &getNodebInfoResult{
+ nodebInfo: &entities.NodebInfo{RanName: RanName, NodeType: entities.Node_ENB, ConnectionStatus: entities.ConnectionStatus_DISCONNECTED, SetupFromNetwork: true},
+ rnibError: nil,
+ },
+ expectedStatusCode: http.StatusBadRequest,
+ expectedJsonResponse: ValidationFailureJson,
+ }
+ controllerDeleteEnbTestExecuter(t, &context, true)
+}
+
func TestControllerDeleteEnbSuccess(t *testing.T) {
context := controllerDeleteEnbTestContext{
getNodebInfoResult: &getNodebInfoResult{
func TestHandleDeleteEnbFromNetworkError(t *testing.T) {
handler, readerMock, _ := setupDeleteEnbRequestHandlerTest(t, false)
-
ranName := "ran1"
nodebInfo := &entities.NodebInfo{RanName: ranName, NodeType: entities.Node_ENB, SetupFromNetwork: true}
readerMock.On("GetNodeb", ranName).Return(nodebInfo, nil)
- //writerMock.On("RemoveEnb", nodebInfo).Return(nil)
result, err := handler.Handle(&models.DeleteEnbRequest{RanName: ranName})
assert.NotNil(t, err)
assert.Nil(t, result)
gnbNodebRanName = "gnb:310-410-b5c67788"
enbNodebRanName = "enB_macro:P310-410-b5c67788"
GnbSetupRequestXmlPath = "../../tests/resources/setupRequest_gnb.xml"
+ GnbWithZeroFunctionsSetupRequestXmlPath = "../../tests/resources/setupRequest_gnb_with_zero_functions.xml"
EnGnbSetupRequestXmlPath = "../../tests/resources/setupRequest_en-gNB.xml"
NgEnbSetupRequestXmlPath = "../../tests/resources/setupRequest_ng-eNB.xml"
EnbSetupRequestXmlPath = "../../tests/resources/setupRequest_enb.xml"
/* Existing Ran UTs - BEGIN */
-func getExpectedNodebForExistingRan(nodeb entities.NodebInfo, payload []byte) *entities.NodebInfo {
+func getExpectedNodebForExistingRan(nodeb *entities.NodebInfo, payload []byte) *entities.NodebInfo {
pipInd := bytes.IndexByte(payload, '|')
setupRequest := &models.E2SetupRequestMessage{}
_ = xml.Unmarshal(normalizeXml(payload[pipInd+1:]), &setupRequest.E2APPDU)
+ nb := *nodeb
+
if nodeb.NodeType == entities.Node_ENB {
- return &nodeb
+ return &nb
}
if ranFuncs := setupRequest.ExtractRanFunctionsList(); ranFuncs != nil {
- nodeb.GetGnb().RanFunctions = ranFuncs
+ updatedGnb := *nodeb.GetGnb()
+ updatedGnb.RanFunctions = ranFuncs
+ nb.Configuration =&entities.NodebInfo_Gnb{Gnb: &updatedGnb}
}
- return &nodeb
+
+ return &nb
}
func TestE2SetupRequestNotificationHandler_HandleExistingConnectedEnbSuccess(t *testing.T) {
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
notificationRequest := &models.NotificationRequest{RanName: enbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xmlEnb...)}
- enbToUpdate := getExpectedNodebForExistingRan(*nodebInfo, notificationRequest.Payload)
+ enbToUpdate := getExpectedNodebForExistingRan(nodebInfo, notificationRequest.Payload)
enbToUpdate.SetupFromNetwork = true
writerMock.On("UpdateNodebInfo", enbToUpdate).Return(nil)
e2tInstancesManagerMock.On("AddRansToInstance", e2tInstanceFullAddress, []string{enbNodebRanName}).Return(nil)
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
notificationRequest := &models.NotificationRequest{RanName: enbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xmlEnb...)}
- enbToUpdate := getExpectedNodebForExistingRan(*nodebInfo, notificationRequest.Payload)
+ enbToUpdate := getExpectedNodebForExistingRan(nodebInfo, notificationRequest.Payload)
enbToUpdate2 := *enbToUpdate
enbToUpdate2.ConnectionStatus = entities.ConnectionStatus_CONNECTED
rmrMessengerMock.AssertCalled(t, "SendMsg", mock.Anything, true)
}
-func testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t *testing.T, withFunctions bool) {
- var xmlGnb []byte
-
- if withFunctions {
- xmlGnb = readXmlFile(t, GnbSetupRequestXmlPath)
-
- } else {
- xmlGnb = readXmlFile(t, GnbWithoutFunctionsSetupRequestXmlPath)
- }
+func testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t *testing.T, withFunctions bool, xmlToRead string) {
+ xmlGnb := readXmlFile(t, xmlToRead)
handler, readerMock, writerMock, rmrMessengerMock, e2tInstancesManagerMock, routingManagerClientMock := initMocks(t)
readerMock.On("GetGeneralConfiguration").Return(&entities.GeneralConfiguration{EnableRic: true}, nil)
e2tInstancesManagerMock.On("GetE2TInstance", e2tInstanceFullAddress).Return(&entities.E2TInstance{}, nil)
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xmlGnb...)}
- gnbToUpdate := getExpectedNodebForExistingRan(*nodebInfo, notificationRequest.Payload)
+ gnbToUpdate := getExpectedNodebForExistingRan(nodebInfo, notificationRequest.Payload)
gnbToUpdate.SetupFromNetwork = true
writerMock.On("UpdateNodebInfo", gnbToUpdate).Return(nil)
if withFunctions {
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(errors.New("association error"))
notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xmlGnb...)}
- gnbToUpdate := getExpectedNodebForExistingRan(*nodebInfo, notificationRequest.Payload)
+ gnbToUpdate := getExpectedNodebForExistingRan(nodebInfo, notificationRequest.Payload)
gnbToUpdate2 := *gnbToUpdate
gnbToUpdate2.ConnectionStatus = entities.ConnectionStatus_DISCONNECTED
}
func TestE2SetupRequestNotificationHandler_HandleExistingConnectedGnbWithoutFunctionsSuccess(t *testing.T) {
- testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t, false)
+ testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t, false, GnbWithoutFunctionsSetupRequestXmlPath)
}
func TestE2SetupRequestNotificationHandler_HandleExistingConnectedGnbWithFunctionsSuccess(t *testing.T) {
- testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t, true)
+ testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t, true, GnbSetupRequestXmlPath)
+}
+
+func TestE2SetupRequestNotificationHandler_HandleExistingConnectedGnbWithZeroFunctionsSuccess(t *testing.T) {
+ testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(t, true, GnbWithZeroFunctionsSetupRequestXmlPath)
}
func TestE2SetupRequestNotificationHandler_HandleExistingDisconnectedGnbSuccess(t *testing.T) {
routingManagerClientMock.On("AssociateRanToE2TInstance", e2tInstanceFullAddress, mock.Anything).Return(nil)
notificationRequest := &models.NotificationRequest{RanName: gnbNodebRanName, Payload: append([]byte(e2SetupMsgPrefix), xmlGnb...)}
- gnbToUpdate := getExpectedNodebForExistingRan(*nodebInfo, notificationRequest.Payload)
+ gnbToUpdate := getExpectedNodebForExistingRan(nodebInfo, notificationRequest.Payload)
gnbToUpdate2 := *gnbToUpdate
gnbToUpdate2.ConnectionStatus = entities.ConnectionStatus_CONNECTED
gnbToUpdate2.SetupFromNetwork = true
func (h *UpdateEnbManager) SetNodeb(nodeb *entities.NodebInfo, request models.Request) {
updateEnbRequest := request.(*models.UpdateEnbRequest)
- updateEnbRequest.Enb.EnbType = nodeb.GetEnb().GetEnbType()
+
+ if nodeb.SetupFromNetwork {
+ updateEnbRequest.Enb.EnbType = nodeb.GetEnb().GetEnbType()
+ }
+
nodeb.Configuration = &entities.NodebInfo_Enb{Enb: updateEnbRequest.Enb}
}
return err
}
- if h.nodebValidator.IsNgEnbType(request.Enb.GetEnbType()){
+ if h.nodebValidator.IsNgEnbType(request.Enb.GetEnbType()) {
return errors.New("enb.enbType")
}
--- /dev/null
+<E2AP-PDU>
+ <initiatingMessage>
+ <procedureCode>1</procedureCode>
+ <criticality>
+ <reject/>
+ </criticality>
+ <value>
+ <E2setupRequest>
+ <protocolIEs>
+ <E2setupRequestIEs>
+ <id>3</id>
+ <criticality>
+ <reject/>
+ </criticality>
+ <value>
+ <GlobalE2node-ID>
+ <gNB>
+ <global-gNB-ID>
+ <plmn-id>02 F8 29</plmn-id>
+ <gnb-id>
+ <gnb-ID>001100000011000000110000</gnb-ID>
+ </gnb-id>
+ </global-gNB-ID>
+ </gNB>
+ </GlobalE2node-ID>
+ </value>
+ </E2setupRequestIEs>
+ <E2setupRequestIEs>
+ <id>10</id>
+ <criticality>
+ <reject/>
+ </criticality>
+ <value>
+ <RANfunctions-List>
+ </RANfunctions-List>
+ </value>
+ </E2setupRequestIEs>
+ </protocolIEs>
+ </E2setupRequest>
+ </value>
+ </initiatingMessage>
+</E2AP-PDU>
\ No newline at end of file