panic while testing for connection handling
BernhardSchmid opened this issue · comments
Hi,
I'm developing a test to verify correct connection and error handling between client and server. Direct access to the clients error object is not possible, but for test purpose it it can be retrieved by sending a fake message. For now it's a one-off and I'm not able to reproduce it on demand.
The following Ginkgo/Gomega statement caused the attached panic.
Eventually(wsClient.SendMessage(msg), (time.Second / 2), time.Millisecond*200).Should(Equal(&websocket.CloseError{websocket.CloseInternalServerErr, "failed to write to any of the redis group"}))
Go memory panic:
2021/10/29 15:23:03 exiting read loop
2021/10/29 15:23:03 Connection exiting read loop
2021/10/29 15:23:03 write close failed write tcp 127.0.0.1:50038->127.0.0.1:50037: write: broken pipe
2021/10/29 15:23:03 readhandler error: websocket: close 1011 (internal server error): failed to write to any of the redis group
•! Panic [0.003 seconds]
2021/10/29 15:23:03 exiting read loop
2021/10/29 15:23:03 Connection exiting read loop
ForwardDataToRedis
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:30
Connect
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:42
when a client sends data
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:63
when redis reports an error
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:85
the forwarder fails [It]
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:93
Test Panicked
runtime error: invalid memory address or nil pointer dereference
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:221
Full Stack Trace
github.com/onsi/gomega/internal.NewAsyncAssertion(0x0, {0x0, 0x0}, 0xc00028ef30, 0x1dcd6500, 0xbebc200, 0x0)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/gomega@v1.16.0/internal/async_assertion.go:43 +0x107
github.com/onsi/gomega/internal.(*Gomega).EventuallyWithOffset(0xc00028ef30, 0x2f88140, {0x0, 0x0}, {0xc000492040, 0x2, 0xc000692000})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/gomega@v1.16.0/internal/gomega.go:68 +0xdf
github.com/onsi/gomega/internal.(*Gomega).Eventually(0xc00038f220, {0x0, 0x0}, {0xc000492040, 0x155a060, 0xc0001fe601})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/gomega@v1.16.0/internal/gomega.go:55 +0x39
github.com/onsi/gomega.Eventually({0x0, 0x0}, {0xc000492040, 0x0, 0x0})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/gomega@v1.16.0/gomega_dsl.go:306 +0x6a
github.ibm.com/Observability/logger-ingester/pkg/ingester_test.glob..func4.2.4.3.2()
/Users/bus/fargo/logger-ingester/pkg/ingester/redis_forward_test.go:97 +0x10f
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runSync(0x17f0a34)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/leafnodes/runner.go:113 +0xba
github.com/onsi/ginkgo/internal/leafnodes.(*runner).run(0x0)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/leafnodes/runner.go:64 +0x125
github.com/onsi/ginkgo/internal/leafnodes.(*ItNode).Run(0xc0004d0b60)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/leafnodes/it_node.go:26 +0x7b
github.com/onsi/ginkgo/internal/spec.(*Spec).runSample(0xc00052a4b0, 0xc00038fa58, {0x16e44e0, 0xc0002ba700})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/spec/spec.go:215 +0x2a9
github.com/onsi/ginkgo/internal/spec.(*Spec).Run(0xc00052a4b0, {0x16e44e0, 0xc0002ba700})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/spec/spec.go:138 +0xe7
github.com/onsi/ginkgo/internal/specrunner.(*SpecRunner).runSpec(0xc0002f8160, 0xc00052a4b0)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/specrunner/spec_runner.go:200 +0xe5
github.com/onsi/ginkgo/internal/specrunner.(*SpecRunner).runSpecs(0xc0002f8160)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/specrunner/spec_runner.go:170 +0x1a5
github.com/onsi/ginkgo/internal/specrunner.(*SpecRunner).Run(0xc0002f8160)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/specrunner/spec_runner.go:66 +0xc5
github.com/onsi/ginkgo/internal/suite.(*Suite).Run(0xc000287b20, {0x2f85b68, 0xc0002ac9c0}, {0x163086b, 0x1}, {0xc000288b60, 0x1, 0x1}, {0x16f82b8, 0xc0002ba700}, ...)
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/internal/suite/suite.go:79 +0x4d2
github.com/onsi/ginkgo.runSpecsWithCustomReporters({0x16e52c0, 0xc0002ac9c0}, {0x163086b, 0xe}, {0xc0003b6720, 0x1, 0x1055c5f})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/ginkgo_dsl.go:238 +0x185
github.com/onsi/ginkgo.RunSpecs({0x16e52c0, 0xc0002ac9c0}, {0x163086b, 0xe})
/Users/bus/data/development/go/pkg/mod/github.com/onsi/ginkgo@v1.16.4/ginkgo_dsl.go:213 +0x14a
github.ibm.com/Observability/logger-ingester/pkg/ingester_test.TestIngester(0x0)
/Users/bus/fargo/logger-ingester/pkg/ingester/ingester_suite_test.go:12 +0x90
testing.tRunner(0xc0002ac9c0, 0x16584f0)
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
/usr/local/Cellar/go/1.17.2/libexec/src/testing/testing.go:1306 +0x35a
------------------------------
SSSS
Summarizing 1 Failure:
[Panic!] ForwardDataToRedis Connect when a client sends data when redis reports an error [It] the forwarder fails
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:221
Ran 1 of 10 Specs in 0.004 seconds
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 9 Skipped
--- FAIL: TestIngester (0.01s)
FAIL