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

Flaky test in github.com/prometheus/prometheus/discovery/file.go #3419

Closed
elifkus opened this issue Nov 7, 2017 · 4 comments
Closed

Flaky test in github.com/prometheus/prometheus/discovery/file.go #3419

elifkus opened this issue Nov 7, 2017 · 4 comments

Comments

@elifkus
Copy link
Contributor

elifkus commented Nov 7, 2017

I ran make test and the tests for file service discovery failed. But sometimes they don't.

--- FAIL: TestFileSD (0.03s)
file_test.go:105: Unexpected target groups [], we expected a failure here.

I looked into it and found out what makes the tests fail. But I'm not able to fix it (as I'm new to the codebase and to the language) so I'm writing here in the hope someone who knows better might help out. I'll continue in the comments.

System information: MacOs 10.13.1
Darwin 17.2.0 x86_64
Prometheus version:
prometheus, version 2.0.0-rc.3 (branch: master, revision: 09be10a)
build user: mine@my-MacBook.local
build date: 20171107-08:54:35
go version: go1.8

@elifkus elifkus changed the title Flaky test in ithub.com/prometheus/prometheus/discovery/file.go Flaky test in github.com/prometheus/prometheus/discovery/file.go Nov 7, 2017
@elifkus
Copy link
Contributor Author

elifkus commented Nov 7, 2017

The test that fails is testFileSD(t, "invalid_nil", ".yml", false)

I found out that the test fails when the content of fixtures/_test_invalid_nil.yml is empty instead of

  • targets: ['localhost:9090', 'example.org:443']
    labels:
    foo: bar

  • null

I guess that's because sometimes the content is read before the content is written over to the file (which is done in the test testFileSD).

Probably

go fsd.Run(ctx, ch)

at line 53 starts the read before line 74 writes the file content to fixtures/_test_invalid_nil.yml

_, err = io.Copy(newf, f)

When I put a 100ms sleep just before line 74, the test always fails.

@grobie grobie added the kind/bug label Nov 8, 2017
@grobie
Copy link
Member

grobie commented Nov 8, 2017

Thanks for the report @elifkus! I guess we need some goroutine synchronization here. @krasi-georgiev you were looking into our sd tests already, right?

@krasi-georgiev
Copy link
Contributor

@grobie no I haven't, but It happens almost every time on my local tests and quite annoyed by these so will get it fixed.

@elifkus thanks for the pointers.

@lock
Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants