diff --git a/api/types/load_traffic.go b/api/types/load_traffic.go index eccd999..7456ad3 100644 --- a/api/types/load_traffic.go +++ b/api/types/load_traffic.go @@ -190,9 +190,9 @@ func (r WeightedRequest) Validate() error { switch { case r.StaleList != nil: - return r.StaleList.Validate() + return r.StaleList.Validate(true) case r.QuorumList != nil: - return r.QuorumList.Validate() + return r.QuorumList.Validate(false) case r.StaleGet != nil: return r.StaleGet.Validate() case r.QuorumGet != nil: @@ -207,7 +207,7 @@ func (r WeightedRequest) Validate() error { } // RequestList validates RequestList type. -func (r *RequestList) Validate() error { +func (r *RequestList) Validate(stale bool) error { if err := r.KubeGroupVersionResource.Validate(); err != nil { return fmt.Errorf("kube metadata: %v", err) } @@ -215,6 +215,10 @@ func (r *RequestList) Validate() error { if r.Limit < 0 { return fmt.Errorf("limit must >= 0") } + + if stale && r.Limit != 0 { + return fmt.Errorf("stale list doesn't support pagination option: https://github.com/kubernetes/kubernetes/issues/108003") + } return nil } diff --git a/api/types/load_traffic_test.go b/api/types/load_traffic_test.go index 1e23b47..df9eaee 100644 --- a/api/types/load_traffic_test.go +++ b/api/types/load_traffic_test.go @@ -16,6 +16,8 @@ spec: rate: 100 total: 10000 conns: 2 + client: 1 + contentType: json requests: - staleGet: group: core @@ -36,7 +38,6 @@ spec: version: v1 resource: pods namespace: default - limit: 10000 seletor: app=x2 shares: 200 - quorumList: @@ -91,7 +92,7 @@ spec: assert.Equal(t, "v1", target.Spec.Requests[2].StaleList.Version) assert.Equal(t, "core", target.Spec.Requests[0].StaleGet.Group) assert.Equal(t, "default", target.Spec.Requests[2].StaleList.Namespace) - assert.Equal(t, 10000, target.Spec.Requests[2].StaleList.Limit) + assert.Equal(t, 0, target.Spec.Requests[2].StaleList.Limit) assert.Equal(t, "app=x2", target.Spec.Requests[2].StaleList.Selector) assert.NotNil(t, target.Spec.Requests[3].QuorumList) @@ -114,6 +115,8 @@ spec: assert.Equal(t, "main", target.Spec.Requests[5].GetPodLog.Container) assert.Equal(t, int64(1000), *target.Spec.Requests[5].GetPodLog.TailLines) assert.Equal(t, int64(1024), *target.Spec.Requests[5].GetPodLog.LimitBytes) + + assert.NoError(t, target.Validate()) } func TestWeightedRequest(t *testing.T) {