From: calvinosanc1 Date: Tue, 21 Jul 2020 14:03:46 +0000 (+0200) Subject: Basic-12 - RobotFramework X-Git-Tag: release-v9.0-start~29 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a352a93af7e73cd73831ba7601df7d916abc8bfc;p=osm%2Ftests.git Basic-12 - RobotFramework Change-Id: I6c99f33947c07e446e7042e9b0648a148958f560 Signed-off-by: calvinosanc1 --- diff --git a/robot-systest/envfile.rc b/robot-systest/envfile.rc index e2a6d55..ef4ac32 100644 --- a/robot-systest/envfile.rc +++ b/robot-systest/envfile.rc @@ -25,3 +25,4 @@ echo "Please set your environment variables." # export IP_VM3= # export IP_VM4= # export IP_JUJU= +# export JUJU_PASSWORD= # Could be found in ~/.local/share/juju/accounts.yaml file diff --git a/robot-systest/lib/packages_lib.robot b/robot-systest/lib/packages_lib.robot new file mode 100644 index 0000000..e37a590 --- /dev/null +++ b/robot-systest/lib/packages_lib.robot @@ -0,0 +1,48 @@ +# Copyright 2020 Canonical Ltd. +# +# 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 String +Library OperatingSystem + + +*** Variables *** +${success_return_code} 0 + + +*** Keywords *** +Package Build + [Documentation] Build the package NS, VNF given the package_folder + + [Arguments] ${pkg_folder} ${skip_charm_build}=${EMPTY} + + ${skip_charm} Set Variable If '${skip_charm_build}'!='${EMPTY}' --skip-charm-build \ + ${rc} ${stdout}= Run and Return RC and Output osm package-build ${pkg_folder} ${skip_charm} + Should Be Equal As Integers ${rc} ${success_return_code} + Should Contain ${stdout} Package created + ${package}= Get Line ${stdout} -1 + + [Return] ${package} + +Package Validate + [Documentation] Validate descriptors given a base directory + + [Arguments] ${pkg_folder} + ${rc} ${stdout}= Run and Return RC and Output osm package-validate ${pkg_folder} | awk -F\| '$2 !~ /-/ && $4 ~ /OK|ERROR/ {print $4}' + Should Be Equal As Integers ${rc} ${success_return_code} + Should Contain ${stdout} 'OK' + ${package}= Get Line ${stdout} -1 + + [Return] ${package} + diff --git a/robot-systest/resources/basic_12-ns_primitives_data.py b/robot-systest/resources/basic_12-ns_primitives_data.py new file mode 100644 index 0000000..128235c --- /dev/null +++ b/robot-systest/resources/basic_12-ns_primitives_data.py @@ -0,0 +1,35 @@ +# Copyright 2020 Canonical Ltd. +# +# 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 + +# Get ${HOME} from local machine +home = str(Path.home()) +# NS and VNF descriptor package files +vnfd_pkg1 = 'charm-packages/nscharm_policy_vnf' +vnfd_pkg2 = 'charm-packages/nscharm_user_vnf' +nsd_pkg = 'charm-packages/nscharm_ns' +# NSD and VNFD names in OSM +vnfd_name1 = 'nscharm-policy-vnf' +vnfd_name2 = 'nscharm-user-vnf' +nsd_name = 'nscharm-ns' +# NS Descriptor file +nsd_file = 'nscharm_nsd.yaml' +# NS instance name +ns_name = 'test_nscharm' +# SSH keys to be used +publickey = home + '/.ssh/id_rsa.pub' +privatekey = home + '/.ssh/id_rsa' +# Juju variables +old_juju_password = 'd55ce8ab4efa59e7f1b865bce53f55ed' diff --git a/robot-systest/testsuite/basic_12-ns_primitives.robot b/robot-systest/testsuite/basic_12-ns_primitives.robot new file mode 100644 index 0000000..7dcc719 --- /dev/null +++ b/robot-systest/testsuite/basic_12-ns_primitives.robot @@ -0,0 +1,103 @@ +# Copyright 2020 Canonical Ltd. +# 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 + +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/packages_lib.robot + +Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_12-ns_primitives_data.py + +Suite Teardown Run Keyword And Ignore Error Test Cleanup + + +*** Variables *** +${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] } +${publickey} ${EMPTY} + +*** Test Cases *** +Change Juju Password + + [Documentation] NS package needs to be updated with the Juju credentials for your OSM installation + + [Tags] nsprimitives charm sanity regression + + ${nsd_yaml}= Get File %{PACKAGES_FOLDER}${nsd_pkg}/${nsd_file} + ${changed_nsd_yaml}= Replace String ${nsd_yaml} ${old_juju_password} %{JUJU_PASSWORD} + Create File %{PACKAGES_FOLDER}${nsd_pkg}/${nsd_file} ${changed_nsd_yaml} + +Create NS Package + + [Tags] nsprimitives charm sanity regression + + ${pkg}= Package Build '%{PACKAGES_FOLDER}${nsd_pkg}' + Log ${pkg} + Set Suite Variable ${ns_pkg} ${pkg} + + +Upload Vnfds + + [Tags] nsprimitives charm sanity regression + + Create VNFD '%{PACKAGES_FOLDER}${vnfd_pkg1}' + Create VNFD '%{PACKAGES_FOLDER}${vnfd_pkg2}' + +Upload Nsd + + [Tags] nsprimitives charm sanity regression + + Create NSD '${ns_pkg}' + +Instantiate NS + + [Tags] nsprimitives charm sanity regression + + ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} ns_launch_max_wait_time=40min + Set Suite Variable ${ns_id} ${id} + +# TODO: Check Initial Config Primitives Status + +Delete NS + + [Tags] nsprimitives charm sanity regression cleanup + + Delete NS ${ns_name} + +Delete NS Descriptor + + [Tags] nsprimitives charm sanity regression cleanup + + Delete NSD ${nsd_name} + +Delete VNF Descriptors + + [Tags] nsprimitives charm sanity regression cleanup + + Delete VNFD ${vnfd_name1} + Delete VNFD ${vnfd_name2} + + +*** Keywords *** +Test Cleanup + [Documentation] Test Suit Cleanup: Deleting Descriptor and instance + + Run Keyword If Test Failed Delete NS ${ns_name} + Run Keyword If Test Failed Delete NSD ${nsd_name} + Run Keyword If Test Failed Delete VNFD ${vnfd_name1} + Run Keyword If Test Failed Delete VNFD ${vnfd_name2}