pubsub: fix TestAckDistribution
cancels dont get retried anymore, causing Receive to return a
Canceled status code. The test should ignore such codes.
Fixes
@@ -28,6 +28,8 @@ import (
"golang.org/x/net/context"
"google.golang.org/api/option"
"google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
)
var (
@@ -108,7 +110,7 @@ func TestAckDistribution(t *testing.T) {
startSending(t, queuedMsgs, &processTimeSecs, testcase.initialProcessSecs, testcase.finalProcessSecs, recvdWg)
recvdWg.Wait()
- time.Sleep(time.Second) // Wait a bit more for resources to clean up
+ time.Sleep(100 * time.Millisecond) // Wait a bit more for resources to clean up
err = client.Close()
if err != nil {
t.Fatal(err)
@@ -182,9 +184,11 @@ func startReceiving(t *testing.T, ctx context.Context, s *Subscription, recvdWg
}
})
if err != nil {
+ if status.Code(err) != codes.Canceled {
t.Fatal(err)
}
}
+}
// startSending sends four batches of messages broken up by minDeadline, initialProcessSecs, and finalProcessSecs.
func startSending(t *testing.T, queuedMsgs chan int32, processTimeSecs *int32, initialProcessSecs int32, finalProcessSecs int32, recvdWg *sync.WaitGroup) {
