Fix setup of prometheus suite variables in prometheus_lib 34/13934/3
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 5 Oct 2023 09:46:45 +0000 (11:46 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 5 Oct 2023 11:29:51 +0000 (13:29 +0200)
Change-Id: I5184c7d216937aa1a6c05695a4197353eea96387
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
robot-systest/lib/prometheus_lib.robot

index 33208f3..0f4f07c 100644 (file)
@@ -15,32 +15,32 @@ Documentation   Library to obtain metrics from Prometheus.
 
 Library   String
 Library   Collections
+Library   OperatingSystem
 Library   RequestsLibrary
 
 
 *** Variables ***
 ${timeout}   30
 ${max_retries}   1
-${prometheus_host}   %{PROMETHEUS_HOSTNAME}
-${prometheus_port}   9090
-${prometheus_user}   %{PROMETHEUS_USER}
-${prometheus_password}   %{PROMETHEUS_PASSWORD}
+${prometheus_host}   %{PROMETHEUS_HOSTNAME=UNKNOWN}
+${prometheus_port}   %{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
+    IF   '${prometheus_host}' == 'UNKNOWN'
+        ${local_prometheus_host}=   Get Environment Variable   OSM_HOSTNAME
+        Set Suite Variable   ${prometheus_host}   ${local_prometheus_host}
+        Set Suite Variable   ${prometheus_port}   9091
+    END
     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