Skip to content

Commit

Permalink
fix e2e tests using a single context object
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed May 31, 2021
1 parent a74b6a6 commit 8e5241c
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 46 deletions.
4 changes: 1 addition & 3 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

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

ClusterUpgradeConformanceSpec(context.TODO(), func() ClusterUpgradeConformanceSpecInput {
ClusterUpgradeConformanceSpec(ctx, func() ClusterUpgradeConformanceSpecInput {
return ClusterUpgradeConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

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

ClusterctlUpgradeSpec(context.TODO(), func() ClusterctlUpgradeSpecInput {
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var (

// Test suite global vars
var (
ctx = context.Background()

// e2eConfig to be used for this test, read from configPath.
e2eConfig *clusterctl.E2EConfig

Expand Down Expand Up @@ -153,7 +155,7 @@ func initScheme() *runtime.Scheme {
}

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

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

createRepositoryInput.RegisterClusterResourceSetConfigMapTransformation(cniPath, CNIResources)

clusterctlConfig := clusterctl.CreateRepository(context.TODO(), createRepositoryInput)
clusterctlConfig := clusterctl.CreateRepository(ctx, createRepositoryInput)
Expect(clusterctlConfig).To(BeAnExistingFile(), "The clusterctl config file does not exists in the local repository %s", repositoryFolder)
return clusterctlConfig
}
Expand All @@ -181,7 +183,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
var clusterProvider bootstrap.ClusterProvider
kubeconfigPath := ""
if !useExistingCluster {
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(context.TODO(), bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
clusterProvider = bootstrap.CreateKindBootstrapClusterAndLoadImages(ctx, bootstrap.CreateKindBootstrapClusterAndLoadImagesInput{
Name: config.ManagementClusterName,
RequiresDockerSock: config.HasDockerProvider(),
Images: config.Images,
Expand All @@ -200,7 +202,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
}

func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig, clusterctlConfig, artifactFolder string) {
clusterctl.InitManagementClusterAndWatchControllerLogs(context.TODO(), clusterctl.InitManagementClusterAndWatchControllerLogsInput{
clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{
ClusterProxy: bootstrapClusterProxy,
ClusterctlConfigPath: clusterctlConfig,
InfrastructureProviders: config.InfrastructureProviders(),
Expand All @@ -210,9 +212,9 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config *

func tearDown(bootstrapClusterProvider bootstrap.ClusterProvider, bootstrapClusterProxy framework.ClusterProxy) {
if bootstrapClusterProxy != nil {
bootstrapClusterProxy.Dispose(context.TODO())
bootstrapClusterProxy.Dispose(ctx)
}
if bootstrapClusterProvider != nil {
bootstrapClusterProvider.Dispose(context.TODO())
bootstrapClusterProvider.Dispose(ctx)
}
}
4 changes: 1 addition & 3 deletions test/e2e/k8s_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

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

K8SConformanceSpec(context.TODO(), func() K8SConformanceSpecInput {
K8SConformanceSpec(ctx, func() K8SConformanceSpecInput {
return K8SConformanceSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/kcp_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInpu
Cluster: cluster,
}, WaitForControlPlaneIntervals...)

workloadCluster := input.BootstrapClusterProxy.GetWorkloadCluster(context.TODO(), cluster.Namespace, cluster.Name)
workloadCluster := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name)
framework.WaitForClusterMachinesReady(ctx, framework.WaitForClusterMachinesReadyInput{
GetLister: input.BootstrapClusterProxy.GetClient(),
NodeGetter: workloadCluster.GetClient(),
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/kcp_adoption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"

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

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

KCPAdoptionSpec(context.TODO(), func() KCPAdoptionSpecInput {
KCPAdoptionSpec(ctx, func() KCPAdoptionSpecInput {
return KCPAdoptionSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/kcp_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"

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

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

var _ = Describe("When testing KCP upgrade in a HA cluster", func() {
KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput {
KCPUpgradeSpec(ctx, func() KCPUpgradeSpecInput {
return KCPUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand All @@ -55,7 +53,7 @@ var _ = Describe("When testing KCP upgrade in a HA cluster", func() {
})

var _ = Describe("When testing KCP upgrade in a HA cluster using scale in rollout", func() {
KCPUpgradeSpec(context.TODO(), func() KCPUpgradeSpecInput {
KCPUpgradeSpec(ctx, func() KCPUpgradeSpecInput {
return KCPUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/machine_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

var _ = Describe("When testing MachinePools", func() {
MachinePoolSpec(context.TODO(), func() MachinePoolInput {
MachinePoolSpec(ctx, func() MachinePoolInput {
return MachinePoolInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/md_scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

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

MachineDeploymentScaleSpec(context.TODO(), func() MachineDeploymentScaleSpecInput {
MachineDeploymentScaleSpec(ctx, func() MachineDeploymentScaleSpecInput {
return MachineDeploymentScaleSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/md_upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

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

MachineDeploymentUpgradesSpec(context.TODO(), func() MachineDeploymentUpgradesSpecInput {
MachineDeploymentUpgradesSpec(ctx, func() MachineDeploymentUpgradesSpecInput {
return MachineDeploymentUpgradesSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/mhc_remediations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

var _ = Describe("When testing unhealthy machines remediation", func() {

MachineRemediationSpec(context.TODO(), func() MachineRemediationSpecInput {
MachineRemediationSpec(ctx, func() MachineRemediationSpecInput {
return MachineRemediationSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/node_drain_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeo
Expect(machineDeployments[0].Spec.Replicas).To(Equal(pointer.Int32Ptr(1)))

By("Add a deployment with unevictable pods and podDisruptionBudget to the workload cluster. The deployed pods cannot be evicted in the node draining process.")
workloadClusterProxy := input.BootstrapClusterProxy.GetWorkloadCluster(context.TODO(), cluster.Namespace, cluster.Name)
workloadClusterProxy := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, cluster.Namespace, cluster.Name)
framework.DeployUnevictablePod(ctx, framework.DeployUnevictablePodInput{
WorkloadClusterProxy: workloadClusterProxy,
DeploymentName: fmt.Sprintf("%s-%s", "unevictable-pod", util.RandomString(3)),
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/node_drain_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

var _ = Describe("When testing node drain timeout", func() {

NodeDrainTimeoutSpec(context.TODO(), func() NodeDrainTimeoutSpecInput {
NodeDrainTimeoutSpec(ctx, func() NodeDrainTimeoutSpecInput {
return NodeDrainTimeoutSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/quick_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

var _ = Describe("When following the Cluster API quick-start [PR-Blocking]", func() {

QuickStartSpec(context.TODO(), func() QuickStartSpecInput {
QuickStartSpec(ctx, func() QuickStartSpecInput {
return QuickStartSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/self_hosted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ limitations under the License.
package e2e

import (
"context"

. "github.com/onsi/ginkgo"
)

var _ = Describe("When testing Cluster API working on self-hosted clusters", func() {

SelfHostedSpec(context.TODO(), func() SelfHostedSpecInput {
SelfHostedSpec(ctx, func() SelfHostedSpecInput {
return SelfHostedSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
Expand Down

0 comments on commit 8e5241c

Please sign in to comment.