Skip to content

Commit 46be128

Browse files
committed
Adjust utilfeature.SetFeatureGateDuringTest calls
Signed-off-by: Stefan Büringer [email protected]
1 parent 02cbf39 commit 46be128

File tree

20 files changed

+56
-56
lines changed

20 files changed

+56
-56
lines changed

bootstrap/kubeadm/internal/webhooks/kubeadmconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
var ctx = ctrl.SetupSignalHandler()
3434

3535
func TestKubeadmConfigDefault(t *testing.T) {
36-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
36+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
3737

3838
g := NewWithT(t)
3939

@@ -464,7 +464,7 @@ func TestKubeadmConfigValidate(t *testing.T) {
464464
if tt.enableIgnitionFeature {
465465
// NOTE: KubeadmBootstrapFormatIgnition feature flag is disabled by default.
466466
// Enabling the feature flag temporarily for this test.
467-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)()
467+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)
468468
}
469469
g := NewWithT(t)
470470

controlplane/kubeadm/internal/webhooks/kubeadm_control_plane_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestKubeadmControlPlaneValidateCreate(t *testing.T) {
268268
if tt.enableIgnitionFeature {
269269
// NOTE: KubeadmBootstrapFormatIgnition feature flag is disabled by default.
270270
// Enabling the feature flag temporarily for this test.
271-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)()
271+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)
272272
}
273273

274274
g := NewWithT(t)
@@ -1052,7 +1052,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
10521052
if tt.enableIgnitionFeature {
10531053
// NOTE: KubeadmBootstrapFormatIgnition feature flag is disabled by default.
10541054
// Enabling the feature flag temporarily for this test.
1055-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)()
1055+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.KubeadmBootstrapFormatIgnition, true)
10561056
}
10571057

10581058
g := NewWithT(t)

controlplane/kubeadm/internal/webhooks/kubeadmcontrolplanetemplate_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
func TestKubeadmControlPlaneTemplateDefault(t *testing.T) {
36-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
36+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
3737

3838
g := NewWithT(t)
3939

@@ -63,7 +63,7 @@ func TestKubeadmControlPlaneTemplateDefault(t *testing.T) {
6363
}
6464

6565
func TestKubeadmControlPlaneTemplateValidationFeatureGateEnabled(t *testing.T) {
66-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
66+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
6767

6868
t.Run("create kubeadmcontrolplanetemplate should pass if gate enabled and valid kubeadmcontrolplanetemplate", func(t *testing.T) {
6969
testnamespace := "test"

exp/runtime/internal/controllers/extensionconfig_controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ import (
4848
)
4949

5050
func TestExtensionReconciler_Reconcile(t *testing.T) {
51-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
52-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
51+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
52+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
5353

5454
g := NewWithT(t)
5555
ns, err := env.CreateNamespace(ctx, "test-extension-config")
@@ -197,8 +197,8 @@ func TestExtensionReconciler_Reconcile(t *testing.T) {
197197
}
198198

199199
func TestExtensionReconciler_discoverExtensionConfig(t *testing.T) {
200-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
201-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
200+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
201+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
202202
g := NewWithT(t)
203203
ns, err := env.CreateNamespace(ctx, "test-runtime-extension")
204204
g.Expect(err).ToNot(HaveOccurred())

exp/runtime/internal/controllers/warmup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import (
3838

3939
func Test_warmupRunnable_Start(t *testing.T) {
4040
g := NewWithT(t)
41-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
42-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
41+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
42+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
4343

4444
t.Run("succeed to warm up registry on Start", func(t *testing.T) {
4545
ns, err := env.CreateNamespace(ctx, "test-runtime-extension")

exp/topology/desiredstate/desired_state_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ func TestComputeControlPlane(t *testing.T) {
642642

643643
func TestComputeControlPlaneVersion(t *testing.T) {
644644
t.Run("Compute control plane version under various circumstances", func(t *testing.T) {
645-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
645+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
646646

647647
nonBlockingBeforeClusterUpgradeResponse := &runtimehooksv1.BeforeClusterUpgradeResponse{
648648
CommonRetryResponse: runtimehooksv1.CommonRetryResponse{
@@ -888,7 +888,7 @@ func TestComputeControlPlaneVersion(t *testing.T) {
888888
})
889889

890890
t.Run("Calling AfterControlPlaneUpgrade hook", func(t *testing.T) {
891-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
891+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
892892

893893
catalog := runtimecatalog.New()
894894
_ = runtimehooksv1.AddToCatalog(catalog)
@@ -1189,7 +1189,7 @@ func TestComputeControlPlaneVersion(t *testing.T) {
11891189
})
11901190

11911191
t.Run("register intent to call AfterClusterUpgrade and AfterControlPlaneUpgrade hooks", func(t *testing.T) {
1192-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
1192+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
11931193

11941194
catalog := runtimecatalog.New()
11951195
_ = runtimehooksv1.AddToCatalog(catalog)

internal/controllers/cluster/cluster_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ func TestClusterReconciler(t *testing.T) {
399399
}
400400

401401
func TestClusterReconciler_reconcileDelete(t *testing.T) {
402-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
403-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)()
402+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
403+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.ClusterTopology, true)
404404

405405
fakeInfraCluster := builder.InfrastructureCluster("test-ns", "test-cluster").Build()
406406

internal/controllers/clusterclass/clusterclass_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func isOwnerReferenceEqual(a, b metav1.OwnerReference) bool {
404404
}
405405

406406
func TestReconciler_reconcileVariables(t *testing.T) {
407-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)()
407+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.RuntimeSDK, true)
408408

409409
catalog := runtimecatalog.New()
410410
_ = runtimehooksv1.AddToCatalog(catalog)

internal/controllers/machineset/machineset_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ func TestMachineSetReconciler_syncMachines(t *testing.T) {
14391439

14401440
func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) {
14411441
t.Run("should delete unhealthy machines if preflight checks pass", func(t *testing.T) {
1442-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)()
1442+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)
14431443

14441444
g := NewWithT(t)
14451445

@@ -1499,7 +1499,7 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) {
14991499
})
15001500

15011501
t.Run("should update the unhealthy machine MachineOwnerRemediated condition if preflight checks did not pass", func(t *testing.T) {
1502-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)()
1502+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)
15031503

15041504
g := NewWithT(t)
15051505

@@ -1914,7 +1914,7 @@ func TestMachineSetReconciler_reconcileUnhealthyMachines(t *testing.T) {
19141914

19151915
func TestMachineSetReconciler_syncReplicas(t *testing.T) {
19161916
t.Run("should hold off on creating new machines when preflight checks do not pass", func(t *testing.T) {
1917-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)()
1917+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)
19181918

19191919
g := NewWithT(t)
19201920

internal/controllers/machineset/machineset_preflight_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestMachineSetReconciler_runPreflightChecks(t *testing.T) {
6868
Build()
6969

7070
t.Run("should run preflight checks if the feature gate is enabled", func(t *testing.T) {
71-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)()
71+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, true)
7272

7373
tests := []struct {
7474
name string
@@ -570,7 +570,7 @@ func TestMachineSetReconciler_runPreflightChecks(t *testing.T) {
570570
})
571571

572572
t.Run("should not run the preflight checks if the feature gate is disabled", func(t *testing.T) {
573-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, false)()
573+
utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.MachineSetPreflightChecks, false)
574574

575575
g := NewWithT(t)
576576
cluster := &clusterv1.Cluster{

0 commit comments

Comments
 (0)