Hello. This is my proposal to fix the bug in stable, in debdiff format
against version 0.5.1-2, the version currently in bullseye.
Martina: Could you please take a look at it, since you were the one to
fix this in unstable?
I merely backported your patch to stable, i.e. added a Sleep call
before each block containing ListenAndServe, the only differences are
that there are only two such blocks (not three) and the file to patch
now is web/users_test.go, not web/handler_test.go.
Other than that, I've actually tested the patch on a machine where
previously failed all the time, and now it seems to work (tested several
times).
Thanks.diff -Nru golang-github-prometheus-exporter-toolkit-0.5.1/debian/changelog
golang-github-prometheus-exporter-toolkit-0.5.1/debian/changelog
--- golang-github-prometheus-exporter-toolkit-0.5.1/debian/changelog
2021-01-25 15:10:41.0 +0100
+++ golang-github-prometheus-exporter-toolkit-0.5.1/debian/changelog
2022-11-20 23:24:00.0 +0100
@@ -1,3 +1,9 @@
+golang-github-prometheus-exporter-toolkit (0.5.1-2+deb11u1) bullseye;
urgency=medium
+
+ * Patch tests to avoid race condition. Closes: #1013578.
+
+ -- Martina Ferrari Sun, 20 Nov 2022 23:24:00 +0100
+
golang-github-prometheus-exporter-toolkit (0.5.1-2) unstable; urgency=medium
* Team upload.
diff -Nru
golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/02-Avoid_race_in_test.patch
golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/02-Avoid_race_in_test.patch
---
golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/02-Avoid_race_in_test.patch
1970-01-01 01:00:00.0 +0100
+++
golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/02-Avoid_race_in_test.patch
2022-11-20 23:21:59.0 +0100
@@ -0,0 +1,31 @@
+Author: Martina Ferrari
+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 +
+
+--- 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{}
diff -Nru golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/series
golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/series
--- golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/series
1970-01-01 01:00:00.0 +0100
+++ golang-github-prometheus-exporter-toolkit-0.5.1/debian/patches/series
2022-11-20 23:21:59.0 +0100
@@ -0,0 +1 @@
+02-Avoid_race_in_test.patch