From: idanshal Date: Wed, 5 Aug 2020 06:49:57 +0000 (+0000) Subject: [RIC-587, RIC-584] Add Automation for RIC-587 | Add UTs for RIC-584 X-Git-Tag: R5_RC~9 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=885ce20e6a593863923b249bf74ffc09ad610176;hp=5208a1cf953edf958444d41352815073e9ebaf29;p=ric-plt%2Fe2mgr.git [RIC-587, RIC-584] Add Automation for RIC-587 | Add UTs for RIC-584 Change-Id: I986ea4fda6d777d9a1eafd0bbd6bea81e6f75686 Signed-off-by: idanshal --- diff --git a/Automation/Tests/Setup_eNB/Setup_after_Add_eNB.robot b/Automation/Tests/E2_Setup/Setup_after_Add_eNB.robot similarity index 100% rename from Automation/Tests/Setup_eNB/Setup_after_Add_eNB.robot rename to Automation/Tests/E2_Setup/Setup_after_Add_eNB.robot diff --git a/Automation/Tests/Setup_eNB/Setup_eNB.robot b/Automation/Tests/E2_Setup/Setup_eNB.robot similarity index 100% rename from Automation/Tests/Setup_eNB/Setup_eNB.robot rename to Automation/Tests/E2_Setup/Setup_eNB.robot diff --git a/Automation/Tests/E2_Setup/Setup_existing_gNB.robot b/Automation/Tests/E2_Setup/Setup_existing_gNB.robot new file mode 100644 index 0000000..c80c487 --- /dev/null +++ b/Automation/Tests/E2_Setup/Setup_existing_gNB.robot @@ -0,0 +1,61 @@ +############################################################################## +# +# 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 + + + + + diff --git a/Automation/Tests/Setup_eNB/__init__.robot b/Automation/Tests/E2_Setup/__init__.robot similarity index 97% rename from Automation/Tests/Setup_eNB/__init__.robot rename to Automation/Tests/E2_Setup/__init__.robot index abba85a..89bb84a 100644 --- a/Automation/Tests/Setup_eNB/__init__.robot +++ b/Automation/Tests/E2_Setup/__init__.robot @@ -21,4 +21,4 @@ # *** Settings *** -Documentation Setup eNB +Documentation E2 Setup diff --git a/Automation/Tests/Update_GNB/Update_gnb_happy.robot b/Automation/Tests/Update_GNB/Update_gnb_happy.robot index 733ca3f..5dc8f4d 100644 --- a/Automation/Tests/Update_GNB/Update_gnb_happy.robot +++ b/Automation/Tests/Update_GNB/Update_gnb_happy.robot @@ -56,6 +56,7 @@ prepare logs for tests 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 diff --git a/E2Manager/container-tag.yaml b/E2Manager/container-tag.yaml index 752d154..007b8d0 100644 --- a/E2Manager/container-tag.yaml +++ b/E2Manager/container-tag.yaml @@ -1,4 +1,4 @@ # 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 diff --git a/E2Manager/controllers/nodeb_controller_test.go b/E2Manager/controllers/nodeb_controller_test.go index 1b3a7db..e62e7c0 100644 --- a/E2Manager/controllers/nodeb_controller_test.go +++ b/E2Manager/controllers/nodeb_controller_test.go @@ -446,6 +446,11 @@ func activateControllerUpdateEnbMocks(context *controllerUpdateEnbTestContext, r 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) @@ -601,7 +606,8 @@ func controllerAddEnbTestExecuter(t *testing.T, context *controllerAddEnbTestCon 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) @@ -1157,8 +1163,27 @@ func TestControllerUpdateEnbExistingEmptyCellsSuccess(t *testing.T) { 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{ @@ -1174,7 +1199,7 @@ func TestControllerUpdateEnbSuccess(t *testing.T) { 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, }, @@ -1186,6 +1211,35 @@ func TestControllerUpdateEnbSuccess(t *testing.T) { 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 */ @@ -1340,6 +1394,28 @@ func TestControllerAddEnbMissingRequiredServedCellProps(t *testing.T) { } } +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{ @@ -1403,6 +1479,18 @@ func TestControllerDeleteEnbNodebNotEnb(t *testing.T) { 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{ diff --git a/E2Manager/handlers/httpmsghandlers/delete_enb_request_handler_test.go b/E2Manager/handlers/httpmsghandlers/delete_enb_request_handler_test.go index 49d3b07..27141d8 100644 --- a/E2Manager/handlers/httpmsghandlers/delete_enb_request_handler_test.go +++ b/E2Manager/handlers/httpmsghandlers/delete_enb_request_handler_test.go @@ -115,11 +115,9 @@ func TestHandleDeleteEnbInternalRemoveEnbError(t *testing.T) { 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) diff --git a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go index d6de214..5f2e7f6 100644 --- a/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go +++ b/E2Manager/handlers/rmrmsghandlers/e2_setup_request_notification_handler_test.go @@ -45,6 +45,7 @@ const ( 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" @@ -513,19 +514,24 @@ func getExpectedEnbNodebForNewRan(payload []byte) *entities.NodebInfo { /* 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) { @@ -545,7 +551,7 @@ func TestE2SetupRequestNotificationHandler_HandleExistingConnectedEnbSuccess(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) @@ -575,7 +581,7 @@ func TestE2SetupRequestNotificationHandler_HandleExistingDisconnectedEnbSuccess( 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 @@ -596,15 +602,8 @@ func TestE2SetupRequestNotificationHandler_HandleExistingDisconnectedEnbSuccess( 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) @@ -625,7 +624,7 @@ func testE2SetupRequestNotificationHandler_HandleExistingConnectedGnbSuccess(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) gnbToUpdate.SetupFromNetwork = true writerMock.On("UpdateNodebInfo", gnbToUpdate).Return(nil) if withFunctions { @@ -661,7 +660,7 @@ func TestE2SetupRequestNotificationHandler_HandleExistingConnectedGnbRoutingMana 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 @@ -694,11 +693,15 @@ func TestE2SetupRequestNotificationHandler_HandleExistingGnbInvalidConnectionSta } 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) { @@ -718,7 +721,7 @@ func TestE2SetupRequestNotificationHandler_HandleExistingDisconnectedGnbSuccess( 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 diff --git a/E2Manager/managers/update_enb_manager.go b/E2Manager/managers/update_enb_manager.go index cb3e4bc..6cb5414 100755 --- a/E2Manager/managers/update_enb_manager.go +++ b/E2Manager/managers/update_enb_manager.go @@ -82,7 +82,11 @@ func (h *UpdateEnbManager) RemoveNodebCells(nodeb *entities.NodebInfo) error { 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} } @@ -108,7 +112,7 @@ func (h *UpdateEnbManager) validateRequestBody(request *models.UpdateEnbRequest) return err } - if h.nodebValidator.IsNgEnbType(request.Enb.GetEnbType()){ + if h.nodebValidator.IsNgEnbType(request.Enb.GetEnbType()) { return errors.New("enb.enbType") } diff --git a/E2Manager/tests/resources/setupRequest_gnb_with_zero_functions.xml b/E2Manager/tests/resources/setupRequest_gnb_with_zero_functions.xml new file mode 100644 index 0000000..3246799 --- /dev/null +++ b/E2Manager/tests/resources/setupRequest_gnb_with_zero_functions.xml @@ -0,0 +1,42 @@ + + + 1 + + + + + + + + 3 + + + + + + + + 02 F8 29 + + 001100000011000000110000 + + + + + + + + 10 + + + + + + + + + + + + + \ No newline at end of file