-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testutil/prometheus: fix start/stop race (#6854)
* testutil/prometheus: fix start/stop race Fix the following race between start and stop: ``` WARNING: DATA RACE Read at 0x00c0001940a0 by goroutine 35: github.com/thanos-io/thanos/pkg/testutil/e2eutil.(*Prometheus).Stop() /home/giedrius/dev/thanos/pkg/testutil/e2eutil/prometheus.go:298 +0x94 github.com/thanos-io/thanos/pkg/metadata.TestPrometheus_Metadata_e2e.func1() /home/giedrius/dev/thanos/pkg/metadata/prometheus_test.go:32 +0x33 runtime.deferreturn() /usr/lib/go-1.21/src/runtime/panic.go:477 +0x30 testing.tRunner() /usr/lib/go-1.21/src/testing/testing.go:1595 +0x238 testing.(*T).Run.func1() /usr/lib/go-1.21/src/testing/testing.go:1648 +0x44 Previous write at 0x00c0001940a0 by goroutine 73: os/exec.(*Cmd).Start() /usr/lib/go-1.21/src/os/exec/exec.go:693 +0x977 os/exec.(*Cmd).Run() /usr/lib/go-1.21/src/os/exec/exec.go:587 +0x26 os/exec.(*Cmd).CombinedOutput() /usr/lib/go-1.21/src/os/exec/exec.go:1005 +0x1f6 github.com/thanos-io/thanos/pkg/testutil/e2eutil.(*Prometheus).start.func1() /home/giedrius/dev/thanos/pkg/testutil/e2eutil/prometheus.go:226 +0x52 ``` While fixing this I have also noticed some pretty bad code like hardcoding durations in random time.Sleep. Also, some Start() calls were without waiting for Prometheus to be up. Calling start but without waiting for Prometheus to be up doesn't make much sense so I have taken the liberty to refactor this place. Also, this should make tests faster because we won't have random sleeps too. Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com> * e2eutil: pass prefix too Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com> --------- Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
- Loading branch information
Showing
8 changed files
with
80 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters