System Level K8s Cluster
Changes the tests and wrapper script so that a system level k8s
cluster is created instead of each test creating a new cluster.
This is needed if any parallel testing is done, due to the bug
where problems occur if more than one k8s cluster is registered
to the VIM.
Change-Id: I21cad8f2a0fe6c259a4162330b3544ceeed9309b
Signed-off-by: Mark Beierl <mark.beierl@canonical.com>
diff --git a/robot-systest/run_test.sh b/robot-systest/run_test.sh
index b7bf29b..6792452 100755
--- a/robot-systest/run_test.sh
+++ b/robot-systest/run_test.sh
@@ -38,8 +38,41 @@
python3 -m pip install -r /robot-systest/conformance-tests/requirements.txt
}
-create_vim(){
+create_k8scluster(){
+ attempts=3
+ while [ $attempts -ge 0 ] ; do
+ echo -e "\n$( date '+%F_%H:%M:%S' ) Creating K8s Cluster"
+
+ osm k8scluster-add --creds ${K8S_CREDENTIALS} --version "v1" --vim ${VIM_TARGET} --k8s-nets "{\"net1\": \"%{VIM_MGMT_NET}\"}" ${VIM_TARGET} --description "Robot cluster"
+
+ STATUS=""
+ i=0
+ while [[ ${STATUS} != "ENABLED" ]]
+ do
+ ((i++))
+ if [[ $i -eq 5 ]]; then
+ echo "K8s cluster stuck for more than 50 seconds:"
+ osm k8scluster-show ${VIM_TARGET}
+ osm k8scluster-delete ${VIM_TARGET}
+ sleep 5
+ break
+ fi
+ sleep 10
+ STATUS=`osm k8scluster-list | grep ${VIM_TARGET} | awk '{print $8}'`
+ done
+ if [[ ${STATUS} = "ENABLED" ]] ; then
+ break
+ fi
+ ((attempts--))
+ done
+ if [ $attempts -lt 0 ] ; then
+ echo "VIM failed to enter ENABLED state"
+ exit 1
+ fi
+}
+
+create_vim(){
attempts=3
while [ $attempts -ge 0 ] ; do
echo -e "\n$( date '+%F_%H:%M:%S' ) Creating VIM ${VIM_TARGET}"
@@ -136,6 +169,7 @@
;;
-c|--createvim)
create_vim
+ create_k8scluster
shift 1
;;
-T)
@@ -161,7 +195,7 @@
-p <package_branch> [OPTIONAL]: OSM packages repository branch. Default: master
-t <testing_tags> [OPTIONAL]: Robot tests tags. [sanity, daily, regression, particular_test]. Default: sanity
-T <testing_branch> [OPTIONAL]: Run SOL005 Robot conformance tests
- -c To create a VIM for the tests
+ -c To create a VIM and K8s cluster for the tests
Volumes:
<path_to_reports> [OPTIONAL]: It is the absolute path to reports location in the host
diff --git a/robot-systest/testsuite/k8s_02-k8scluster_creation.robot b/robot-systest/testsuite/k8s_02-k8scluster_creation.robot
index 6225913..1983782 100644
--- a/robot-systest/testsuite/k8s_02-k8scluster_creation.robot
+++ b/robot-systest/testsuite/k8s_02-k8scluster_creation.robot
@@ -21,6 +21,9 @@
Library Process
Resource %{ROBOT_DEVOPS_FOLDER}/lib/k8scluster_lib.robot
+Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot
+
+Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_01-crud_operations_on_vim_targets_data.py
Force Tags k8s_02 cluster_k8s daily regression
@@ -33,15 +36,34 @@
${k8scluster_version} v1
*** Test Cases ***
+Create VIM Target Basic
+ [Documentation] Creates a VIM for the K8s cluster to be anchored against
+
+ ${rand}= Generate Random String 6 [NUMBERS]
+ ${vim_name}= Catenate SEPARATOR=_ ${vim_name_prefix} ${rand}
+ Set Suite Variable ${vim_name}
+ ${created_vim_account_id}= Create VIM Target ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type}
+ Set Suite Variable ${created_vim_account_id}
+
Add K8s Cluster To OSM
- Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name}
+ Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} ${vim_name} %{VIM_MGMT_NET} ${k8scluster_name}
Remove K8s Cluster from OSM
[Tags] cleanup
Delete K8s Cluster ${k8scluster_name}
+Delete VIM Target By ID
+ [Documentation] Delete the VIM Target created in previous test-case by its ID.
+ ... Checks whether the VIM Target was created or not before perform the deletion.
+ [Tags] cleanup
+
+ ${vim_account_id}= Get VIM Target ID ${vim_name}
+ Should Be Equal As Strings ${vim_account_id} ${created_vim_account_id}
+ Delete VIM Target ${vim_account_id}
+
+
*** Keywords ***
Suite Cleanup
[Documentation] Test Suit Cleanup: Deleting K8s Cluster
diff --git a/robot-systest/testsuite/k8s_03-simple_k8s.robot b/robot-systest/testsuite/k8s_03-simple_k8s.robot
index a7d7e73..94ad3a2 100644
--- a/robot-systest/testsuite/k8s_03-simple_k8s.robot
+++ b/robot-systest/testsuite/k8s_03-simple_k8s.robot
@@ -34,10 +34,6 @@
*** Variables ***
-# K8s cluster name and version
-${k8scluster_name} k8s03
-${k8scluster_version} v1
-
# NS and VNF descriptor package folder and ids
${vnfd_pkg} charm-packages/native_k8s_charm_vnf
${vnfd_name} native_k8s_charm-vnf
@@ -63,9 +59,6 @@
Create Simple K8s Descriptor
Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
-Add K8s Cluster To OSM
- Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name}
-
Network Service K8s Instance Test
${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
Set Suite Variable ${ns_id} ${id}
@@ -80,10 +73,6 @@
[Tags] cleanup
Delete NS ${ns_name}
-Remove K8s Cluster from OSM
- [Tags] cleanup
- Delete K8s Cluster ${k8scluster_name}
-
Delete NS Descriptor Test
[Tags] cleanup
Delete NSD ${nsd_name}
@@ -104,4 +93,3 @@
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}
- Run Keyword If Any Tests Failed Delete K8s Cluster ${k8scluster_name}
diff --git a/robot-systest/testsuite/k8s_04-openldap_helm.robot b/robot-systest/testsuite/k8s_04-openldap_helm.robot
index f2d6f6e..4370074 100644
--- a/robot-systest/testsuite/k8s_04-openldap_helm.robot
+++ b/robot-systest/testsuite/k8s_04-openldap_helm.robot
@@ -31,10 +31,6 @@
*** Variables ***
-# K8s cluster name and version
-${k8scluster_name} k8s04
-${k8scluster_version} v1
-
# NS and VNF descriptor package folder and ids
${vnfd_pkg} openldap_knf
${vnfd_name} openldap_knf
@@ -62,10 +58,6 @@
[Tags] prepare
Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
-Add K8s Cluster To OSM
- [Tags] prepare
- Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name}
-
Create Network Service Instance
[Tags] prepare
${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
@@ -110,10 +102,6 @@
[Tags] cleanup
Delete NS ${ns_name}
-Remove K8s Cluster from OSM
- [Tags] cleanup
- Delete K8s Cluster ${k8scluster_name}
-
Delete NS Descriptor Test
[Tags] cleanup
Delete NSD ${nsd_name}
@@ -129,4 +117,3 @@
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}
- Run Keyword If Any Tests Failed Delete K8s Cluster ${k8scluster_name}
diff --git a/robot-systest/testsuite/k8s_08-simple_k8s_scaling.robot b/robot-systest/testsuite/k8s_08-simple_k8s_scaling.robot
index ea6b7e1..bfc4c2e 100644
--- a/robot-systest/testsuite/k8s_08-simple_k8s_scaling.robot
+++ b/robot-systest/testsuite/k8s_08-simple_k8s_scaling.robot
@@ -32,10 +32,6 @@
*** Variables ***
-# K8s cluster name and version
-${k8scluster_name} k8s08
-${k8scluster_version} v1
-
# NS and VNF descriptor package folder and ids
${vnfd_pkg} charm-packages/native_k8s_scale_charm_vnf
${vnfd_name} native_k8s_scale_charm-vnf
@@ -67,9 +63,6 @@
Create Simple K8s Scale NS Descriptor
Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
-Add K8s Cluster To OSM
- Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name}
-
Network Service K8s Instance Test
${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
Set Suite Variable ${ns_id} ${id}
@@ -115,10 +108,6 @@
[Tags] cleanup
Delete NS ${ns_name}
-Remove K8s Cluster from OSM
- [Tags] cleanup
- Delete K8s Cluster ${k8scluster_name}
-
Delete NS Descriptor Test
[Tags] cleanup
Delete NSD ${nsd_name}
@@ -134,4 +123,3 @@
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}
- Run Keyword If Any Tests Failed Delete K8s Cluster ${k8scluster_name}
diff --git a/robot-systest/testsuite/k8s_09-pebble_charm_k8s.robot b/robot-systest/testsuite/k8s_09-pebble_charm_k8s.robot
index 6e0ee5a..57d12ee 100644
--- a/robot-systest/testsuite/k8s_09-pebble_charm_k8s.robot
+++ b/robot-systest/testsuite/k8s_09-pebble_charm_k8s.robot
@@ -34,10 +34,6 @@
*** Variables ***
-# K8s cluster name and version
-${k8scluster_name} k8s-test
-${k8scluster_version} v1
-
# NS and VNF descriptor package folder and ids
${vnfd_pkg} charm-packages/pebble_charm_vnf
${vnfd_name} pebble_charm-vnf
@@ -63,9 +59,6 @@
Create Simple K8s Descriptor
Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
-Add K8s Cluster To OSM
- Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name}
-
Network Service K8s Instance Test
${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
Set Suite Variable ${ns_id} ${id}
@@ -80,10 +73,6 @@
[Tags] cleanup
Delete NS ${ns_name}
-Remove K8s Cluster from OSM
- [Tags] cleanup
- Delete K8s Cluster ${k8scluster_name}
-
Delete NS Descriptor Test
[Tags] cleanup
Delete NSD ${nsd_name}
@@ -104,4 +93,3 @@
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}
- Run Keyword If Any Tests Failed Delete K8s Cluster ${k8scluster_name}