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

Add well-known reply timeout error #234

Merged
merged 2 commits into from
Sep 12, 2024
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 core/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last
"expSeqNum": expSeqNum,
"channel": ch.id,
}).Debugf("timeout (%v) waiting for reply: %s", timeout, msg.GetMessageName())
err = fmt.Errorf("no reply received within the timeout period %s", timeout)
err = fmt.Errorf("%w %s", ErrReplyTimeout, timeout)
return false, err
}
}
Expand Down
3 changes: 3 additions & 0 deletions core/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package core_test

import (
"errors"
"fmt"
"math"
"testing"
Expand Down Expand Up @@ -341,6 +342,7 @@ func TestSimpleRequestWithTimeout(t *testing.T) {
err := reqCtx1.ReceiveReply(reply)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(HavePrefix("no reply received within the timeout period"))
Expect(errors.Is(err, core.ErrReplyTimeout)).To(Equal(true))

ctx.mockVpp.MockReplyWithContext(
// reply for the previous request
Expand Down Expand Up @@ -492,6 +494,7 @@ func TestRequestsOrdering(t *testing.T) {
err = reqCtx1.ReceiveReply(reply1)
Expect(err).ToNot(BeNil())
Expect(err.Error()).To(HavePrefix("no reply received within the timeout period"))
Expect(errors.Is(err, core.ErrReplyTimeout)).To(Equal(true))
}

func TestCycleOverSetOfSequenceNumbers(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions core/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var ReplyChannelTimeout = time.Millisecond * 100
var (
ErrNotConnected = errors.New("not connected to VPP, ignoring the request")
ErrProbeTimeout = errors.New("probe reply not received within timeout period")
ErrReplyTimeout = errors.New("no reply received within the timeout period")
)

// watchRequests watches for requests on the request API channel and forwards them as messages to VPP.
Expand Down
2 changes: 1 addition & 1 deletion core/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *Stream) recvReply() (*vppReply, error) {
}
return reply, nil
case <-timeoutTimer.C:
err := fmt.Errorf("no reply received within the timeout period %s", timeout)
err := fmt.Errorf("%w %s", ErrReplyTimeout, timeout)
return nil, err
case <-s.ctx.Done():
return nil, s.ctx.Err()
Expand Down
2 changes: 2 additions & 0 deletions core/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"context"
"errors"
"testing"
"time"

Expand Down Expand Up @@ -60,4 +61,5 @@ func TestStreamReply(t *testing.T) {
_, err = ctx.stream.RecvMsg()
Expect(err).Should(HaveOccurred())
Expect(err.Error()).To(HavePrefix("no reply received within the timeout period"))
Expect(errors.Is(err, ErrReplyTimeout)).To(Equal(true))
}
Loading