Resolve race condition in test
We now use a stub receiver which always returns envelopes and no error to
guarantee we have a deterministic test.
@@ -227,7 +227,7 @@ var _ = Describe("Server", func() {
It("errors when the sender cannot send the envelope", func() {
receiverServer := &spyBatchedReceiverServer{err: errors.New("Oh No!")}
server := egress.NewServer(
- newSpyReceiver(10000),
+ &stubReceiver{},
testhelper.NewMetricClient(),
newSpyHealthRegistrar(),
context.TODO(),
@@ -465,6 +465,15 @@ func (s *spyReceiver) Receive(ctx context.Context, req *v2.EgressRequest) (func(
}, nil
}
+type stubReceiver struct{}
+
+func (s *stubReceiver) Receive(ctx context.Context, req *v2.EgressRequest) (func() (*v2.Envelope, error), error) {
+ rx := func() (*v2.Envelope, error) {
+ return &v2.Envelope{}, nil
+ }
+ return rx, nil
+}
+
func (s *spyReceiver) stop() {
close(s.stopCh)
}
