From: ss412g Date: Tue, 10 Dec 2019 15:36:45 +0000 (+0200) Subject: Add Automation for E2T init X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=64fcc929961e1dc46de36b3c460b9fd67b0c0ef2;p=ric-plt%2Fe2mgr.git Add Automation for E2T init Change-Id: I502338c138e13ee3a5ad2686e886ddcfef10fc8e Signed-off-by: ss412g --- diff --git a/Automation/Tests/E2Term_Initialization/E2Term_Init_Message_Test.robot b/Automation/Tests/E2Term_Initialization/E2Term_Init_Message_Test.robot new file mode 100644 index 0000000..7c0e924 --- /dev/null +++ b/Automation/Tests/E2Term_Initialization/E2Term_Init_Message_Test.robot @@ -0,0 +1,36 @@ +*** 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/cleanup_db.py +Library ../Scripts/e2t_init_script.py + +*** Test Cases *** + +Test New E2T Send Init + Stop E2 + + ${result}= cleanup_db.flush_and_restore_without_e2t_keys + Should Be Equal As Strings ${result} True + + Start E2 + + ${result}= e2t_init_script.verify_db_e2t_addresses + Should Be Equal As Strings ${result} True + + ${result}= e2t_init_script.verify_db_e2t_instance + Should Be Equal As Strings ${result} True + +prepare logs for tests + Remove log files + Save logs + +E2M Logs - Verify RMR Message + ${result} find_rmr_message.verify_logs ${EXECDIR} ${e2mgr_log_filename} ${E2_INIT_message_type} ${None} + Should Be Equal As Strings ${result} True + + + diff --git a/Automation/Tests/E2Term_Initialization/__init__.robot b/Automation/Tests/E2Term_Initialization/__init__.robot new file mode 100755 index 0000000..7112a73 --- /dev/null +++ b/Automation/Tests/E2Term_Initialization/__init__.robot @@ -0,0 +1,20 @@ +############################################################################## +# +# Copyright (c) 2019 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################## + +*** Settings *** +Documentation E2Term-Initialization diff --git a/Automation/Tests/Resource/Keywords.robot b/Automation/Tests/Resource/Keywords.robot index 05d87e3..96e5b57 100755 --- a/Automation/Tests/Resource/Keywords.robot +++ b/Automation/Tests/Resource/Keywords.robot @@ -132,6 +132,12 @@ Start E2 Should Be Equal As Integers ${result[1]} ${docker_number} Sleep 2s +Stop E2 + Run And Return Rc And Output ${stop_e2} + ${result}= Run And Return Rc And Output ${docker_command} + Should Be Equal As Integers ${result[1]} ${docker_number-1} + Sleep 2s + Start Dbass Run And Return Rc And Output ${dbass_remove} Run And Return Rc And Output ${dbass_start} diff --git a/Automation/Tests/Resource/resource.robot b/Automation/Tests/Resource/resource.robot index f4add1e..dd54137 100755 --- a/Automation/Tests/Resource/resource.robot +++ b/Automation/Tests/Resource/resource.robot @@ -51,10 +51,11 @@ ${restart_e2e_simu} docker restart e2e_simu ${restart_e2adapter} docker restart e2adapter ${restart_rsm} docker restart rsm ${start_e2} docker start e2 -${stop_docker_e2} docker stop e2 +${stop_e2} docker stop e2 ${dbass_start} docker run -d --name dbass -p 6379:6379 --env DBAAS_SERVICE_HOST=10.0.2.15 snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001/dbass:1.0.0 ${dbass_remove} docker rm dbass ${dbass_stop} docker stop dbass +${restart_simu} docker restart gnbe2_simu ${start_e2} docker start e2 ${stop_docker_e2} docker stop e2 ${Run_Config} docker exec gnbe2_simu pkill gnbe2_simu -INT diff --git a/Automation/Tests/Resource/scripts_variables.robot b/Automation/Tests/Resource/scripts_variables.robot index 1d33db6..e2998ae 100644 --- a/Automation/Tests/Resource/scripts_variables.robot +++ b/Automation/Tests/Resource/scripts_variables.robot @@ -29,6 +29,7 @@ ${RAN_CONNECTED_message_type} MType: 1200 ${RAN_RESTARTED_message_type} MType: 1210 ${RIC_X2_RESET_REQ_message_type} MType: 10070 ${RIC_X2_RESET_RESP_message_type} MType: 10070 +${E2_INIT_message_type} MType: 1100 #${failed_to_retrieve_nodeb_message} failed to retrieve nodeB entity. RanName: test1. #{#RanReconnectionManager.ReconnectRan - RAN name: test1 - Failed fetching RAN from rNib. Error: dial tcp 172.17.0.2:637 #9: i/o timeout" ${failed_to_retrieve_nodeb_message} RAN name: test1 - Failed fetching RAN from rNib diff --git a/Automation/Tests/Scripts/cleanup_db.py b/Automation/Tests/Scripts/cleanup_db.py index e2507c5..4cf961f 100644 --- a/Automation/Tests/Scripts/cleanup_db.py +++ b/Automation/Tests/Scripts/cleanup_db.py @@ -31,5 +31,23 @@ def flush(): r.set("{rsm},CFG:GENERAL:v1.0.0" , "{\"enableResourceStatus\":true,\"partialSuccessAllowed\":true,\"prbPeriodic\":true,\"tnlLoadIndPeriodic\":true,\"wwLoadIndPeriodic\":true,\"absStatusPeriodic\":true,\"rsrpMeasurementPeriodic\":true,\"csiPeriodic\":true,\"periodicityMs\":1,\"periodicityRsrpMeasurementMs\":3,\"periodicityCsiMs\":3}") + r.set("{e2Manager},E2TAddresses", "[\"e2t.att.com:38000\"]") + + r.set("{e2Manager},E2TInstance:e2t.att.com:38000", "{\"address\":\"e2t.att.com:38000\",\"associatedRanList\":[],\"keepAliveTimestamp\":1575974678854116185,\"state\":\"ACTIVE\"}") + + return True + +def flush_and_restore_without_e2t_keys(): + + c = config.redis_ip_address + + p = config.redis_ip_port + + r = redis.Redis(host=c, port=p, db=0) + + r.flushall() + + r.set("{rsm},CFG:GENERAL:v1.0.0" , "{\"enableResourceStatus\":true,\"partialSuccessAllowed\":true,\"prbPeriodic\":true,\"tnlLoadIndPeriodic\":true,\"wwLoadIndPeriodic\":true,\"absStatusPeriodic\":true,\"rsrpMeasurementPeriodic\":true,\"csiPeriodic\":true,\"periodicityMs\":1,\"periodicityRsrpMeasurementMs\":3,\"periodicityCsiMs\":3}") + return True diff --git a/Automation/Tests/Scripts/e2t_init_script.py b/Automation/Tests/Scripts/e2t_init_script.py new file mode 100644 index 0000000..ac48cbb --- /dev/null +++ b/Automation/Tests/Scripts/e2t_init_script.py @@ -0,0 +1,58 @@ +############################################################################## +# +# 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 + + +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_db_e2t_addresses(): + + r = getRedisClientDecodeResponse() + + value = "[\"e2t.att.com:38000\"]" + + return r.get("{e2Manager},E2TAddresses") == value + + +def verify_db_e2t_instance(): + + r = getRedisClientDecodeResponse() + + e2_address = "\"address\":\"e2t.att.com:38000\"" + e2_associated_ran_list = "\"associatedRanList\":[]" + e2_state = "\"state\":\"ACTIVE\"" + + e2_db_instance = r.get("{e2Manager},E2TInstance:e2t.att.com:38000") + + if e2_db_instance.find(e2_address) < 0: + return False + if e2_db_instance.find(e2_associated_ran_list) < 0: + return False + if e2_db_instance.find(e2_state) < 0: + return False + + return True \ No newline at end of file diff --git a/Automation/Tests/Scripts/find_rmr_message.py b/Automation/Tests/Scripts/find_rmr_message.py index 1d75e81..f4ab516 100644 --- a/Automation/Tests/Scripts/find_rmr_message.py +++ b/Automation/Tests/Scripts/find_rmr_message.py @@ -27,8 +27,12 @@ def verify_logs(directory,filename,mtype,meid): for l in f: - if l.find(mtype) > 0 and l.find(meid) > 0: - return True + if (meid is not None): + if l.find(mtype) > 0 and l.find(meid) > 0: + return True + else: + if l.find(mtype) > 0: + return True return False diff --git a/Automation/Tests/Scripts/rsmscripts.py b/Automation/Tests/Scripts/rsmscripts.py index 40c4d35..db2a869 100644 --- a/Automation/Tests/Scripts/rsmscripts.py +++ b/Automation/Tests/Scripts/rsmscripts.py @@ -18,7 +18,6 @@ import config import redis -import cleanup_db import json @@ -41,67 +40,58 @@ def verify_rsm_ran_info_start_false(): value = "{\"ranName\":\"test1\",\"enb1MeasurementId\":1,\"enb2MeasurementId\":0,\"action\":\"start\",\"actionStatus\":false}" - if r.get("{rsm},RAN:test1") == value: - return True - else: - return False + return r.get("{rsm},RAN:test1") == value def verify_rsm_ran_info_start_true(): r = getRedisClientDecodeResponse() - + rsmInfoStr = r.get("{rsm},RAN:test1") rsmInfoJson = json.loads(rsmInfoStr) response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["enb2MeasurementId"] != 1 and rsmInfoJson["action"] == "start" and rsmInfoJson["actionStatus"] == True - return response + return response def verify_rsm_ran_info_stop_false(): r = getRedisClientDecodeResponse() - + rsmInfoStr = r.get("{rsm},RAN:test1") rsmInfoJson = json.loads(rsmInfoStr) response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["enb1MeasurementId"] == 1 and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == False - return response + return response def verify_rsm_ran_info_stop_true(): r = getRedisClientDecodeResponse() - + rsmInfoStr = r.get("{rsm},RAN:test1") rsmInfoJson = json.loads(rsmInfoStr) response = rsmInfoJson["ranName"] == "test1" and rsmInfoJson["action"] == "stop" and rsmInfoJson["actionStatus"] == True - return response - + return response + def verify_general_config_enable_resource_status_true(): r = getRedisClientDecodeResponse() - + configStr = r.get("{rsm},CFG:GENERAL:v1.0.0") configJson = json.loads(configStr) - if configJson["enableResourceStatus"] == True: - return True - else: - return False + return configJson["enableResourceStatus"] == True def verify_general_config_enable_resource_status_false(): r = getRedisClientDecodeResponse() - + configStr = r.get("{rsm},CFG:GENERAL:v1.0.0") configJson = json.loads(configStr) - if configJson["enableResourceStatus"] == False: - return True - else: - return False \ No newline at end of file + return configJson["enableResourceStatus"] == False \ No newline at end of file