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

test: nil pointer in metrics test, II #984

Merged
merged 1 commit into from
Jun 9, 2021
Merged

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Jun 7, 2021

Apparently resp (?!) can be nil even when there was no error code.

Panic: runtime error: invalid memory address or nil pointer dereference
Full stack:
github.com/intel/pmem-csi/test/e2e/metrics.glob..func1.2.1()
/mnt/workspace/pmem-csi_PR-977/test/e2e/metrics/metrics.go:81 +0x7f0
github.com/onsi/gomega.InterceptGomegaFailures(0xc0052d4ab0, 0xc0014b2660, 0x0, 0xc002627800)
/mnt/workspace/gopath/pkg/mod/github.com/onsi/gomega@v1.10.5/gomega_dsl.go:107
+0xbb

metrics.go:81 now had:

 Expect(resp.Body).NotTo(BeNil(), "have response body")

Fixes: #971

@pohly
Copy link
Contributor Author

pohly commented Jun 7, 2021

This goes against what go doc net/http.Client.Get says:

    When err is nil, resp always contains a non-nil resp.Body. Caller should
    close resp.Body when done reading from it.

@pohly pohly requested a review from avalluri June 8, 2021 06:07
@pohly pohly changed the title test: nil pointer in metrics test, II WIP: test: nil pointer in metrics test, II Jun 8, 2021
The root cause has been
identified (onsi/gomega#198 (comment)),
the right fix is to check for "err == nil" because the assertion alone
is not enough in this particular scenario.
@pohly pohly changed the title WIP: test: nil pointer in metrics test, II test: nil pointer in metrics test, II Jun 8, 2021
@pohly pohly merged commit cd37f97 into intel:devel Jun 9, 2021
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.

test flake: invalid memory address in metrics test
2 participants