Merge pull request #92713 from liggitt/deflake-list-rv-0

Deflake TestListResourceVersion0
This commit is contained in:
Kubernetes Prow Robot 2020-07-02 04:18:07 -07:00 committed by GitHub
commit 3f585835d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -54,6 +54,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/serializer/streaming:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",

View File

@ -49,6 +49,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer/protobuf"
"k8s.io/apimachinery/pkg/runtime/serializer/streaming"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature"
@ -548,6 +549,20 @@ func TestListResourceVersion0(t *testing.T) {
}
}
if tc.watchCacheEnabled {
// poll until the watch cache has the full list in memory
err := wait.PollImmediate(time.Second, wait.ForeverTestTimeout, func() (bool, error) {
list, err := clientSet.AppsV1().ReplicaSets(ns.Name).List(context.Background(), metav1.ListOptions{ResourceVersion: "0"})
if err != nil {
return false, err
}
return len(list.Items) == 10, nil
})
if err != nil {
t.Fatalf("error waiting for watch cache to observe the full list: %v", err)
}
}
pagerFn := func(opts metav1.ListOptions) (runtime.Object, error) {
return rsClient.List(context.TODO(), opts)
}