Skip to content

Commit

Permalink
fix uint test
Browse files Browse the repository at this point in the history
  • Loading branch information
whalecold committed Aug 26, 2024
1 parent 3c15ab7 commit 05021b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xdssuite/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sync/atomic"

"github.com/cloudwego/kitex/client"
"github.com/cloudwego/kitex/pkg/klog"
"github.com/cloudwego/kitex/pkg/retry"
"github.com/cloudwego/kitex/pkg/rpcinfo"

Expand Down Expand Up @@ -98,6 +99,7 @@ func updateRetryPolicy(rc *retrySuit, res map[string]xdsresource.Resource) {
}

if wildcarRetryPolicy == nil {
klog.Debugf("[XDS] retry policy is empty, disable it, res number %v", len(res))
wildcarRetryPolicy = &retry.Policy{
Enable: false,
}
Expand Down
39 changes: 39 additions & 0 deletions xdssuite/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func TestRetry(t *testing.T) {
r := &retrySuit{
Container: retry.NewRetryContainer(),
}
updateRetryPolicy(r, map[string]xdsresource.Resource{})

assert.Equal(t, newContainer(map[string]retry.Policy{
wildcardRetryKey: {
Enable: false,
},
}), dump(r.Dump()))

updateRetryPolicy(r, map[string]xdsresource.Resource{
"1": &xdsresource.RouteConfigResource{
Expand Down Expand Up @@ -148,6 +155,24 @@ func TestRetry(t *testing.T) {
},
},
},
wildcardRetryKey: {
Enable: true,
Type: retry.FailureType,
FailurePolicy: &retry.FailurePolicy{
RetrySameNode: false,
StopPolicy: retry.StopPolicy{
MaxRetryTimes: 3,
MaxDurationMS: 1000,
},
BackOffPolicy: &retry.BackOffPolicy{
BackOffType: retry.RandomBackOffType,
CfgItems: map[retry.BackOffCfgKey]float64{
retry.MaxMSBackOffCfgKey: 2000,
retry.MinMSBackOffCfgKey: 1000,
},
},
},
},
}), dump(r.Dump()))

updateRetryPolicy(r, map[string]xdsresource.Resource{
Expand Down Expand Up @@ -189,5 +214,19 @@ func TestRetry(t *testing.T) {
},
},
},
wildcardRetryKey: {
Enable: true,
Type: retry.FailureType,
FailurePolicy: &retry.FailurePolicy{
RetrySameNode: false,
StopPolicy: retry.StopPolicy{
MaxRetryTimes: 2,
MaxDurationMS: 5000,
},
BackOffPolicy: &retry.BackOffPolicy{
BackOffType: retry.NoneBackOffType,
},
},
},
}), dump(r.Dump()))
}

0 comments on commit 05021b6

Please sign in to comment.