Skip to content

Commit

Permalink
Fix SetFeatureGateDuringTest handling of Parallel tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
serathius authored and k8s-publishing-bot committed Mar 5, 2024
1 parent 24438a9 commit a853d25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/integration/fieldselector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit a853d25

Please sign in to comment.