Set Testsuite Prometheus Variables
[Documentation] Set Testsuite Prometheus Variables to be used in subsequent test cases
- IF ${PROMETHEUS_HOST} == 'UNKNOWN'
+ IF '${PROMETHEUS_HOST}' == 'UNKNOWN'
${local_prometheus_host}= Get Environment Variable OSM_HOSTNAME
+ IF '${local_prometheus_host}'.startswith('nbi.')
+ ${local_prometheus_host}= Replace String ${local_prometheus_host} nbi. prometheus.
+ END
Set Suite Variable ${PROMETHEUS_HOST} ${local_prometheus_host}
- Set Suite Variable ${PROMETHEUS_HOST} 9091
+ Set Suite Variable ${PROMETHEUS_PORT} 80
END
+ Set Suite Variable ${PROMETHEUS_URL} http://${PROMETHEUS_HOST}:${PROMETHEUS_PORT}
Log ${PROMETHEUS_PORT}
Log ${PROMETHEUS_HOST}
+ Log ${PROMETHEUS_URL}
Log ${PROMETHEUS_USER}
Log ${PROMETHEUS_PASSWORD}
... 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} ${prometheus_password} \${metric}
- ... \${metric}= Get Metric \${prometheus_ip} \${prometheus_port} ${prometheus_password} \${metric} \${param1}=\${value1} \${param2}=\${value2}
- [Arguments] ${prometheus_ip} ${prometheus_port} ${prometheus_user} ${prometheus_password} ${metric} @{filter_parameters}
+ ... \${metric}= Get Metric \${prometheus_url} ${prometheus_password} \${metric}
+ ... \${metric}= Get Metric \${prometheus_url} ${prometheus_password} \${metric} \${param1}=\${value1} \${param2}=\${value2}
+ [Arguments] ${prometheus_url} ${prometheus_user} ${prometheus_password} ${metric} @{filter_parameters}
+ Log ${prometheus_url}
+ Log ${prometheus_user}
+ Log ${prometheus_password}
+ Log ${metric}
+ Log ${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
Log ${match},${param_name},${param_value}
${filter}= Catenate SEPARATOR= ${filter} ${param_name}="${param_value}",
END
- ${resp}= Execute Prometheus Instant Query ${prometheus_ip} ${prometheus_port} ${prometheus_user} ${prometheus_password} query=${metric}{${filter}}
+ ${resp}= Execute Prometheus Instant Query ${prometheus_url} ${prometheus_user} ${prometheus_password} query=${metric}{${filter}}
+ Log ${resp}
${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
Execute Prometheus Instant Query
[Documentation] Execute a Prometheus Instant Query using HTTP API.
... 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} ${prometheus_user} ${prometheus_password} ${querystring}
+ ... The requested URL is the next: \${prometheus_url}/api/v1/query?\${querystring}
+ [Arguments] ${prometheus_url} ${prometheus_user} ${prometheus_password} ${querystring}
+ Log ${prometheus_url}
+ Log ${prometheus_user}
+ Log ${prometheus_password}
+ Log ${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}
+ Create Session prometheus ${prometheus_url} 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
[Documentation] Check in a loop if the value of the metric osm_sdnc_status in Prometheus for the SDN controller is 1 (reachable).
- [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} ${prometheus_user} ${prometheus_password}
+ [Arguments] ${sdnc_id} ${prometheus_url} ${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_url} ${prometheus_user} ${prometheus_password}
Get SDNC ID
[Documentation] Check if an SDN controller identified by name exists in OSM, and return the id.
Check If SDNC Is Available
[Documentation] Check if the value of the metric osm_sdnc_status in Prometheus for the SDN controller is 1 (reachable).
- [Arguments] ${sdnc_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_sdnc_status sdnc_id=${sdnc_id}
+ [Arguments] ${sdnc_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
+ ${metric}= Get Metric ${prometheus_url} ${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
[Documentation] Check in a loop if the metric of osm_vim_status is present in Prometheus for the VIM account in OSM.
- [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
+ [Arguments] ${vim_name} ${prometheus_url} ${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} ${prometheus_user} ${prometheus_password}
+ Wait Until Keyword Succeeds ${VIM_STATUS_MAX_WAIT_TIME} ${VIM_STATUS_POL_TIME} Check If VIM Target Has Metric ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
Check For VIM Target Status
[Documentation] Check in a loop if the value of the metric osm_vim_status in Prometheus for the VIM account is 1 (reachable).
- [Arguments] ${vim_name} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
+ [Arguments] ${vim_name} ${prometheus_url} ${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} ${prometheus_user} ${prometheus_password}
+ Wait Until Keyword Succeeds ${VIM_STATUS_MAX_WAIT_TIME} ${VIM_STATUS_POL_TIME} Check If VIM Target Is Available ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
Get VIM Target ID
[Documentation] Get from OSM the VIM account id associated to the VIM account name passed as parameter.
Check If VIM Target Is Available
[Documentation] Check if the value of the metric osm_vim_status in Prometheus for the VIM account is 1 (reachable).
- [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
+ [Arguments] ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
+ Log ${prometheus_url}
+ Log ${prometheus_user}
+ Log ${prometheus_password}
+ Log ${vim_account_id}
+ ${metric}= Get Metric ${prometheus_url} ${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
[Documentation] Check if the metric of osm_vim_status is present in Prometheus for the VIM account in OSM.
- [Arguments] ${vim_account_id} ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password}
- ${metric}= Get Metric ${prometheus_host} ${prometheus_port} ${prometheus_user} ${prometheus_password} osm_vim_status vim_account_id=${vim_account_id}
+ [Arguments] ${vim_account_id} ${prometheus_url} ${prometheus_user} ${prometheus_password}
+ ${metric}= Get Metric ${prometheus_url} ${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
${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}
- ${stdout}= Check For VIM Target Metric ${VIM_NAME} ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
+ ${stdout}= Check For VIM Target Metric ${VIM_NAME} ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
Log ${stdout}
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} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
+ Check For VIM Target Status ${VIM_NAME} ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
Delete VIM Target By ID
[Documentation] Delete the VIM Target created in previous test-case by its ID.
... (no firewall).
${created_vim_account_id}= Create VIM Target ${VIM_NAME} ${VIM_USER} ${VIM_PASSWORD} ${VIM_AUTH_URL} ${VIM_TENANT} ${VIM_ACCOUNT_TYPE} config=${VIM_CONFIG}
Log ${created_vim_account_id}
- Check For VIM Target Status ${VIM_NAME} ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
+ Check For VIM Target Status ${VIM_NAME} ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
Create VNF Descriptor
[Documentation] Upload VNF package for the testsuite.
Check SDNC Status Is Healthy
[Documentation] Check in Prometheus that the SDN controller is in healthy state.
- Check For SDNC Status ${SDNC_ID} ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
+ Check For SDNC Status ${SDNC_ID} ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD}
Delete Basic SDNC
[Documentation] Delete SDN controller from OSM.
[Documentation] Check that the expected metrics are present in Prometheus (pushed from SA modules).
Variable Should Exist ${PROMETHEUS_POLL_RETRIES} msg=Metric polling retries is not available
Variable Should Exist ${PROMETHEUS_POLL_TIMEOUT} msg=Metric polling timeout is not available
- 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 ${PROMETHEUS_URL} msg=Prometheus URL 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_filter}= Set Variable ns_id=${NS_ID}
- ${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_filter}
+ ${metric_1_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_1_NAME} ${metric_filter}
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} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_2_NAME} ${metric_filter}
+ ${metric_2_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_2_NAME} ${metric_filter}
IF ${metric_2_value} <= 0 Fail msg=The metric '${METRIC_2_NAME}' value is '${metric_2_value}'
Delete NS Instance
[Documentation] Get from Prometheus the VIM metric associated to the VNF auto-scaling group.
Variable Should Exist ${PROMETHEUS_POLL_RETRIES} msg=Metric polling retries is not available
Variable Should Exist ${PROMETHEUS_POLL_TIMEOUT} msg=Metric polling timeout is not available
- 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 ${PROMETHEUS_URL} msg=Prometheus URL is not available
Variable Should Exist ${METRIC_NAME} msg=Prometheus metric name is not available
${metric_filter}= Set Variable ns_id=${NS_ID}
- ${metric_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
+ ${metric_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
IF ${metric_value} <= 0
Fail msg=The metric '${METRIC_NAME}' value is '${metric_value}'
END
Check VIM-based Metric Exceeds Threshold
[Documentation] Auxiliar keyword to check if metric exceeds 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 ${PROMETHEUS_URL} msg=Prometheus URL is not available
Variable Should Exist ${METRIC_NAME} msg=Prometheus metric name is not available
${metric_filter}= Set Variable ns_id=${NS_ID}
- ${metric_value}= Get Metric ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
+ ${metric_value}= Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
IF ${metric_value} <= ${METRIC_THRESHOLD}
Fail msg=The metric '${METRIC_NAME}' value is '${metric_value}' which is lower than '${METRIC_THRESHOLD}'
END
[Documentation] Check that the expected metric is present in Prometheus (pushed from SA modules).
Variable Should Exist ${PROMETHEUS_POLL_RETRIES} msg=Metric polling retries is not available
Variable Should Exist ${PROMETHEUS_POLL_TIMEOUT} msg=Metric polling timeout is not available
- 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 ${PROMETHEUS_URL} msg=Prometheus URL is not available
Variable Should Exist ${METRIC_NAME} msg=Prometheus metric name is not available
${metric_filter}= Set Variable ns_id=${NS_ID}
- ${metric_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_HOST} ${PROMETHEUS_PORT} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
+ ${metric_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_NAME} ${metric_filter}
IF ${metric_value} <= 0 Fail msg=The metric '${METRIC_NAME}' value is '${metric_value}'
Check Alarms Were Received
Get VNF SNMP Metrics
[Documentation] Check that SNMP metrics from the VNF are stored in Prometheus.
- 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 ${PROMETHEUS_URL} msg=Prometheus URL 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} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_1_NAME} ${METRIC_1_FILTER}
+ ${metric_1_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_1_NAME} ${METRIC_1_FILTER}
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} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_2_NAME} ${METRIC_2_FILTER}
+ ${metric_2_value}= Wait Until Keyword Succeeds ${PROMETHEUS_POLL_RETRIES} ${PROMETHEUS_POLL_TIMEOUT} Get Metric ${PROMETHEUS_URL} ${PROMETHEUS_USER} ${PROMETHEUS_PASSWORD} ${METRIC_2_NAME} ${METRIC_2_FILTER}
IF ${metric_2_value} <= 0 Fail msg=The metric '${METRIC_2_NAME}' value is '${metric_2_value}'
Delete NS Instance