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

TestProcesses failing on CI for darwin #148

Closed
AndersonQ opened this issue Jan 24, 2023 · 3 comments · Fixed by #150
Closed

TestProcesses failing on CI for darwin #148

AndersonQ opened this issue Jan 24, 2023 · 3 comments · Fixed by #150
Labels
flaky-test Unstable or unreliable test cases.

Comments

@AndersonQ
Copy link
Member

The TestProcesses is constantly failing on CI at least for #144, but it seems to be happening on other PRs as well, even though it passes locally.

I don´t have a mac to investigate it further, I just got someone else to try it and as I said, itś working locally.

[2023-01-23T13:49:10.877Z] === RUN   TestProcesses

[2023-01-23T13:49:10.877Z]     process_darwin_test.go:115: empty exec

[2023-01-23T13:49:10.877Z] --- FAIL: TestProcesses (0.00s)

[2023-01-23T13:49:10.877Z] FAIL

[2023-01-23T13:49:10.877Z] FAIL	github.com/elastic/go-sysinfo/providers/darwin	0.671s
@andrewkroh
Copy link
Member

This test looks non-deterministic in that it lists all processes and assumes the first one has an executable associated to it. If macos is like Linux and Windows, then this is not always true for special kernel processes.

func TestProcesses(t *testing.T) {
var s darwinSystem
ps, err := s.Processes()
if err != nil {
t.Fatal(err)
}
pinfo, err := ps[0].Info()
if err != nil {
t.Fatal(err)
}

@andrewkroh andrewkroh added the flaky-test Unstable or unreliable test cases. label Jan 24, 2023
@andrewkroh andrewkroh changed the title TestProcesses failig on CI for darwin TestProcesses failing on CI for darwin Jan 24, 2023
@andrewkroh
Copy link
Member

I think we should update the test's error message to include the full process details so we can see what process is causing this.

andrewkroh added a commit to andrewkroh/go-sysinfo that referenced this issue Jan 25, 2023
kern_procargs was not returning an error when kern.procargs2 failed.
Then meant that you didn't get an error when the process no longer exists
or when you didn't have permissions to access the process.

For process.Info(), this especially affected builds running without CGO enabled.
When running with CGO there are other calls that will fail with "no such process"
or "operation not permitted" before we get to calling kern.procargs2, but without
CGO it goes directly to calling kern.procargs2. This resulted in Info() returning
a zero value types.ProcessInfo and no error.

Fixes elastic#148
@andrewkroh
Copy link
Member

I opened a PR to address this at #150.

andrewkroh added a commit that referenced this issue Jan 26, 2023
* providers/darwin/process: fix error handling

kern_procargs was not returning an error when kern.procargs2 failed.
Then meant that you didn't get an error when the process no longer exists
or when you didn't have permissions to access the process.

For process.Info(), this especially affected builds running without CGO enabled.
When running with CGO there are other calls that will fail with "no such process"
or "operation not permitted" before we get to calling kern.procargs2, but without
CGO it goes directly to calling kern.procargs2. This resulted in Info() returning
a zero value types.ProcessInfo and no error.

Fixes #148

* system_test.go: Ignore EINVAL for process.Info()

Non-CGO build will return EINVAL when a process does not exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky-test Unstable or unreliable test cases.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants