From 3d3a73bd37632d35df56b9173fa000a40ef93ce9 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Wed, 19 Jun 2024 11:55:10 +0200 Subject: [PATCH] Fix TestWebhookConverterWithWatchCache when ResilientWatchCacheInitialization and ConsistentListFromCache are enabled --- .../test/integration/conversion/conversion_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiextensions-apiserver/test/integration/conversion/conversion_test.go b/staging/src/k8s.io/apiextensions-apiserver/test/integration/conversion/conversion_test.go index 2107cc35f34..01a15e02c48 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/test/integration/conversion/conversion_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/test/integration/conversion/conversion_test.go @@ -683,6 +683,7 @@ func expectConversionFailureMessage(id, message string) func(t *testing.T, ctc * objv1beta2 := newConversionMultiVersionFixture(ns, id, "v1beta2") meta, _, _ := unstructured.NestedFieldCopy(obj.Object, "metadata") unstructured.SetNestedField(objv1beta2.Object, meta, "metadata") + lastRV := objv1beta2.GetResourceVersion() for _, verb := range []string{"get", "list", "create", "update", "patch", "delete", "deletecollection"} { t.Run(verb, func(t *testing.T) { @@ -690,7 +691,10 @@ func expectConversionFailureMessage(id, message string) func(t *testing.T, ctc * case "get": _, err = clients["v1beta2"].Get(context.TODO(), obj.GetName(), metav1.GetOptions{}) case "list": - _, err = clients["v1beta2"].List(context.TODO(), metav1.ListOptions{}) + // With ResilientWatchcCacheInitialization feature, List requests are rejected with 429 if watchcache is not initialized. + // However, in some of these tests that install faulty converter webhook, watchcache will never initialize by definition (as list will never succeed due to faulty converter webook). + // In such case, the returned error will differ from the one returned from the etcd, so we need to force the request to go to etcd. + _, err = clients["v1beta2"].List(context.TODO(), metav1.ListOptions{ResourceVersion: lastRV, ResourceVersionMatch: metav1.ResourceVersionMatchExact}) case "create": _, err = clients["v1beta2"].Create(context.TODO(), newConversionMultiVersionFixture(ns, id, "v1beta2"), metav1.CreateOptions{}) case "update":