@@ -29,7 +29,7 @@ import (
2929
3030 admissionv1 "k8s.io/api/admission/v1"
3131 admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
32- "k8s.io/apimachinery/pkg/api/errors"
32+ apierrors "k8s.io/apimachinery/pkg/api/errors"
3333 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434 "k8s.io/apimachinery/pkg/runtime"
3535 "k8s.io/apimachinery/pkg/runtime/schema"
@@ -197,14 +197,13 @@ func TestAPIBindingMutatingWebhook(t *testing.T) {
197197
198198 // Avoid race condition here by making sure that CRD is served after installing the types into logical clusters
199199 t .Logf ("Creating cowboy resource in target logical cluster" )
200- require .Eventually (t , func () bool {
201- _ , err = cowbyClusterClient .Cluster (targetPath ).WildwestV1alpha1 ().Cowboys ("default" ).Create (ctx , & cowboy , metav1.CreateOptions {})
202- t .Log (err )
203- if err != nil && ! errors .IsAlreadyExists (err ) {
204- return false
200+ kcptestinghelpers .Eventually (t , func () (bool , string ) {
201+ _ , err := cowbyClusterClient .Cluster (targetPath ).WildwestV1alpha1 ().Cowboys ("default" ).Create (ctx , & cowboy , metav1.CreateOptions {})
202+ if err != nil && ! apierrors .IsAlreadyExists (err ) {
203+ return false , err .Error ()
205204 }
206- return testWebhooks [sourcePath ].Calls () >= 1
207- }, wait .ForeverTestTimeout , 100 * time .Millisecond )
205+ return testWebhooks [sourcePath ].Calls () >= 1 , ""
206+ }, wait .ForeverTestTimeout , 100 * time .Millisecond , "failed to create cowboy resource" )
208207
209208 t .Logf ("Check that the in-workspace webhook was NOT called" )
210209 require .Zero (t , testWebhooks [targetPath ].Calls (), "in-workspace webhook should not have been called" )
0 commit comments