Check for listening exporter before querying

CI runs have exposed timing issues where promtool/e2e scripts query the
exporter, before exporter has begun listening.

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy 2022-02-27 07:34:50 +10:00
parent 6941ee7ab2
commit 79ecaf6a99
No known key found for this signature in database
GPG Key ID: 235C15B6086C9D7E
2 changed files with 20 additions and 4 deletions

View File

@ -30,8 +30,16 @@ $exporter_proc = Start-Process `
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" ` -RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log" -RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
# Give exporter some time to start # Exporter can take some time to start
Start-Sleep 15 for ($i=1; $i -le 5; $i++) {
Start-Sleep 10
$netstat_output = netstat -anp tcp | Select-String 'listening'
if ($netstat_output -like '*:9182*') {
break
}
Write-Host "Waiting for exporter to start"
}
$response = Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9182/metrics $response = Invoke-WebRequest -UseBasicParsing -URI http://127.0.0.1:9182/metrics
# Response output must be split and saved as UTF-8. # Response output must be split and saved as UTF-8.

View File

@ -98,8 +98,16 @@ $exporter_proc = Start-Process `
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" ` -RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
-RedirectStandardError "$($temp_dir)/windows_exporter_error.log" -RedirectStandardError "$($temp_dir)/windows_exporter_error.log"
# Give exporter some time to start # Exporter can take some time to start
Start-Sleep 15 for ($i=1; $i -le 5; $i++) {
Start-Sleep 10
$netstat_output = netstat -anp tcp | Select-String 'listening'
if ($netstat_output -like '*:9183*') {
break
}
Write-Host "Waiting for exporter to start"
}
# Omit metrics from client_golang library; we're not responsible for these # Omit metrics from client_golang library; we're not responsible for these
$skip_re = "^[#]?\s*(HELP|TYPE)?\s*go_" $skip_re = "^[#]?\s*(HELP|TYPE)?\s*go_"