X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2Ftests.git;a=blobdiff_plain;f=robot-systest%2Flib%2Fprometheus_lib.robot;fp=robot-systest%2Flib%2Fprometheus_lib.robot;h=5fdda496a7e38b1dd407095b4b847c000afc9baf;hp=c76b560e4efafa05ea6fbf0fd3e076c9356a9cf8;hb=063677c719bd33d8674903ed5b7f11e7368da23a;hpb=73951e60380e7b6b908945237cd82c115f81f882 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 @@ Get Metric ... 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 @@ Execute Prometheus Instant Query ... 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()}