Skip to content

Commit

Permalink
[add] unretryableError test
Browse files Browse the repository at this point in the history
  • Loading branch information
paaaaay5 committed Mar 12, 2024
1 parent 863323d commit 071f24b
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion firequeue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,24 @@ func (te *testAWSError) Error() string {
return "retryable error"
}

type errCodeMode string

const (
retryable errCodeMode = "retryable"
unretryable errCodeMode = "unretryable"
)

var ecm = retryable

func (te *testAWSError) Code() string {
return request.ErrCodeResponseTimeout
switch ecm {
case retryable:
return request.ErrCodeResponseTimeout
case unretryable:
return request.CanceledErrorCode
default:
return ""
}
}

func (te *testAWSError) Message() string {
Expand Down Expand Up @@ -408,3 +424,27 @@ func TestStat_RetryCount(t *testing.T) {
}
t.Log(stats)
}

func TestStat_UnRetryableErrorCount(t *testing.T) {
// It means always return unretryable error.
fhErrorRate = 10
ecm = unretryable

tf := &testFirehose{}
q := firequeue.New(tf, "env", firequeue.BatchSize(1))
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

go q.Loop(ctx)
time.Sleep(1000 * time.Millisecond)
err := q.Enqueue(&firehose.Record{})
if err != nil {
t.Errorf("error should not be occurred but: %s", err)
}
time.Sleep(5 * time.Second)
stats := q.Stats()
if stats.UnretryableError == 0 {
t.Errorf("retryCount should be more than 0 but: %d", stats.RetryCount)
}
t.Log(stats)
}

0 comments on commit 071f24b

Please sign in to comment.