Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestRegisteringHookMultipleTimesShouldBeSafe failure on CPU-constrained systems #22

Open
gibmat opened this issue Oct 29, 2023 · 0 comments

Comments

@gibmat
Copy link

gibmat commented Oct 29, 2023

It was reported in a Debian bug that TestRegisteringHookMultipleTimesShouldBeSafe fails when the tests are run on a system with only one or two CPUs, or alternatively on non-amd64 architectures with slower CPUs. The test failure output is at the end of this issue.

The cause appears to be that the metrics server started as a goroutine in httpServePrometheusMetrics() isn't fully ready to serve requests by the time the test code attempts to make a request. As a work around for the time being, I've introduced a quarter second sleep before returning from httpServePrometheusMetrics() (which is probably overkill) that fixes this test failure.

=== RUN   TestRegisteringHookMultipleTimesShouldBeSafe
    promrus_test.go:103: 
        	Error Trace:	/build/golang-github-weaveworks-promrus-1.2.0+git20210208.77c195c/_build/src/github.com/weaveworks/promrus/promrus_test.go:103
        	            				/build/golang-github-weaveworks-promrus-1.2.0+git20210208.77c195c/_build/src/github.com/weaveworks/promrus/promrus_test.go:29
        	Error:      	Expected nil, but got: &url.Error{Op:"Get", URL:"http://localhost:8080/metrics", Err:(*net.OpError)(0xc000025360)}
        	Test:       	TestRegisteringHookMultipleTimesShouldBeSafe
--- FAIL: TestRegisteringHookMultipleTimesShouldBeSafe (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x8acf6a]

goroutine 8 [running]:
testing.tRunner.func1.2({0x9157c0, 0xdaaef0})
	/usr/lib/go-1.21/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
	/usr/lib/go-1.21/src/testing/testing.go:1548 +0x397
panic({0x9157c0?, 0xdaaef0?})
	/usr/lib/go-1.21/src/runtime/panic.go:914 +0x21f
github.com/weaveworks/promrus_test.httpGetMetrics(0x27?)
	/build/golang-github-weaveworks-promrus-1.2.0+git20210208.77c195c/_build/src/github.com/weaveworks/promrus/promrus_test.go:104 +0xca
github.com/weaveworks/promrus_test.TestRegisteringHookMultipleTimesShouldBeSafe(0x0?)
	/build/golang-github-weaveworks-promrus-1.2.0+git20210208.77c195c/_build/src/github.com/weaveworks/promrus/promrus_test.go:29 +0x98
testing.tRunner(0xc000106ea0, 0x9eb450)
	/usr/lib/go-1.21/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 1
	/usr/lib/go-1.21/src/testing/testing.go:1648 +0x3ad
FAIL	github.com/weaveworks/promrus	0.023s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant