diff --git a/tools/end-to-end-test.ps1 b/tools/end-to-end-test.ps1 index 1d370749..3af46a82 100644 --- a/tools/end-to-end-test.ps1 +++ b/tools/end-to-end-test.ps1 @@ -30,8 +30,16 @@ $exporter_proc = Start-Process ` -RedirectStandardOutput "$($temp_dir)/windows_exporter.log" ` -RedirectStandardError "$($temp_dir)/windows_exporter_error.log" -# Give exporter some time to start -Start-Sleep 15 +# Exporter can take some time to start +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 output must be split and saved as UTF-8. diff --git a/tools/promtool.ps1 b/tools/promtool.ps1 index 16fe32c6..46d3941a 100644 --- a/tools/promtool.ps1 +++ b/tools/promtool.ps1 @@ -98,8 +98,16 @@ $exporter_proc = Start-Process ` -RedirectStandardOutput "$($temp_dir)/windows_exporter.log" ` -RedirectStandardError "$($temp_dir)/windows_exporter_error.log" -# Give exporter some time to start -Start-Sleep 15 +# Exporter can take some time to start +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 $skip_re = "^[#]?\s*(HELP|TYPE)?\s*go_"