From: is005q Date: Thu, 12 Dec 2019 11:21:41 +0000 (+0200) Subject: [RICPLT-2523] Add Setup automation tests... X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=50190b60334f85598535d1b80f032495082c47b5;p=ric-plt%2Fe2mgr.git [RICPLT-2523] Add Setup automation tests... Change-Id: Ib09fd0eed7dba01a8f99482c0905b931155f93d2 Signed-off-by: is005q --- diff --git a/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot b/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot index 8891608..364b7d5 100755 --- a/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot +++ b/Automation/Tests/RedButton/RedButton_CONNECTED_SHUTDOWN_CONNECTED.robot @@ -25,9 +25,6 @@ Library Collections Library REST ${url} -*** Variables *** -${restart_docker_sim} docker restart gnbe2_simu - *** Test Cases *** @@ -55,11 +52,7 @@ Verfiy Shutdown ConnectionStatus String response body connectionStatus SHUT_DOWN Restart simualtor - - Run And Return Rc And Output ${restart_docker_sim} - ${result}= Run And Return Rc And Output ${docker_command} - Should Be Equal As Integers ${result[1]} ${docker_number} - + Restart simulator repare Ran in Connected connectionStatus Post Request setup node b x-2 diff --git a/Automation/Tests/Resource/Keywords.robot b/Automation/Tests/Resource/Keywords.robot index 96e5b57..982fe57 100755 --- a/Automation/Tests/Resource/Keywords.robot +++ b/Automation/Tests/Resource/Keywords.robot @@ -77,6 +77,7 @@ Stop Simulator Run And Return Rc And Output ${stop_simu} + Prepare Simulator For Load Information Run And Return Rc And Output ${stop_simu} Run And Return Rc And Output ${docker_Remove} @@ -149,6 +150,12 @@ Stop Dbass ${result}= Run And Return Rc And Output ${docker_command} Should Be Equal As Integers ${result[1]} ${docker_number-1} +Restart simulator + + Run And Return Rc And Output ${restart_docker_sim} + ${result}= Run And Return Rc And Output ${docker_command} + Should Be Equal As Integers ${result[1]} ${docker_number} + diff --git a/Automation/Tests/Resource/resource.robot b/Automation/Tests/Resource/resource.robot index dd54137..cdecf81 100755 --- a/Automation/Tests/Resource/resource.robot +++ b/Automation/Tests/Resource/resource.robot @@ -58,6 +58,7 @@ ${dbass_stop} docker stop dbass ${restart_simu} docker restart gnbe2_simu ${start_e2} docker start e2 ${stop_docker_e2} docker stop e2 +${restart_docker_sim} docker restart gnbe2_simu ${Run_Config} docker exec gnbe2_simu pkill gnbe2_simu -INT ${403_reset_message} "Activity X2_RESET rejected. RAN current state DISCONNECTED does not allow its execution " diff --git a/Automation/Tests/Scripts/e2mdbscripts.py b/Automation/Tests/Scripts/e2mdbscripts.py new file mode 100644 index 0000000..7b9475b --- /dev/null +++ b/Automation/Tests/Scripts/e2mdbscripts.py @@ -0,0 +1,49 @@ +############################################################################## +# +# 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. +# +############################################################################## + +import config +import redis +import cleanup_db +import json + +def getRedisClientDecodeResponse(): + c = config.redis_ip_address + p = config.redis_ip_port + return redis.Redis(host=c, port=p, db=0, decode_responses=True) + +def verify_ran_is_associated_with_e2t_instance(ranName, e2tAddress): + r = getRedisClientDecodeResponse() + e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress) + e2tInstanceDic = json.loads(e2tInstanceJson) + assocRanList = e2tInstanceDic.get("associatedRanList") + return ranName in assocRanList + +# def dissociate_ran_from_e2tInstance(ranName, e2tAddress): +# r = getRedisClientDecodeResponse() +# e2tInstanceJson = r.get("{e2Manager},E2TInstance:"+e2tAddress) +# e2tInstanceDic = json.loads(e2tInstanceJson) +# assocRanList = e2tInstanceDic.get("associatedRanList") +# print(assocRanList) +# assocRanList.remove(ranName) +# updatedE2tInstanceJson = json.dumps(e2tInstanceDic) +# print(updatedE2tInstanceJson) +# r.set("{e2Manager},E2TInstance:"+e2tAddress, updatedE2tInstanceJson) +# nodebBytes = r.get("{e2Manager},RAN:"+ranName) +# encoded = nodebBytes.decode().replace(e2tAddress,"").encode() +# r.set("{e2Manager},RAN:"+ranName, encoded) + diff --git a/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot b/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot index da14d32..4ad0dbe 100755 --- a/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot +++ b/Automation/Tests/X2-Setup/X2_Setup_reuqest_test.robot @@ -24,6 +24,7 @@ Resource ../Resource/scripts_variables.robot Library OperatingSystem Library ../Scripts/find_rmr_message.py Library ../Scripts/rsmscripts.py +Library ../Scripts/e2mdbscripts.py Library REST ${url} *** Test Cases *** @@ -39,6 +40,7 @@ X2 - Get Nodeb Integer response body port 5577 String response body connectionStatus CONNECTED String response body nodeType ENB + String response body associatedE2tInstanceAddress e2t.att.com:38000 String response body enb enbType MACRO_ENB Integer response body enb servedCells 0 pci 99 String response body enb servedCells 0 cellId 02f829:0007ab00 @@ -65,4 +67,11 @@ RSM RESOURCE STATUS REQUEST message sent Verify RSM RAN info exists in redis ${result}= rsmscripts.verify_rsm_ran_info_start_false - Should Be Equal As Strings ${result} True \ No newline at end of file + Should Be Equal As Strings ${result} True + +Verify RAN is associated with E2T instance + ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test1 e2t.att.com:38000 + Should Be True ${result} + + + diff --git a/Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot b/Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot new file mode 100644 index 0000000..e3eb058 --- /dev/null +++ b/Automation/Tests/X2-Setup/x2_setup_existing_assoc_test.robot @@ -0,0 +1,63 @@ +############################################################################## +# +# Copyright (c) 2019 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +*** Settings *** +Suite Setup Prepare Enviorment +Resource ../Resource/resource.robot +Resource ../Resource/Keywords.robot +Resource ../Resource/scripts_variables.robot +Library OperatingSystem +Library ../Scripts/find_rmr_message.py +Library ../Scripts/rsmscripts.py +Library ../Scripts/e2mdbscripts.py +Library REST ${url} + +*** Test Cases *** +X2 - Setup Test 1 + Post Request setup node b x-2 + Integer response status 204 + +X2 - Setup Test 2 + Post Request setup node b x-2 + Integer response status 204 + +X2 - Get Nodeb + Get Request Node B Enb test1 + Integer response status 200 + String response body ranName test1 + String response body associatedE2tInstanceAddress e2t.att.com:38000 + +prepare logs for tests + Remove log files + Save logs + +X2 - RAN Connected message going to be sent + ${result} find_rmr_message.verify_logs ${EXECDIR} ${e2mgr_log_filename} ${RAN_CONNECTED_message_type} ${Meid_test1} + Should Be Equal As Strings ${result} True + +RSM RESOURCE STATUS REQUEST message sent + ${result} find_rmr_message.verify_logs ${EXECDIR} ${rsm_log_filename} ${RIC_RES_STATUS_REQ_message_type_successfully_sent} ${RAN_NAME_test1} + Should Be Equal As Strings ${result} True + +Verify RSM RAN info exists in redis + ${result}= rsmscripts.verify_rsm_ran_info_start_false + Should Be Equal As Strings ${result} True + +Verify RAN is associated with E2T instance + ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test1 e2t.att.com:38000 + Should Be True ${result} diff --git a/Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot b/Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot new file mode 100644 index 0000000..457ca9c --- /dev/null +++ b/Automation/Tests/X2-Setup/x2_setup_existing_not_assoc_test.robot @@ -0,0 +1,71 @@ +############################################################################## +# +# Copyright (c) 2019 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +*** Settings *** +Suite Setup Prepare Enviorment +Resource ../Resource/resource.robot +Resource ../Resource/Keywords.robot +Resource ../Resource/scripts_variables.robot +Library OperatingSystem +Library ../Scripts/find_rmr_message.py +Library ../Scripts/rsmscripts.py +Library ../Scripts/e2mdbscripts.py +Library REST ${url} + +*** Test Cases *** +X2 - Setup Test 1 + Post Request setup node b x-2 + Integer response status 204 + +Restart Simulator + Restart Simulator + +Verify RAN is NOT associated with E2T instance + ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test1 e2t.att.com:38000 + Should Be True ${result} == False + + +X2 - Setup Test 2 + Post Request setup node b x-2 + Integer response status 204 + +X2 - Get Nodeb + Get Request Node B Enb test1 + Integer response status 200 + String response body ranName test1 + String response body associatedE2tInstanceAddress e2t.att.com:38000 + +prepare logs for tests + Remove log files + Save logs + +X2 - RAN Connected message going to be sent + ${result} find_rmr_message.verify_logs ${EXECDIR} ${e2mgr_log_filename} ${RAN_CONNECTED_message_type} ${Meid_test1} + Should Be Equal As Strings ${result} True + +RSM RESOURCE STATUS REQUEST message sent + ${result} find_rmr_message.verify_logs ${EXECDIR} ${rsm_log_filename} ${RIC_RES_STATUS_REQ_message_type_successfully_sent} ${RAN_NAME_test1} + Should Be Equal As Strings ${result} True + +Verify RSM RAN info exists in redis + ${result}= rsmscripts.verify_rsm_ran_info_start_false + Should Be Equal As Strings ${result} True + +Verify RAN is associated with E2T instance + ${result} e2mdbscripts.verify_ran_is_associated_with_e2t_instance test1 e2t.att.com:38000 + Should Be True ${result} diff --git a/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go b/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go index 9f1fbb2..6ca7b0b 100644 --- a/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go +++ b/E2Manager/handlers/httpmsghandlers/setup_request_handler_test.go @@ -326,6 +326,20 @@ func TestSetupExistingRanWithAssocE2TInstanceUpdateNodebFailure(t *testing.T) { ranSetupManagerMock.AssertNotCalled(t, "ExecuteSetup") } +func TestSetupExistingRanWithAssocE2TInstanceExecuteSetupRmrError(t *testing.T) { + readerMock, writerMock, handler, e2tInstancesManagerMock, ranSetupManagerMock := initSetupRequestTest(t, entities.E2ApplicationProtocol_X2_SETUP_REQUEST) + nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress:E2TAddress, ConnectionStatus: entities.ConnectionStatus_CONNECTED} + readerMock.On("GetNodeb", RanName).Return(nb , nil) + updatedNb := *nb + updatedNb.ConnectionAttempts = 0 + writerMock.On("UpdateNodebInfo", &updatedNb).Return(nil) + ranSetupManagerMock.On("ExecuteSetup", &updatedNb, entities.ConnectionStatus_CONNECTED).Return(e2managererrors.NewRmrError()) + _, err := handler.Handle(models.SetupRequest{"127.0.0.1", 8080, RanName,}) + assert.IsType(t, &e2managererrors.RmrError{}, err) + e2tInstancesManagerMock.AssertNotCalled(t, "SelectE2TInstance") + e2tInstancesManagerMock.AssertNotCalled(t, "AssociateRan") +} + func TestSetupExistingRanWithAssocE2TInstanceConnectedSuccess(t *testing.T) { readerMock, writerMock, handler, e2tInstancesManagerMock, ranSetupManagerMock := initSetupRequestTest(t, entities.E2ApplicationProtocol_X2_SETUP_REQUEST) nb := &entities.NodebInfo{RanName: RanName, AssociatedE2TInstanceAddress:E2TAddress, ConnectionStatus: entities.ConnectionStatus_CONNECTED}