Skip to content

Commit 593f1c9

Browse files
fix e2e tests using a single context object
1 parent a74b6a6 commit 593f1c9

15 files changed

+25
-47
lines changed

test/e2e/cluster_upgrade_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When upgrading a workload cluster and testing K8S conformance [Conformance] [K8s-Upgrade]", func() {
2826

29-
ClusterUpgradeConformanceSpec(context.TODO(), func() ClusterUpgradeConformanceSpecInput {
27+
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
3028
return ClusterUpgradeConformanceSpecInput{
3129
E2EConfig: e2eConfig,
3230
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/clusterctl_upgrade_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When testing clusterctl upgrades", func() {
2826

29-
ClusterctlUpgradeSpec(context.TODO(), func() ClusterctlUpgradeSpecInput {
27+
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
3028
return ClusterctlUpgradeSpecInput{
3129
E2EConfig: e2eConfig,
3230
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/e2e_suite_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
2322
"flag"
2423
"os"
2524
"path/filepath"
@@ -28,6 +27,7 @@ import (
2827

2928
. "github.com/onsi/ginkgo"
3029
. "github.com/onsi/gomega"
30+
ctrl "sigs.k8s.io/controller-runtime"
3131

3232
"k8s.io/apimachinery/pkg/runtime"
3333
"sigs.k8s.io/cluster-api/test/framework"
@@ -52,6 +52,8 @@ var (
5252

5353
// Test suite global vars
5454
var (
55+
ctx = ctrl.SetupSignalHandler()
56+
5557
// e2eConfig to be used for this test, read from configPath.
5658
e2eConfig *clusterctl.E2EConfig
5759

@@ -153,7 +155,7 @@ func initScheme() *runtime.Scheme {
153155
}
154156

155157
func loadE2EConfig(configPath string) *clusterctl.E2EConfig {
156-
config := clusterctl.LoadE2EConfig(context.TODO(), clusterctl.LoadE2EConfigInput{ConfigPath: configPath})
158+
config := clusterctl.LoadE2EConfig(ctx, clusterctl.LoadE2EConfigInput{ConfigPath: configPath})
157159
Expect(config).ToNot(BeNil(), "Failed to load E2E config from %s", configPath)
158160

159161
return config
@@ -172,7 +174,7 @@ func createClusterctlLocalRepository(config *clusterctl.E2EConfig, repositoryFol
172174

173175
createRepositoryInput.RegisterClusterResourceSetConfigMapTransformation(cniPath, CNIResources)
174176

175-
clusterctlConfig := clusterctl.CreateRepository(context.TODO(), createRepositoryInput)
177+
clusterctlConfig := clusterctl.CreateRepository(ctx, createRepositoryInput)
176178
Expect(clusterctlConfig).To(BeAnExistingFile(), "The clusterctl config file does not exists in the local repository %s", repositoryFolder)
177179
return clusterctlConfig
178180
}
@@ -181,7 +183,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
181183
var clusterProvider bootstrap.ClusterProvider
182184
kubeconfigPath := ""
183185
if !useExistingCluster {
184-
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(context.TODO(), bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
186+
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
185187
Name: config.ManagementClusterName,
186188
RequiresDockerSock: config.HasDockerProvider(),
187189
Images: config.Images,
@@ -200,7 +202,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
200202
}
201203

202204
func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig, clusterctlConfig, artifactFolder string) {
203-
clusterctl.InitManagementClusterAndWatchControllerLogs(context.TODO(), clusterctl.InitManagementClusterAndWatchControllerLogsInput{
205+
clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{
204206
ClusterProxy: bootstrapClusterProxy,
205207
ClusterctlConfigPath: clusterctlConfig,
206208
InfrastructureProviders: config.InfrastructureProviders(),
@@ -210,9 +212,9 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *
210212

211213
func tearDown(bootstrapClusterProvider bootstrap.ClusterProvider, bootstrapClusterProxy framework.ClusterProxy) {
212214
if bootstrapClusterProxy != nil {
213-
bootstrapClusterProxy.Dispose(context.TODO())
215+
bootstrapClusterProxy.Dispose(ctx)
214216
}
215217
if bootstrapClusterProvider != nil {
216-
bootstrapClusterProvider.Dispose(context.TODO())
218+
bootstrapClusterProvider.Dispose(ctx)
217219
}
218220
}

test/e2e/k8s_conformance_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When testing K8S conformance [Conformance]", func() {
2826

29-
K8SConformanceSpec(context.TODO(), func() K8SConformanceSpecInput {
27+
K8SConformanceSpec(ctx, func() K8SConformanceSpecInput {
3028
return K8SConformanceSpecInput{
3129
E2EConfig: e2eConfig,
3230
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/kcp_adoption.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInpu
123123
Cluster: cluster,
124124
}, WaitForControlPlaneIntervals...)
125125

126-
workloadCluster := input.BootstrapClusterProxy.GetWorkloadCluster(context.TODO(), cluster.Namespace, cluster.Name)
126+
workloadCluster := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name)
127127
framework.WaitForClusterMachinesReady(ctx, framework.WaitForClusterMachinesReadyInput{
128128
GetLister: input.BootstrapClusterProxy.GetClient(),
129129
NodeGetter: workloadCluster.GetClient(),

test/e2e/kcp_adoption_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523

2624
"sigs.k8s.io/cluster-api/test/framework"
2725
)
2826

2927
var _ = Describe("When testing KCP adoption", func() {
3028

31-
KCPAdoptionSpec(context.TODO(), func() KCPAdoptionSpecInput {
29+
KCPAdoptionSpec(ctx, func() KCPAdoptionSpecInput {
3230
return KCPAdoptionSpecInput{
3331
E2EConfig: e2eConfig,
3432
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/kcp_upgrade_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523

2624
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
2725
)
2826

2927
var _ = Describe("When testing KCP upgrade in a single control plane cluster", func() {
30-
KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput {
28+
KCPUpgradeSpec(ctx, func() KCPUpgradeSpecInput {
3129
return KCPUpgradeSpecInput{
3230
E2EConfig: e2eConfig,
3331
ClusterctlConfigPath: clusterctlConfigPath,
@@ -41,7 +39,7 @@ var _ = Describe("When testing KCP upgrade in a single control plane cluster", f
4139
})
4240

4341
var _ = Describe("When testing KCP upgrade in a HA cluster", func() {
44-
KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput {
42+
KCPUpgradeSpec(ctx, func() KCPUpgradeSpecInput {
4543
return KCPUpgradeSpecInput{
4644
E2EConfig: e2eConfig,
4745
ClusterctlConfigPath: clusterctlConfigPath,
@@ -55,7 +53,7 @@ var _ = Describe("When testing KCP upgrade in a HA cluster", func() {
5553
})
5654

5755
var _ = Describe("When testing KCP upgrade in a HA cluster using scale in rollout", func() {
58-
KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput {
56+
KCPUpgradeSpec(ctx, func() KCPUpgradeSpecInput {
5957
return KCPUpgradeSpecInput{
6058
E2EConfig: e2eConfig,
6159
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/machine_pool_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When testing MachinePools", func() {
28-
MachinePoolSpec(context.TODO(), func() MachinePoolInput {
26+
MachinePoolSpec(ctx, func() MachinePoolInput {
2927
return MachinePoolInput{
3028
E2EConfig: e2eConfig,
3129
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/md_scale_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When testing MachineDeployment scale out/in", func() {
2826

29-
MachineDeploymentScaleSpec(context.TODO(), func() MachineDeploymentScaleSpecInput {
27+
MachineDeploymentScaleSpec(ctx, func() MachineDeploymentScaleSpecInput {
3028
return MachineDeploymentScaleSpecInput{
3129
E2EConfig: e2eConfig,
3230
ClusterctlConfigPath: clusterctlConfigPath,

test/e2e/md_upgrades_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ limitations under the License.
1919
package e2e
2020

2121
import (
22-
"context"
23-
2422
. "github.com/onsi/ginkgo"
2523
)
2624

2725
var _ = Describe("When testing MachineDeployment upgrades", func() {
2826

29-
MachineDeploymentUpgradesSpec(context.TODO(), func() MachineDeploymentUpgradesSpecInput {
27+
MachineDeploymentUpgradesSpec(ctx, func() MachineDeploymentUpgradesSpecInput {
3028
return MachineDeploymentUpgradesSpecInput{
3129
E2EConfig: e2eConfig,
3230
ClusterctlConfigPath: clusterctlConfigPath,

0 commit comments

Comments
 (0)