mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
Improve WatchList test robustness
The WatchList test “[sig-api-machinery] API Streaming (aka. WatchList) [FeatureGate:WatchList] [Beta] should be requested by metadatainformer when WatchListClient is enabled” works by fetching an expected (initial) state of secrets, starting an informer, and polling until context timeout for the informer to converge to the expected state. If any secret in the namespace changes while the test is running, they never converge, and the test times out. This change limits the secrets we’re listing to just the ones relevant to the test.
This commit is contained in:
parent
b75d1f6dca
commit
b5c6d68a6d
1 changed files with 5 additions and 3 deletions
|
|
@ -103,11 +103,13 @@ var _ = SIGDescribe("API Streaming (aka. WatchList)", framework.WithFeatureGate(
|
|||
f.Namespace.Name,
|
||||
time.Duration(0),
|
||||
nil,
|
||||
nil,
|
||||
func(options *metav1.ListOptions) {
|
||||
options.LabelSelector = "watchlist=true"
|
||||
},
|
||||
)
|
||||
|
||||
_ = addWellKnownSecrets(ctx, f)
|
||||
expectedSecrets, err := metadataClient.Resource(v1.SchemeGroupVersion.WithResource("secrets")).Namespace(f.Namespace.Name).List(ctx, metav1.ListOptions{})
|
||||
expectedSecrets, err := metadataClient.Resource(v1.SchemeGroupVersion.WithResource("secrets")).Namespace(f.Namespace.Name).List(ctx, metav1.ListOptions{LabelSelector: "watchlist=true"})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("Starting the secret meta informer")
|
||||
|
|
@ -131,7 +133,7 @@ var _ = SIGDescribe("API Streaming (aka. WatchList)", framework.WithFeatureGate(
|
|||
_, err = f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Update(ctx, secret, metav1.UpdateOptions{})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
expectedSecrets, err = metadataClient.Resource(v1.SchemeGroupVersion.WithResource("secrets")).Namespace(f.Namespace.Name).List(ctx, metav1.ListOptions{})
|
||||
expectedSecrets, err = metadataClient.Resource(v1.SchemeGroupVersion.WithResource("secrets")).Namespace(f.Namespace.Name).List(ctx, metav1.ListOptions{LabelSelector: "watchlist=true"})
|
||||
framework.ExpectNoError(err)
|
||||
verifyStoreFor(ctx, verifyPartialObjectMetadataStore(toPointerSlice(expectedSecrets.Items), secretMetaInformer.Informer().GetStore()))
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue