From c4da06720df24e3136bb2cbab42505ac6469c4f5 Mon Sep 17 00:00:00 2001 From: dhanasekaran Date: Thu, 28 Apr 2022 12:56:03 +0000 Subject: [PATCH] Autohealing Feature robot test support Change-Id: I8783986cc922603eda21e2ab500acb2180d941d4 Signed-off-by: dhanasekaran --- robot-systest/lib/openstack_lib.robot | 10 ++ .../testsuite/heal_04-autohealing.robot | 139 ++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 robot-systest/testsuite/heal_04-autohealing.robot diff --git a/robot-systest/lib/openstack_lib.robot b/robot-systest/lib/openstack_lib.robot index 36e3f1d..c335963 100644 --- a/robot-systest/lib/openstack_lib.robot +++ b/robot-systest/lib/openstack_lib.robot @@ -114,3 +114,13 @@ Stop Server log ${stdout} Should Be Equal As Integers ${rc} ${success_return_code} [Return] ${stdout} + +Halt Server + [Documentation] Reset a server + [Arguments] ${server_id} + + Should Not Be Empty ${server_id} + ${rc} ${stdout}= Run and Return RC and Output openstack server set --state error ${server_id} + log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + [Return] ${stdout} diff --git a/robot-systest/testsuite/heal_04-autohealing.robot b/robot-systest/testsuite/heal_04-autohealing.robot new file mode 100644 index 0000000..990b44a --- /dev/null +++ b/robot-systest/testsuite/heal_04-autohealing.robot @@ -0,0 +1,139 @@ +# 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 [HEAL-04] Autohealing of NS +Suite Teardown Run Keyword And Ignore Error Suite Cleanup +Force Tags heal_04 cluster_main daily regression +Library OperatingSystem +Library String +Library Collections +Library Process +Library SSHLibrary +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot + +*** Variables *** +# NS and VNF descriptor package folder and ids +${vnfd_pkg} autoheal_vnf +${vnfd_name} autoheal_vnfd +${vdu_name} autoheal_vnfd-VM +${vnf_index} 1 +${nsd_pkg} autoheal_ns +${nsd_name} autoheal_nsd +# NS instance name and configuration +${ns_name} heal_04 +${ns_config} {vld: [ {name: mgmt, vim-network-name: %{VIM_MGMT_NET}} ] } + +# SSH keys and username to be used +${publickey} %{HOME}/.ssh/id_rsa.pub +${privatekey} %{HOME}/.ssh/id_rsa +${username} ubuntu +${password} ${EMPTY} + +${success_return_code} 0 + +*** Test Cases *** +Create VNF Descriptors + [Tags] prepare + Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' + + +Create NS Descriptor + [Tags] prepare + Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' + + +Network Service Instance Test + [Tags] prepare + ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} + Set Suite Variable ${ns_id} ${id} + + +Get NS Id + [Tags] verify cleanup + ${variables} Get Variables + IF not "\${ns_id}" in "${variables}" + ${id}= Get Ns Id ${ns_name} + Set Suite Variable ${ns_id} ${id} + END + + +Get VNF Info + [Tags] verify + Variable Should Exist ${ns_id} msg=NS is not available + ${ip_addr}= Get Vnf Management Ip Address ${ns_id} ${vnf_index} + log ${ip_addr} + Set Suite Variable ${vnf_ip_addr} ${ip_addr} + + ${vnf_id}= Get Vnf Id ${ns_id} ${vnf_index} + Set Suite Variable ${vnf_autoheal_id} ${vnf_id} + ${id}= Get VNF VIM ID ${vnf_id} + Set Suite Variable ${vdu_autoheal_id} ${id} + log ${vdu_autoheal_id} + + @{autoheal_ip_list}= Get Vnf Vdur IPs ${vnf_autoheal_id} + Set Suite Variable @{autoheal_ip_list} @{autoheal_ip_list} + log @{autoheal_ip_list} + + +Stop Autoheal VDU + [Tags] verify + Variable Should Exist ${vdu_autoheal_id} msg=VDU is not available + Halt Server ${vdu_autoheal_id} + Sleep 20 + + +Check VNF After Healing + [Tags] verify + FOR ${Index} IN RANGE 0 15 + ${server_status}= Get Server Property ${vdu_autoheal_id} status + ${status}= Run Keyword And Return Status Should Be Equal ${server_status} ACTIVE + Run Keyword If ${status} Exit For Loop + ... ELSE Sleep 10 + END + Variable Should Exist ${vnf_autoheal_id} msg=VNF is not available + + @{ip_list}= Get Vnf Vdur IPs ${vnf_autoheal_id} + log @{ip_list} + Should Be Equal ${ip_list} ${autoheal_ip_list} IP addresses have changed after healing + + ${id}= Get VNF VIM ID ${vnf_autoheal_id} + log ${id} + Should Not Be Equal ${id} ${vdu_autoheal_id} VDU id has not changed after healing + + +Delete NS Instance + [Tags] cleanup + Delete NS ${ns_name} + + +Delete NS Descriptor + [Tags] cleanup + Delete NSD ${nsd_name} + + +Delete VNF Descriptors + [Tags] cleanup + Delete VNFD ${vnfd_name} + +*** Keywords *** +Suite Cleanup + [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim + + Run Keyword If Any Tests Failed Delete NS ${ns_name} + Run Keyword If Any Tests Failed Delete NSD ${nsd_name} + Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} -- 2.17.1