Skip to content

Leftover processes after running make test#561

Merged
maelvls merged 2 commits intomasterfrom
leftover-envtest
Aug 23, 2024
Merged

Leftover processes after running make test#561
maelvls merged 2 commits intomasterfrom
leftover-envtest

Conversation

@maelvls
Copy link
Member

@maelvls maelvls commented Aug 23, 2024

Sometimes (for example when the CRD file isn't found), the test would stop immediately after envtest.Start, meaning that the t.Cleanup block wouldn't run and the two new processes would be left over after the test process would end.

Credit for identifying this bug and fixing goes to Richard Wall in (1).

maelvls and others added 2 commits August 23, 2024 11:38
Sometimes (for example when the CRD file isn't found), the test would
stop immediately after envtest.Start, meaning that the t.Cleanup block
wouldn't run and the two new processes would be left over after the test
process would end.

The credit for identifying this bug and fixing goes to Richard Wall in
[1].

[1]: #560 (comment)

Co-authored-by: Richard Wall <978965+wallrj@users.noreply.github.com>
@maelvls maelvls changed the title Leftover envtest Leftover processes after running make test Aug 23, 2024
Comment on lines +338 to +344
// If KUBEBUILDER_ASSETS isn't set, show a warning to the user.
if os.Getenv("KUBEBUILDER_ASSETS") == "" {
t.Fatalf("KUBEBUILDER_ASSETS isn't set. You can run this test using `make test`.\n" +
"But if you prefer not to use `make`, run these two commands first:\n" +
" make _bin/tools/{kube-apiserver,etcd}\n" +
" export KUBEBUILDER_ASSETS=$PWD/_bin/tools")
}
Copy link
Member Author

@maelvls maelvls Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was slightly annoyed that running go test would always end up with the unhelpful message:

unable to start control plane itself: failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory

So I added this quick fix to help whoever is running this test to sort things out.

@maelvls maelvls requested a review from wallrj August 23, 2024 10:44
Copy link
Member

@wallrj wallrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maelvls

I tried it and it worked.

$ go test ./pkg/client/...
--- FAIL: TestVenConnClient_PostDataReadingsWithOptions (0.00s)
    --- FAIL: TestVenConnClient_PostDataReadingsWithOptions/valid_accessToken (0.00s)
        client_venconn_test.go:340: KUBEBUILDER_ASSETS isn't set. You can run this test using `make test`.
            But if you prefer not to use `make`, run these two commands first:
                make _bin/tools/{kube-apiserver,etcd}
                export KUBEBUILDER_ASSETS=$PWD/_bin/tools
    --- FAIL: TestVenConnClient_PostDataReadingsWithOptions/error_when_the_apiKey_field_is_used (0.00s)
        client_venconn_test.go:340: KUBEBUILDER_ASSETS isn't set. You can run this test using `make test`.
            But if you prefer not to use `make`, run these two commands first:
                make _bin/tools/{kube-apiserver,etcd}
                export KUBEBUILDER_ASSETS=$PWD/_bin/tools
    --- FAIL: TestVenConnClient_PostDataReadingsWithOptions/error_when_the_tpp_field_is_used (0.00s)
        client_venconn_test.go:340: KUBEBUILDER_ASSETS isn't set. You can run this test using `make test`.
            But if you prefer not to use `make`, run these two commands first:
                make _bin/tools/{kube-apiserver,etcd}
                export KUBEBUILDER_ASSETS=$PWD/_bin/tools
FAIL
FAIL    github.com/jetstack/preflight/pkg/client        0.026s
FAIL

$ make _bin/tools/{kube-apiserver,etcd}
make: '_bin/tools/kube-apiserver' is up to date.
make: '_bin/tools/etcd' is up to date.

$ export KUBEBUILDER_ASSETS=$PWD/_bin/tools

$ go test ./pkg/client/...
ok      github.com/jetstack/preflight/pkg/client        18.790s

/approve
/lgtm

@maelvls maelvls merged commit 1459adf into master Aug 23, 2024
@wallrj wallrj deleted the leftover-envtest branch August 23, 2024 17:00
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

Successfully merging this pull request may close these issues.

2 participants