Add testsuite basic_17 to test delete vnf package when not possible
Change-Id: If1c7c32c004c9404ebdbec6b473249710c94370b
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/robot-systest/lib/vnfd_lib.robot b/robot-systest/lib/vnfd_lib.robot
index fc84436..1d57598 100644
--- a/robot-systest/lib/vnfd_lib.robot
+++ b/robot-systest/lib/vnfd_lib.robot
@@ -28,6 +28,7 @@
*** Variables ***
${success_return_code} 0
+${failure_return_code} 0
${delete_max_wait_time} 1min
${delete_pol_time} 15sec
@@ -82,7 +83,7 @@
... - `--override-nonepa`: removes all EPA attributes from all VDUs.
... - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
... the others above (e.g. '--override-nonepa --override-paravirt').
- ... - Relevant environment variables:
+ ... - Relevant environment variables:
... - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
... This is often more convenient to enforce the same behaviour for every test run in a given VIM.
@@ -110,8 +111,21 @@
WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For VNFD ${vnfd_id}
-Check For VNFD
+Assert Failure Delete VNFD
+ [Documentation] Deletes a NF Package that cannot be deleted and asserts the failure
[Arguments] ${vnfd_id}
+ ${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-delete ${vnfd_id}
+ log ${stdout}
+ Should Be Equal As Integers ${rc} ${failure_return_code}
+ Should Contain ${stdout} 409 msg=Expected Conflict values=False
+ WAIT UNTIL KEYWORD SUCCEEDS ${delete_max_wait_time} ${delete_pol_time} Check For VNFD ${vnfd_id} True
+
+
+Check For VNFD
+ [Arguments] ${vnfd_id} ${exists}=False
+
${rc} ${stdout}= Run and Return RC and Output osm vnfpkg-list | awk '{print $2}' | grep ${vnfd_id}
- Should Not Be Equal As Strings ${stdout} ${vnfd_id}
+ Run Keyword If ${exists} Should Be Equal As Strings ${stdout} ${vnfd_id}
+ ... ELSE Should Not Be Equal As Strings ${stdout} ${vnfd_id}
+
diff --git a/robot-systest/resources/basic_17-delete_vnf_package_data.py b/robot-systest/resources/basic_17-delete_vnf_package_data.py
new file mode 100644
index 0000000..76f003e
--- /dev/null
+++ b/robot-systest/resources/basic_17-delete_vnf_package_data.py
@@ -0,0 +1,21 @@
+# 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.
+
+from pathlib import Path
+
+# NS and VNF descriptor package folder
+vnfd_pkg = 'hackfest_basic_vnf'
+nsd_pkg = 'hackfest_basic_ns'
+# NS and VNF descriptor package id
+vnfd_name = 'hackfest_basic-vnf'
+nsd_name = 'hackfest_basic-ns'
+
diff --git a/robot-systest/testsuite/basic_17-delete_vnf_package.robot b/robot-systest/testsuite/basic_17-delete_vnf_package.robot
new file mode 100644
index 0000000..0cd13f8
--- /dev/null
+++ b/robot-systest/testsuite/basic_17-delete_vnf_package.robot
@@ -0,0 +1,66 @@
+# 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 ***
+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
+
+Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_17-delete_vnf_package_data.py
+
+Suite Teardown Run Keyword And Ignore Error Suite Cleanup
+
+
+*** Test Cases ***
+Create VNF Package
+ [Tags] hackfest_basic sanity regression
+
+ Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'
+
+
+Create NS Package
+ [Tags] hackfest_basic sanity regression
+
+ Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
+
+
+Cannot Delete VNF Package
+ [Tags] hackfest_basic sanity regression cleanup
+
+ Assert Failure Delete VNFD ${vnfd_name}
+
+
+Delete NS Package
+ [Tags] hackfest_basic sanity regression cleanup
+
+ Delete NSD ${nsd_name}
+
+
+Delete VNF Package
+ [Tags] hackfest_basic sanity regression cleanup
+
+ Delete VNFD ${vnfd_name}
+
+
+*** Keywords ***
+Suite Cleanup
+ [Documentation] Test Suit Cleanup: Deleting NS and VNF packages
+
+ Run Keyword If Any Tests Failed Delete NSD ${nsd_name}
+ Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}
+
+