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

[receiver/hostmetricsreceiver] Test failure in internal/scraper/processscraper #36468

Open
jade-guiton-dd opened this issue Nov 20, 2024 · 3 comments

Comments

@jade-guiton-dd
Copy link
Contributor

jade-guiton-dd commented Nov 20, 2024

Component(s)

receiver/hostmetrics

What happened?

Description

When running the tests for receiver/hostmetricsreceiver locally, I consistently get a failure in receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go on lines 179 and 180:

internal.AssertContainsAttribute(t, attr, conventions.AttributeProcessCommand)
internal.AssertContainsAttribute(t, attr, conventions.AttributeProcessCommandLine)

I suspect this may be an OS-dependent issue.

Steps to Reproduce

Run go test in receiver/hostmetricsreceiver.

Expected Result

Tests pass.

Actual Result

Tests fail.

Collector version

Latest main (75ceb55)

Environment information

Environment

OS: macOS Sonoma 14.7.1 (on M3 hardware)
Compiler: go 1.22.9

Log output

The following output is repeated many times:

Error:          Should be true
Test:           TestScrape/Enable_memory_utilization
testutils.go:17: 
Error Trace:    [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/testutils.go:17
                [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go:179
                [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go:128
Error:          Should be true
Test:           TestScrape/Enable_memory_utilization
testutils.go:17: 
Error Trace:    [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/testutils.go:17
                [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go:180
                [...]/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go:128
Error:          Should be true
Test:           TestScrape/Enable_memory_utilization

=== FAIL: internal/scraper/processscraper TestScrape (re-run 1) (0.25s)
@jade-guiton-dd jade-guiton-dd added bug Something isn't working needs triage New item requiring triage labels Nov 20, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@VihasMakwana
Copy link
Contributor

VihasMakwana commented Nov 22, 2024

@jade-guiton-dd can you run the tests as sudo and see if they work?
They're failing if you run with a "normal" user, most probably due to insufficient permissions.

EDIT: Tried the same on my Mac and the tests work with sudo

@VihasMakwana VihasMakwana added waiting for author and removed needs triage New item requiring triage labels Nov 22, 2024
@jade-guiton-dd
Copy link
Contributor Author

jade-guiton-dd commented Nov 22, 2024

@VihasMakwana You're right, running the tests as root works.

Is this expected behavior? If yes, it may be nice to document it (if it isn't already), and/or change test expectations depending on the current user, since I doubt most devs would run local tests as root by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants