From db73aa70f10d7da6ee7387b1854c6b22d871b6f3 Mon Sep 17 00:00:00 2001 From: Gabriel Cuba Date: Thu, 23 Nov 2023 00:44:58 -0500 Subject: [PATCH] Feature 10996: cancel operation robot test Change-Id: I1a582eb3e52507e7a975f95cf099ca3f71092c48 Signed-off-by: Gabriel Cuba --- robot-systest/lib/ns_lib.robot | 29 ++++- .../lcmop_01-cancel_operation_basic.robot | 115 ++++++++++++++++++ 2 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 robot-systest/testsuite/lcmop_01-cancel_operation_basic.robot diff --git a/robot-systest/lib/ns_lib.robot b/robot-systest/lib/ns_lib.robot index aa0830f..a37e509 100644 --- a/robot-systest/lib/ns_lib.robot +++ b/robot-systest/lib/ns_lib.robot @@ -284,7 +284,7 @@ Get Operations List Check For NS Operation Completed - [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not. + [Documentation] Check whether the status of the desired operation is "COMPLETED" or not. [Arguments] ${ns_operation_id} @@ -296,7 +296,7 @@ Check For NS Operation Completed Check For NS Operation Failed - [Documentation] Check wheter the status of the desired operation is "FAILED" or not. + [Documentation] Check whether the status of the desired operation is "FAILED" or not. [Arguments] ${ns_operation_id} @@ -308,7 +308,7 @@ Check For NS Operation Failed Check For NS Operation Ended - [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED". + [Documentation] Check whether the status of the desired operation is "FAILED" or "COMPLETED". [Arguments] ${ns_operation_id} @@ -319,6 +319,18 @@ Check For NS Operation Ended Should Contain Any ${stdout} FAILED COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False +Check For NS Operation Cancelled + [Documentation] Check whether the operation was cancelled or not. + + [Arguments] ${ns_operation_id} + + Should Not Be Empty ${ns_operation_id} + ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq -r '.operationState, .isCancelPending' + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + Should Contain ${stdout} FAILED_TEMP\nfalse msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False + + Get Ns Vnfr Ids [Documentation] Return a list with the IDs of the VNF records of a NS instance. @@ -393,3 +405,14 @@ Get Operations By Type Should Be Equal As Integers ${rc} ${success_return_code} Should Not Be Empty ${stdout} [Return] ${stdout} + +Cancel operation By Id + [Documentation] Cancels an ongoing operation by operation ID + + [Arguments] ${op_id} ${cancel_mode}=GRACEFUL + + Should Not Be Empty ${op_id} + ${rc} ${stdout}= Run and Return RC and Output osm ns-op-cancel ${op_id} --cancel_mode ${cancel_mode} --wait + Log ${stdout} + Should Be Equal As Integers ${rc} ${success_return_code} + [Return] ${stdout} \ No newline at end of file diff --git a/robot-systest/testsuite/lcmop_01-cancel_operation_basic.robot b/robot-systest/testsuite/lcmop_01-cancel_operation_basic.robot new file mode 100644 index 0000000..3b9d215 --- /dev/null +++ b/robot-systest/testsuite/lcmop_01-cancel_operation_basic.robot @@ -0,0 +1,115 @@ +# 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 [LCMOP_01] Cancel an ongoing NS operation + +Library OperatingSystem +Library String +Library Collections +Library Process +Library SSHLibrary + +Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/connectivity_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot + +Force Tags lcmop_01 cluster_lcmop daily + +Suite Teardown Run Keyword And Ignore Error Suite Cleanup + + +*** Variables *** +# NS and VNF descriptor package folder and ids +${vnfd_pkg} simple_ee_vnf +${vnfd_name} simple_ee-vnf +${nsd_pkg} simple_ee_ns +${nsd_name} simple_ee-ns + +# NS instance name and configuration +${ns_name} lcmop_01_cancel_operation_basic +${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] } + + +*** Test Cases *** +Create VNF Descriptor + [Documentation] Create the VNF descriptor + + ${id}= Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' + Set Suite Variable ${vnfd_id} ${id} + + +Create NS Descriptor + [Documentation] Create the NS descriptor + + Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' + + +Instantiate Network Service + [Documentation] Instantiate the Network service + + ${id}= Instantiate Network Service ${ns_name} ${nsd_name} %{VIM_TARGET} --config '${ns_config}' + Set Suite Variable ${ns_id} ${id} + + +Get operation ID + [Documentation] Obtain the operation ID of the NS instantiation + + ${id}= Get Operations By Type ${ns_id} instantiate + Set Suite Variable ${op_id} ${id} + + +Cancel operation + [Documentation] Cancel the ongoing NS instantiation + + Sleep 5s Waiting before cancelling the operation + Cancel operation By Id ${op_id} + + +Check that operation is cancelled + [Documentation] Check that the operation is succesfully cancelled + + Check For NS Operation Cancelled ${op_id} + + +Delete NS Instance Test + [Documentation] Delete the cancelled NS instance + [Tags] cleanup + + Delete NS ${ns_name} + + +Delete NS Descriptor Test + [Documentation] Delete the NS descriptor + [Tags] cleanup + + Delete NSD ${nsd_name} + + +Delete VNF Descriptor Test + [Documentation] Delete the VNF descriptor + [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