... The filter parameters are given to this function in key=value format (one argument per key/value pair).
... Fails if the metric is not found or has multiple values.
... Examples of execution:
- ... \${metric}= Get Metric \${prometheus_ip} \${prometheus_port} \${metric}
- ... \${metric}= Get Metric \${prometheus_ip} \${prometheus_port} \${metric} \${param1}=\${value1} \${param2}=\${value2}
+ ... \${metric}= Get Metric \${prometheus_ip} \${prometheus_port} ${prometheus_password} \${metric}
+ ... \${metric}= Get Metric \${prometheus_ip} \${prometheus_port} ${prometheus_password} \${metric} \${param1}=\${value1} \${param2}=\${value2}
- [Arguments] ${prometheus_ip} ${prometheus_port} ${metric} @{filter_parameters}
+ [Arguments] ${prometheus_ip} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric} @{filter_parameters}
${filter}= Set Variable ${EMPTY}
FOR ${param} IN @{filter_parameters}
${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in filter parameters
${filter}= Catenate SEPARATOR= ${filter} ${param_name}="${param_value}",
END
- ${resp}= Execute Prometheus Instant Query ${prometheus_host} ${prometheus_port} query=${metric}{${filter}}
+ ${resp}= Execute Prometheus Instant Query ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} query=${metric}{${filter}}
${result_list}= Convert To List ${resp["data"]["result"]}
${results}= Get Length ${result_list}
Should Not Be Equal As Numbers 0 ${results} msg=Metric ${metric} not found values=false
... Return an inline json with the result of the query.
... The requested URL is the next: http://\${prometheus_ip}:\${prometheus_port}/api/v1/query?\${querystring}
- [Arguments] ${prometheus_ip} ${prometheus_port} ${querystring}
-
- Create Session prometheus http://${prometheus_ip}:${prometheus_port} timeout=${timeout} max_retries=${max_retries}
+ [Arguments] ${prometheus_ip} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${querystring}
+ ${auth}= IF '${prometheus_password}'!='${EMPTY}' Create List ${prometheus_user} ${prometheus_password} ELSE Set Variable None
+ Create Session prometheus http://${prometheus_ip}:${prometheus_port} timeout=${timeout} max_retries=${max_retries} verify=false auth=${auth}
${resp}= GET On Session prometheus /api/v1/query?${querystring} timeout=${timeout}
Status Should Be 200 ${resp}
[Return] ${resp.json()}
Check for SDNC Status
- [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- Wait Until Keyword Succeeds ${sdnc_status_max_wait_time} ${sdnc_status_pol_time} Check If SDNC Is Available ${sdnc_id} ${prometheus_host} ${prometheus_port}
+ Wait Until Keyword Succeeds ${sdnc_status_max_wait_time} ${sdnc_status_pol_time} Check If SDNC Is Available ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Get SDNC ID
Check If SDNC Is Available
- [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_password} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} osm_sdnc_status sdnc_id=${sdnc_id}
+ ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_password} ${prometheus_user} ${prometheus_password} osm_sdnc_status sdnc_id=${sdnc_id}
Should Be Equal As Integers ${metric} 1 msg=SDNC '${sdnc_id}' is not active values=false
Check for VIM Target Metric
- [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
${vim_account_id}= Get VIM Target ID ${vim_name}
- Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Has Metric ${vim_account_id} ${prometheus_host} ${prometheus_port}
+ Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Has Metric ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Check for VIM Target Status
- [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
${vim_account_id}= Get VIM Target ID ${vim_name}
- Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Is Available ${vim_account_id} ${prometheus_host} ${prometheus_port}
+ Wait Until Keyword Succeeds ${vim_status_max_wait_time} ${vim_status_pol_time} Check If VIM Target Is Available ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Get VIM Target ID
Check If VIM Target Is Available
- [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} osm_vim_status vim_account_id=${vim_account_id}
+ ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
Should Be Equal As Integers ${metric} 1 msg=VIM Target '${vim_account_id}' is not active values=false
Check If VIM Target Has Metric
- [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port}
+ [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} osm_vim_status vim_account_id=${vim_account_id}
+ ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
Should Be True ${metric} <2 msg=VIM Target '${vim_account_id}' has no metric
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# VIM configuration
cloud_type = os.environ.get("CLOUD_TYPE", "openstack")
vim_name_prefix = "basic01"
# Get credentias from Openstack Clouds file
os_cloud = os.environ.get("OS_CLOUD")
- clouds_file_paths = ["./clouds.yaml", str(Path.home()) + "/.config/openstack/clouds.yaml", "/etc/openstack/clouds.yaml"]
+ clouds_file_paths = [
+ "./clouds.yaml",
+ str(Path.home()) + "/.config/openstack/clouds.yaml",
+ "/etc/openstack/clouds.yaml",
+ ]
for path in clouds_file_paths:
clouds_file_path = Path(path)
if clouds_file_path.exists():
raise Exception("Auth url not found in Openstack cloud '" + os_cloud + "'")
vim_auth_url = cloud["auth"]["auth_url"]
if not "project_name" in cloud["auth"]:
- raise Exception("Project name not found in Openstack cloud '" + os_cloud + "'")
+ raise Exception(
+ "Project name not found in Openstack cloud '" + os_cloud + "'"
+ )
vim_tenant = cloud["auth"]["project_name"]
- vim_user_domain_name = cloud["auth"]["user_domain_name"] if "user_domain_name" in cloud["auth"] else None
- vim_project_domain_name = cloud["auth"]["project_domain_name"] if "project_domain_name" in cloud["auth"] else None
+ vim_user_domain_name = (
+ cloud["auth"]["user_domain_name"]
+ if "user_domain_name" in cloud["auth"]
+ else None
+ )
+ vim_project_domain_name = (
+ cloud["auth"]["project_domain_name"]
+ if "project_domain_name" in cloud["auth"]
+ else None
+ )
vim_insecure = True if "verify" in cloud and not cloud["verify"] else None
-
+
# Extra config
vim_config_dict = {}
vim_config_dict["vim_network_name"] = os.environ.get("VIM_MGMT_NET")
vim_config_dict["user_domain_name"] = vim_user_domain_name
if vim_insecure:
vim_config_dict["insecure"] = True
- vim_config = "'{}'".format(yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip('\r\n'))
+ vim_config = "'{}'".format(
+ yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
+ "\r\n"
+ )
+ )
elif cloud_type == "azure":
# Azure VIM
vim_config_dict["vnet_name"] = os.environ.get("VNET_NAME")
if "AZURE_FLAVORS_PATTERN" in os.environ:
vim_config_dict["flavors_pattern"] = os.environ.get("AZURE_FLAVORS_PATTERN")
- vim_config = "'{}'".format(yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip('\r\n'))
+ vim_config = "'{}'".format(
+ yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip(
+ "\r\n"
+ )
+ )
else:
raise Exception("VIM type not supported: '" + cloud_type + "'")
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# VIM Configuration
vim_account_type = "openstack"
# Get credentials from Openstack clouds file
os_cloud = os.environ.get("OS_CLOUD")
-clouds_file_paths = ["./clouds.yaml", str(Path.home()) + "/.config/openstack/clouds.yaml", "/etc/openstack/clouds.yaml"]
+clouds_file_paths = [
+ "./clouds.yaml",
+ str(Path.home()) + "/.config/openstack/clouds.yaml",
+ "/etc/openstack/clouds.yaml",
+]
for path in clouds_file_paths:
clouds_file_path = Path(path)
if clouds_file_path.exists():
if not "project_name" in cloud["auth"]:
raise Exception("Project name not found in Openstack cloud '" + os_cloud + "'")
vim_tenant = cloud["auth"]["project_name"]
- vim_user_domain_name = cloud["auth"]["user_domain_name"] if "user_domain_name" in cloud["auth"] else None
- vim_project_domain_name = cloud["auth"]["project_domain_name"] if "project_domain_name" in cloud["auth"] else None
+ vim_user_domain_name = (
+ cloud["auth"]["user_domain_name"]
+ if "user_domain_name" in cloud["auth"]
+ else None
+ )
+ vim_project_domain_name = (
+ cloud["auth"]["project_domain_name"]
+ if "project_domain_name" in cloud["auth"]
+ else None
+ )
vim_insecure = True if "verify" in cloud and not cloud["verify"] else None
# Extra VIM config
vim_config_dict["insecure"] = True
vim_config_dict["disable_network_port_security"] = True
vim_config_dict["management_network_name"] = os.environ.get("VIM_MGMT_NET")
-vim_config = "'{}'".format(yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip('\r\n'))
+vim_config = "'{}'".format(
+ yaml.safe_dump(vim_config_dict, default_flow_style=True, width=10000).rstrip("\r\n")
+)
# Get ${HOME} from local machine
home = str(Path.home())
# NS and VNF descriptor package folder
-vnfd_pkg = 'hackfest_multivdu_vnf'
-nsd_pkg = 'hackfest_multivdu_ns'
+vnfd_pkg = "hackfest_multivdu_vnf"
+nsd_pkg = "hackfest_multivdu_ns"
# NS and VNF descriptor id
-vnfd_name = 'hackfest_multivdu-vnf'
-nsd_name = 'hackfest_multivdu-ns'
+vnfd_name = "hackfest_multivdu-vnf"
+nsd_name = "hackfest_multivdu-ns"
# NS instance name
-ns_name = 'basic_08_disable_port_security_network_level_test'
+ns_name = "basic_08_disable_port_security_network_level_test"
# SSH keys to be used
-publickey = home + '/.ssh/id_rsa.pub'
-privatekey = home + '/.ssh/id_rsa'
+publickey = home + "/.ssh/id_rsa.pub"
+privatekey = home + "/.ssh/id_rsa"
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)
+ 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)
- return prometheus_host, prometheus_port
+ 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
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# SDNC Configuration
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
# Prometheus host and port
-(prometheus_host, prometheus_port) = get_prometheus_info()
+(
+ prometheus_host,
+ prometheus_port,
+ prometheus_user,
+ prometheus_password,
+) = get_prometheus_info()
${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}
Check VIM Target Operational State ${vim_name}
- Check for VIM Target Metric ${vim_name} ${prometheus_host} ${prometheus_port}
+ ${stdout}= Check for VIM Target Metric ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Delete VIM Target By Name
${created_vim_account_id}= Create VIM Target ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} config=${vim_config}
Set Suite Variable ${created_vim_account_id}
Check VIM Target Operational State ${vim_name}
- Check for VIM Target Status ${vim_name} ${prometheus_host} ${prometheus_port}
+ Check for VIM Target Status ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Delete VIM Target By ID
Create VIM With Port Security Disabled
${created_vim_account_id}= Create VIM Target ${vim_name} ${vim_user} ${vim_password} ${vim_auth_url} ${vim_tenant} ${vim_account_type} config=${vim_config}
- Check for VIM Target Status ${vim_name} ${prometheus_host} ${prometheus_port}
+ Check for VIM Target Status ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Create VNF Descriptor
Check SDNC Status Is Healthy
- Check for SDNC Status ${sdnc_id} ${prometheus_host} ${prometheus_port}
+ Check for SDNC Status ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
Delete Basic SDNC
Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
Variable Should Exist ${metric_1_name} msg=Prometheus first metric name is not available
Variable Should Exist ${metric_2_name} msg=Prometheus second metric name is not available
- ${metric_1_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_1_name}
+ ${metric_1_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_1_name}
Run Keyword If ${metric_1_value} <= 0 Fail msg=The metric '${metric_1_name}' value is '${metric_1_value}'
- ${metric_2_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_2_name}
+ ${metric_2_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_2_name}
Run Keyword If ${metric_2_value} <= 0 Fail msg=The metric '${metric_2_name}' value is '${metric_2_value}'
Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
- ${metric_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_name}
+ ${metric_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_name}
Run Keyword If ${metric_value} <= 0 Fail msg=The metric '${metric_name}' value is '${metric_value}'
Run Keyword If ${metric_value} >= ${metric_threshold} Fail msg=The metric '${metric_name}' value is higher than '${metric_threshold}' before scaling
Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
- ${metric_value}= Get Metric ${prometheus_host} ${prometheus_port} ${metric_name}
+ ${metric_value}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_name}
Run Keyword If ${metric_value} <= ${metric_threshold} Fail msg=The metric '${metric_name}' value is '${metric_value}' which is lower than '${metric_threshold}'
Variable Should Exist ${prometheus_host} msg=Prometheus address is not available
Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
Variable Should Exist ${metric_name} msg=Prometheus metric name is not available
- ${metric_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_name}
+ ${metric_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_name}
Run Keyword If ${metric_value} <= 0 Fail msg=The metric '${metric_name}' value is '${metric_value}'
Variable Should Exist ${prometheus_port} msg=Prometheus port is not available
Variable Should Exist ${metric_1_name} msg=Prometheus first metric name is not available
Variable Should Exist ${metric_2_name} msg=Prometheus second metric name is not available
- ${metric_1_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_1_name} ${metric_1_filter}
+ ${metric_1_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_1_name} ${metric_1_filter}
Run Keyword If ${metric_1_value} <= 0 Fail msg=The metric '${metric_1_name}' value is '${metric_1_value}'
- ${metric_2_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${metric_2_name} ${metric_2_filter}
+ ${metric_2_value}= Wait Until Keyword Succeeds ${prometheus_poll_retries} ${prometheus_poll_timeout} Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric_2_name} ${metric_2_filter}
Run Keyword If ${metric_2_value} <= 0 Fail msg=The metric '${metric_2_name}' value is '${metric_2_value}'