Skip to content

Commit

Permalink
fix race
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <dug@microsoft.com>
  • Loading branch information
Doug Davis committed Oct 23, 2023
1 parent 6f5984b commit 7c1a3b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/integration/kafka_sarama_binding/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func testSenderReceiver(t testing.TB) (func(), bindings.Sender, bindings.Receive

// Not perfect but we need to give OpenInbound() as chance to start
// as it's a race condition. I couldn't find something on 'p' to wait for
time.Sleep(5 * time.Second)
time.Sleep(15 * time.Second)

return func() {
require.NoError(t, p.Close(context.TODO()))
Expand Down
7 changes: 7 additions & 0 deletions v2/client/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"sync"
"testing"
"time"

"github.com/cloudevents/sdk-go/v2/protocol"

Expand All @@ -29,6 +30,9 @@ func SendReceive(t *testing.T, protocolFactory func() interface{}, in event.Even
wg := sync.WaitGroup{}
wg.Add(2)

// Give time for Kafka client protocol to get setup
time.Sleep(5 * time.Second)

go func() {
ctx, cancel := context.WithCancel(context.TODO())
inCh := make(chan event.Event)
Expand All @@ -49,6 +53,9 @@ func SendReceive(t *testing.T, protocolFactory func() interface{}, in event.Even
outAssert(e)
}()

// Give time for the receiever to start
time.Sleep(5 * time.Second)

go func() {
defer wg.Done()
err := c.Send(context.Background(), in)
Expand Down

0 comments on commit 7c1a3b1

Please sign in to comment.