From a853d2582b00a00a58cd149b2af06848ee62be0c Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Tue, 5 Mar 2024 21:56:40 +0100 Subject: [PATCH] Fix SetFeatureGateDuringTest handling of Parallel tests Stop using defer as parallel subtest will might result in main test finishing before subtest. Fatal when same flag is set twice. Kubernetes-commit: 9fcf279e2b91e7549190a433373f256fb5aebe85 --- test/integration/fieldselector_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/fieldselector_test.go b/test/integration/fieldselector_test.go index cd1d1458f..76e3c9050 100644 --- a/test/integration/fieldselector_test.go +++ b/test/integration/fieldselector_test.go @@ -699,13 +699,13 @@ func TestFieldSelectorDisablement(t *testing.T) { crd := selectableFieldFixture.DeepCopy() // Write a field that uses the feature while the feature gate is enabled - func() { + t.Run("CustomResourceFieldSelectors", func(t *testing.T) { defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, apiextensionsfeatures.CustomResourceFieldSelectors, true)() crd, err = fixtures.CreateNewV1CustomResourceDefinition(crd, apiExtensionClient, dynamicClient) if err != nil { t.Fatal(err) } - }() + }) // Now that the feature gate is disabled again, update the CRD to trigger an openAPI update crd, err = apiExtensionClient.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, crd.Name, metav1.GetOptions{})