Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Jul 19, 2024
1 parent a37eea9 commit 61e1c23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
13 changes: 9 additions & 4 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"

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

var (
Expand Down Expand Up @@ -67,11 +69,11 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10
InitWithKubernetesVersion: "v1.30.0",
WorkloadKubernetesVersion: "v1.30.0",
WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"),
UseKindForManagementCluster: true,
UseKindForManagementCluster: testSpecificSettingsGetter().UseKindForManagementCluster,
KindManagementClusterNewClusterProxyFunc: kindManagementClusterNewClusterProxyFunc,
}
})
}, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"), WithUseKindForManagementCluster())
}, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"), WithAdditionalVCSimServer(true))
})

var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9=>current, CAPI 1.6=>1.8) [vcsim] [supervisor] [ClusterClass]", func() {
Expand Down Expand Up @@ -105,11 +107,11 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9=
InitWithKubernetesVersion: "v1.29.0",
WorkloadKubernetesVersion: "v1.29.0",
WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"),
UseKindForManagementCluster: true,
UseKindForManagementCluster: testSpecificSettingsGetter().UseKindForManagementCluster,
KindManagementClusterNewClusterProxyFunc: kindManagementClusterNewClusterProxyFunc,
}
})
}, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"), WithUseKindForManagementCluster())
}, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP"), WithAdditionalVCSimServer(true))
})

// getStableReleaseOfMinor returns the latest stable version of minorRelease.
Expand All @@ -119,5 +121,8 @@ func getStableReleaseOfMinor(ctx context.Context, releaseMarkerPrefix, minorRele
}

func kindManagementClusterNewClusterProxyFunc(name string, kubeconfigPath string) framework.ClusterProxy {
if testTarget == VCSimTestTarget {
return vcsim.NewClusterProxy(name, kubeconfigPath, initScheme())
}
return framework.NewClusterProxy(name, kubeconfigPath, initScheme())
}
35 changes: 19 additions & 16 deletions test/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ import (
)

type setupOptions struct {
additionalIPVariableNames []string
gatewayIPVariableName string
prefixVariableName string
useKindForManagementCluster bool
additionalIPVariableNames []string
gatewayIPVariableName string
prefixVariableName string
additionalVCSimServer bool
}

// SetupOption is a configuration option supplied to Setup.
Expand Down Expand Up @@ -74,19 +74,21 @@ func WithPrefix(variableName string) SetupOption {
}
}

// WithUseKindForManagementCluster instructs Setup to run extra steps for the separate kind management cluster.
func WithUseKindForManagementCluster() SetupOption {
// WithAdditionalVCSimServer instructs Setup to run extra steps for setting up VCSim
// with a separate kind management cluster.
func WithAdditionalVCSimServer(t bool) SetupOption {
return func(o *setupOptions) {
o.useKindForManagementCluster = true
o.additionalVCSimServer = t
}
}

type testSettings struct {
ClusterctlConfigPath string
Variables map[string]string
PostNamespaceCreatedFunc func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string)
FlavorForMode func(flavor string) string
RuntimeExtensionProviders []string
ClusterctlConfigPath string
Variables map[string]string
PostNamespaceCreatedFunc func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string)
FlavorForMode func(flavor string) string
RuntimeExtensionProviders []string
UseKindForManagementCluster bool
}

// Setup for the specific test.
Expand Down Expand Up @@ -145,7 +147,7 @@ func Setup(specName string, f func(testSpecificSettings func() testSettings), op
postNamespaceCreatedFunc = func(managementClusterProxy framework.ClusterProxy, workloadClusterNamespace string) {
var ipVariables map[string]string

if testTarget == VCSimTestTarget && options.useKindForManagementCluster {
if options.additionalVCSimServer && testTarget == VCSimTestTarget {
Byf("Creating a vcsim server")
Eventually(func() error {
return vspherevcsim.Create(ctx, managementClusterProxy.GetClient())
Expand All @@ -167,7 +169,7 @@ func Setup(specName string, f func(testSpecificSettings func() testSettings), op
case VCSimTestTarget:
testSpecificIPAddressManager = vcsimAddressManager
// Use a new address manager when using VCSim in a separate kind management cluster.
if options.useKindForManagementCluster {
if options.additionalVCSimServer {
var err error
testSpecificIPAddressManager, err = vsphereip.VCSIMAddressManager(managementClusterProxy.GetClient(), map[string]string{}, skipCleanup)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -258,7 +260,7 @@ func Setup(specName string, f func(testSpecificSettings func() testSettings), op
if !skipCleanup {
Byf("Cleaning up test env for %s", specName)
// We can't cleanup when a kind management cluster is used, because it won't exist anymore.
if !options.useKindForManagementCluster {
if !options.additionalVCSimServer {
// cleanup IPs/controlPlaneEndpoint created by the IPAddressManager.
Expect(testSpecificIPAddressManager.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
}
Expand All @@ -284,7 +286,8 @@ func Setup(specName string, f func(testSpecificSettings func() testSettings), op
}
return flavor
},
RuntimeExtensionProviders: runtimeExtensionProviders,
RuntimeExtensionProviders: runtimeExtensionProviders,
UseKindForManagementCluster: options.additionalVCSimServer,
}
})
}
Expand Down

0 comments on commit 61e1c23

Please sign in to comment.