Author: Martina Ferrari <tina@debian.org>
Description: Fix test failures due to race conditions
Forwarded: https://github.com/prometheus/exporter-toolkit/issues/108
Last-Updated: Mon, 29 Aug 2022 17:39:56 +0000

--- a/web/users_test.go
+++ b/web/users_test.go
@@ -18,6 +18,7 @@
 	"net/http"
 	"sync"
 	"testing"
+	"time"
 )
 
 // TestBasicAuthCache validates that the cache is working by calling a password
@@ -42,6 +43,7 @@
 		ListenAndServe(server, "testdata/tls_config_users_noTLS.good.yml", testlogger)
 		close(done)
 	}()
+	time.Sleep(250 * time.Millisecond)
 
 	login := func(username, password string, code int) {
 		client := &http.Client{}
@@ -106,6 +108,7 @@
 		ListenAndServe(server, "testdata/tls_config_users_noTLS.good.yml", testlogger)
 		close(done)
 	}()
+	time.Sleep(250 * time.Millisecond)
 
 	login := func() {
 		client := &http.Client{}
