Fix Bug 2197 - Prometheus cannot be authenticated in Robot tests
Change-Id: I1c610968fea5f13711d6d6d8bed5ddc7422a6d3f
Signed-off-by: Guillermo Calvino <guillermo.calvino@canonical.com>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/robot-systest/lib/prometheus_lib.robot b/robot-systest/lib/prometheus_lib.robot
index c76b560..5fdda49 100644
--- a/robot-systest/lib/prometheus_lib.robot
+++ b/robot-systest/lib/prometheus_lib.robot
@@ -29,17 +29,17 @@
... 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
@@ -52,9 +52,9 @@
... 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()}
diff --git a/robot-systest/lib/sdnc_lib.robot b/robot-systest/lib/sdnc_lib.robot
index 0b4508b..1089b7c 100644
--- a/robot-systest/lib/sdnc_lib.robot
+++ b/robot-systest/lib/sdnc_lib.robot
@@ -80,9 +80,9 @@
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
@@ -95,7 +95,7 @@
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
diff --git a/robot-systest/lib/vim_lib.robot b/robot-systest/lib/vim_lib.robot
index 8fd7e51..bfaae36 100644
--- a/robot-systest/lib/vim_lib.robot
+++ b/robot-systest/lib/vim_lib.robot
@@ -73,17 +73,17 @@
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
@@ -110,14 +110,14 @@
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