From 2d4de332830e2f6deb4705fcc85d140c92e27c2c Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Wed, 28 Jun 2023 00:23:34 +0200 Subject: [PATCH] Remove common_helpers.py and update tests using it Change-Id: I013ce2037994baa28efe0dedb5b206a4231449a3 Signed-off-by: garciadeblas --- robot-systest/lib/prometheus_lib.robot | 19 +++++++++++++++ ..._01-crud_operations_on_vim_targets_data.py | 9 ------- ...isable_port_security_network_level_data.py | 10 -------- robot-systest/resources/common_helpers.py | 24 ------------------- .../epa_03-crud_operations_on_sdnc_data.py | 11 --------- .../sa_01-vnf_with_vim_metrics_data.py | 22 ----------------- ...f_with_vim_metrics_and_autoscaling_data.py | 22 ----------------- .../sa_07-alarms_from_sa-related_vnfs_data.py | 22 ----------------- ...sa_08-vnf_with_vnf_indicators_snmp_data.py | 22 ----------------- ...ic_01-crud_operations_on_vim_targets.robot | 9 +++++++ ...-disable_port_security_network_level.robot | 7 ++++++ .../epa_03-crud_operations_on_sdnc.robot | 8 +++++++ .../sa_01-vnf_with_vim_metrics.robot | 11 +++++---- ...vnf_with_vim_metrics_and_autoscaling.robot | 10 +++++--- .../sa_07-alarms_from_sa-related_vnfs.robot | 9 +++++-- .../sa_08-vnf_with_vnf_indicators_snmp.robot | 9 +++++-- 16 files changed, 71 insertions(+), 153 deletions(-) delete mode 100644 robot-systest/resources/common_helpers.py delete mode 100644 robot-systest/resources/sa_01-vnf_with_vim_metrics_data.py delete mode 100644 robot-systest/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py delete mode 100644 robot-systest/resources/sa_07-alarms_from_sa-related_vnfs_data.py delete mode 100644 robot-systest/resources/sa_08-vnf_with_vnf_indicators_snmp_data.py diff --git a/robot-systest/lib/prometheus_lib.robot b/robot-systest/lib/prometheus_lib.robot index 5fdda49..33208f3 100644 --- a/robot-systest/lib/prometheus_lib.robot +++ b/robot-systest/lib/prometheus_lib.robot @@ -21,9 +21,28 @@ Library RequestsLibrary *** Variables *** ${timeout} 30 ${max_retries} 1 +${prometheus_host} %{PROMETHEUS_HOSTNAME} +${prometheus_port} 9090 +${prometheus_user} %{PROMETHEUS_USER} +${prometheus_password} %{PROMETHEUS_PASSWORD} *** Keywords *** +Set Testsuite Prometheus Variables + [Documentation] Set Testsuite Prometheus Variables to be used in subsequent test cases + + ${prometheus_port} Set Variable If '${prometheus_host}'=='${EMPTY}' 9091 + Log ${prometheus_port} + ${prometheus_host} Set Variable If '${prometheus_host}'=='${EMPTY}' %{OSM_HOSTNAME} + Log ${prometheus_host} + Log ${prometheus_user} + Log ${prometheus_password} + Set Suite Variable ${prometheus_host} + Set Suite Variable ${prometheus_port} + Set Suite Variable ${prometheus_user} + Set Suite Variable ${prometheus_password} + + Get Metric [Documentation] Get the instant value of a metric from Prometheus using multiple filter parameters. ... The filter parameters are given to this function in key=value format (one argument per key/value pair). diff --git a/robot-systest/resources/basic_01-crud_operations_on_vim_targets_data.py b/robot-systest/resources/basic_01-crud_operations_on_vim_targets_data.py index 101f3d5..1e35e78 100644 --- a/robot-systest/resources/basic_01-crud_operations_on_vim_targets_data.py +++ b/robot-systest/resources/basic_01-crud_operations_on_vim_targets_data.py @@ -13,17 +13,8 @@ import os from pathlib import Path import yaml -from common_helpers import get_prometheus_info -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() - # VIM configuration cloud_type = os.environ.get("CLOUD_TYPE", "openstack") if cloud_type == "openstack": diff --git a/robot-systest/resources/basic_08-disable_port_security_network_level_data.py b/robot-systest/resources/basic_08-disable_port_security_network_level_data.py index b35ed87..ab2edd8 100644 --- a/robot-systest/resources/basic_08-disable_port_security_network_level_data.py +++ b/robot-systest/resources/basic_08-disable_port_security_network_level_data.py @@ -14,16 +14,6 @@ import os from pathlib import Path import yaml -from common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() # VIM Configuration vim_account_type = "openstack" diff --git a/robot-systest/resources/common_helpers.py b/robot-systest/resources/common_helpers.py deleted file mode 100644 index 87a3d34..0000000 --- a/robot-systest/resources/common_helpers.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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. -import os - - -def get_prometheus_info(): - if os.environ.get("PROMETHEUS_HOSTNAME", False): - prometheus_host = os.environ.get("PROMETHEUS_HOSTNAME") - prometheus_port = os.environ.get("PROMETHEUS_PORT", 9090) - else: - prometheus_host = os.environ.get("OSM_HOSTNAME") - prometheus_port = os.environ.get("PROMETHEUS_PORT", 9091) - prometheus_user = os.environ.get("PROMETHEUS_USER", "") - prometheus_password = os.environ.get("PROMETHEUS_PASSWORD", "") - return prometheus_host, prometheus_port, prometheus_user, prometheus_password diff --git a/robot-systest/resources/epa_03-crud_operations_on_sdnc_data.py b/robot-systest/resources/epa_03-crud_operations_on_sdnc_data.py index c11054a..fe8d541 100644 --- a/robot-systest/resources/epa_03-crud_operations_on_sdnc_data.py +++ b/robot-systest/resources/epa_03-crud_operations_on_sdnc_data.py @@ -12,17 +12,6 @@ import os -from common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() - # SDNC Configuration sdnc_name = "epa_03" diff --git a/robot-systest/resources/sa_01-vnf_with_vim_metrics_data.py b/robot-systest/resources/sa_01-vnf_with_vim_metrics_data.py deleted file mode 100644 index a7a3456..0000000 --- a/robot-systest/resources/sa_01-vnf_with_vim_metrics_data.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() diff --git a/robot-systest/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py b/robot-systest/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py deleted file mode 100644 index a7a3456..0000000 --- a/robot-systest/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() diff --git a/robot-systest/resources/sa_07-alarms_from_sa-related_vnfs_data.py b/robot-systest/resources/sa_07-alarms_from_sa-related_vnfs_data.py deleted file mode 100644 index a7a3456..0000000 --- a/robot-systest/resources/sa_07-alarms_from_sa-related_vnfs_data.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() diff --git a/robot-systest/resources/sa_08-vnf_with_vnf_indicators_snmp_data.py b/robot-systest/resources/sa_08-vnf_with_vnf_indicators_snmp_data.py deleted file mode 100644 index a7a3456..0000000 --- a/robot-systest/resources/sa_08-vnf_with_vnf_indicators_snmp_data.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 common_helpers import get_prometheus_info - - -# Prometheus host and port -( - prometheus_host, - prometheus_port, - prometheus_user, - prometheus_password, -) = get_prometheus_info() diff --git a/robot-systest/testsuite/basic_01-crud_operations_on_vim_targets.robot b/robot-systest/testsuite/basic_01-crud_operations_on_vim_targets.robot index eb35010..cdfe0bd 100644 --- a/robot-systest/testsuite/basic_01-crud_operations_on_vim_targets.robot +++ b/robot-systest/testsuite/basic_01-crud_operations_on_vim_targets.robot @@ -15,11 +15,14 @@ Documentation [BASIC-01] CRUD operations on VIM targets. ... All tests will be performed over an Openstack VIM, and the credentials will be loaded from clouds.yaml file. Resource %{ROBOT_DEVOPS_FOLDER}/lib/vim_lib.robot +Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_01-crud_operations_on_vim_targets_data.py Force Tags basic_01 cluster_main daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation + *** Test Cases *** Create VIM Target Basic @@ -69,3 +72,9 @@ Delete VIM Target By ID Should Be Equal As Strings ${vim_account_id} ${created_vim_account_id} Delete VIM Target ${vim_account_id} + +*** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables diff --git a/robot-systest/testsuite/basic_08-disable_port_security_network_level.robot b/robot-systest/testsuite/basic_08-disable_port_security_network_level.robot index 25164f5..11effd9 100644 --- a/robot-systest/testsuite/basic_08-disable_port_security_network_level.robot +++ b/robot-systest/testsuite/basic_08-disable_port_security_network_level.robot @@ -27,6 +27,7 @@ Variables %{ROBOT_DEVOPS_FOLDER}/resources/basic_08-disable_port_security_netw Force Tags basic_08 cluster_main daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Suite Cleanup @@ -87,6 +88,12 @@ Delete VIM *** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables + + Suite Cleanup [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance diff --git a/robot-systest/testsuite/epa_03-crud_operations_on_sdnc.robot b/robot-systest/testsuite/epa_03-crud_operations_on_sdnc.robot index 982a8de..48c9e90 100644 --- a/robot-systest/testsuite/epa_03-crud_operations_on_sdnc.robot +++ b/robot-systest/testsuite/epa_03-crud_operations_on_sdnc.robot @@ -19,6 +19,7 @@ Variables %{ROBOT_DEVOPS_FOLDER}/resources/epa_03-crud_operations_on_sdnc_data Force Tags epa_03 cluster_epa daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Delete Basic SDNC @@ -44,3 +45,10 @@ Delete Basic SDNC [Tags] cleanup Delete SDNC ${sdnc_name} + + +*** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables diff --git a/robot-systest/testsuite/sa_01-vnf_with_vim_metrics.robot b/robot-systest/testsuite/sa_01-vnf_with_vim_metrics.robot index 8c3d677..2a98e13 100644 --- a/robot-systest/testsuite/sa_01-vnf_with_vim_metrics.robot +++ b/robot-systest/testsuite/sa_01-vnf_with_vim_metrics.robot @@ -23,10 +23,9 @@ Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot -Variables %{ROBOT_DEVOPS_FOLDER}/resources/sa_01-vnf_with_vim_metrics_data.py - Force Tags sa_01 cluster_sa daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Suite Cleanup @@ -107,6 +106,12 @@ Delete VNF Descriptor *** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables + + Suite Cleanup [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance @@ -115,5 +120,3 @@ Suite Cleanup Run Keyword If Any Tests Failed Delete NSD ${nsd_name} Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} - - diff --git a/robot-systest/testsuite/sa_02-vnf_with_vim_metrics_and_autoscaling.robot b/robot-systest/testsuite/sa_02-vnf_with_vim_metrics_and_autoscaling.robot index ae2253d..3459d12 100644 --- a/robot-systest/testsuite/sa_02-vnf_with_vim_metrics_and_autoscaling.robot +++ b/robot-systest/testsuite/sa_02-vnf_with_vim_metrics_and_autoscaling.robot @@ -24,10 +24,9 @@ Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot -Variables %{ROBOT_DEVOPS_FOLDER}/resources/sa_02-vnf_with_vim_metrics_and_autoscaling_data.py - Force Tags sa_02 cluster_sa daily regression sanity azure +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Suite Cleanup @@ -177,6 +176,12 @@ Delete VNF Descriptor *** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables + + Suite Cleanup [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance @@ -194,4 +199,3 @@ Check VIM-based Metric Exceeds Threshold ${metric_filter}= Set Variable ns_id=${ns_id} ${metric_value}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_name} ${metric_filter} Run Keyword If ${metric_value} <= ${metric_threshold} Fail msg=The metric '${metric_name}' value is '${metric_value}' which is lower than '${metric_threshold}' - diff --git a/robot-systest/testsuite/sa_07-alarms_from_sa-related_vnfs.robot b/robot-systest/testsuite/sa_07-alarms_from_sa-related_vnfs.robot index b6679e0..d79a762 100644 --- a/robot-systest/testsuite/sa_07-alarms_from_sa-related_vnfs.robot +++ b/robot-systest/testsuite/sa_07-alarms_from_sa-related_vnfs.robot @@ -24,10 +24,9 @@ Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot -Variables %{ROBOT_DEVOPS_FOLDER}/resources/sa_07-alarms_from_sa-related_vnfs_data.py - Force Tags sa_07 cluster_sa daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Suite Cleanup @@ -184,6 +183,12 @@ Delete Webhook Service VNF Descriptor *** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables + + Suite Cleanup [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance diff --git a/robot-systest/testsuite/sa_08-vnf_with_vnf_indicators_snmp.robot b/robot-systest/testsuite/sa_08-vnf_with_vnf_indicators_snmp.robot index a937bcd..ea8873c 100644 --- a/robot-systest/testsuite/sa_08-vnf_with_vnf_indicators_snmp.robot +++ b/robot-systest/testsuite/sa_08-vnf_with_vnf_indicators_snmp.robot @@ -23,10 +23,9 @@ Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot Resource %{ROBOT_DEVOPS_FOLDER}/lib/prometheus_lib.robot -Variables %{ROBOT_DEVOPS_FOLDER}/resources/sa_08-vnf_with_vnf_indicators_snmp_data.py - Force Tags sa_08 cluster_k8s daily regression +Suite Setup Run Keyword And Ignore Error Suite Preparation Suite Teardown Run Keyword And Ignore Error Suite Cleanup @@ -102,6 +101,12 @@ Delete VNF Descriptor *** Keywords *** +Suite Preparation + [Documentation] Test Suite Preparation: Setting Prometheus Testsuite Variables + + Set Testsuite Prometheus Variables + + Suite Cleanup [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance -- 2.17.1