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

Fix: race condition in the v1 ingestor server tests #468

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version-file: "src/go.mod"
- run: go run github.com/onsi/ginkgo/ginkgo -r -race -randomizeAllSpecs -randomizeSuites
- run: go run github.com/onsi/ginkgo/ginkgo -r -race -randomizeAllSpecs -randomizeSuites -keepGoing
working-directory: src

vet:
Expand Down
12 changes: 9 additions & 3 deletions src/router/internal/server/v1/ingestor_server_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package v1_test

import (
"context"
"errors"
"io"
"net"
"time"

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

Expand Down Expand Up @@ -141,17 +141,23 @@ var _ = Describe("IngestorServer", func() {

Context("When the Recv returns an error", func() {
It("does not forward the message to the sender", func() {
ctx, cancel := context.WithCancel(context.Background())
fakeStream := newSpyIngestorGRPCServer()
fakeStream.context = ctx
fakeStream.recvError = errors.New("fake error")

errCh := make(chan error)
go func() {
err := manager.Pusher(fakeStream)
Expect(err).NotTo(HaveOccurred())
errCh <- manager.Pusher(fakeStream)
}()

Consistently(func() bool {
_, ok := v1Buf.TryNext()
return ok
}).Should(BeFalse())

cancel()
Expect(<-errCh).To(MatchError("context canceled"))
})
})

Expand Down