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

TestFileStreamingService fails and is missed by the Github actions. #14302

Closed
SpicyLemon opened this issue Dec 14, 2022 · 2 comments · Fixed by #14305
Closed

TestFileStreamingService fails and is missed by the Github actions. #14302

SpicyLemon opened this issue Dec 14, 2022 · 2 comments · Fixed by #14305
Assignees

Comments

@SpicyLemon
Copy link
Collaborator

Summary of Bug

The TestFileStreamingService in store/streaming/file/service_test.go fails but the "Tests / Code Coverage" Github Actions do not indicate that it does.

GOROOT=/opt/homebrew/Cellar/go/1.18.3/libexec #gosetup
GOPATH=/Users/danielwedul/go #gosetup
/opt/homebrew/Cellar/go/1.18.3/libexec/bin/go test -c -o /private/var/folders/yg/my5b2q657dl8h4bfs8x8y1ch0000gp/T/GoLand/___service_test_go.test github.com/cosmos/cosmos-sdk/store/streaming/file #gosetup
/opt/homebrew/Cellar/go/1.18.3/libexec/bin/go tool test2json -t /private/var/folders/yg/my5b2q657dl8h4bfs8x8y1ch0000gp/T/GoLand/___service_test_go.test -test.v -test.paniconexit0 -test.run ^\QTestFileStreamingService\E$
=== RUN   TestFileStreamingService
--- FAIL: TestFileStreamingService (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x104ae3b78]

goroutine 21 [running]:
testing.tRunner.func1.2({0x104d853a0, 0x105413b50})
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/testing/testing.go:1389 +0x1c8
testing.tRunner.func1()
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/testing/testing.go:1392 +0x384
panic({0x104d853a0, 0x105413b50})
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/panic.go:838 +0x204
github.com/cosmos/cosmos-sdk/store/streaming/file.(*StreamingService).ListenBeginBlock(...)
	/Users/danielwedul/git/cosmos-sdk/store/streaming/file/service.go:102
github.com/cosmos/cosmos-sdk/store/streaming/file.testListenBlock(0x104e89ce8?)
	/Users/danielwedul/git/cosmos-sdk/store/streaming/file/service_test.go:177 +0x788
github.com/cosmos/cosmos-sdk/store/streaming/file.TestFileStreamingService(0x140004a8000)
	/Users/danielwedul/git/cosmos-sdk/store/streaming/file/service_test.go:132 +0x404
testing.tRunner(0x140004a8000, 0x104e80de0)
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/testing/testing.go:1439 +0x110
created by testing.(*T).Run
	/opt/homebrew/Cellar/go/1.18.3/libexec/src/testing/testing.go:1486 +0x300


Process finished with the exit code 1

The above output is from running the test in IntelliJ.

The problem is that there's a globally defined testStreamingService variable used in some helper functions for the test, but it's not being set. In the TestFileStreamingService func, there is this: testStreamingService, err := NewStreamingService(...), but because of the := there, a new variable is being created, shadowing the global one instead of setting it. So when the helper gets called and tries to use the global one, it's nil and we get that error.

Version

First noticed in v0.46.7.
Also reproducible in main at 7050eb91f2: "feat(collections): implement Iteration (#14222)".

Steps to Reproduce

Run this from the root of the repo:

$ go test -mod=readonly -timeout 30m -tags='ledger test_ledger_mock' github.com/cosmos/cosmos-sdk/store/streaming/file

It also runs if you do a make test (possibly need go clean -testcache first).

Example of it passing in a Github Action: https://github.com/cosmos/cosmos-sdk/actions/runs/3696863992/jobs/6261146822

I'm running this on an Apple M1 Pro with macOS Ventura 13.0.
I ran the test using both go 1.18.3 (e.g. in v0.46.7) and go 1.19 (e.g. in main), with the same results from both.

@SpicyLemon SpicyLemon changed the title TestFileStreamingService fails and also doesn't run in Github Actions TestFileStreamingService fails and is missed by the Github actions. Dec 14, 2022
@julienrbrt
Copy link
Member

This test contains:

	if os.Getenv("CI") != "" {
		t.Skip("Skipping TestFileStreamingService in CI environment")
	}

so it makes sense it was missed in CI. Are you up for submitting the quick fix?

@SpicyLemon
Copy link
Collaborator Author

Ah. Gotcha. Yeah. I'll PR the fix since it doesn't involve Github action changes.

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