Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Jan 19, 2024
1 parent 6ab0280 commit 61348ae
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 208 deletions.
8 changes: 3 additions & 5 deletions test/e2e/anti_affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ var _ = Describe("Cluster creation with anti affined nodes", func() {

var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

BeforeEach(func() {
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/capi_machine_deployment_rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"

"sigs.k8s.io/cluster-api-provider-vsphere/test/e2e/ipam"
Expand All @@ -27,15 +28,13 @@ var _ = Describe("ClusterAPI Machine Deployment Tests", func() {
Context("Running the MachineDeployment rollout spec", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

capi_e2e.MachineDeploymentRolloutSpec(ctx, func() capi_e2e.MachineDeploymentRolloutSpecInput {
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/ptr"
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"

Expand All @@ -27,15 +28,13 @@ import (
var _ = Describe("When upgrading a workload cluster using ClusterClass [ClusterClass]", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

capi_e2e.ClusterUpgradeConformanceSpec(ctx, func() capi_e2e.ClusterUpgradeConformanceSpecInput {
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/clusterclass_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
capie2e "sigs.k8s.io/cluster-api/test/e2e"

"sigs.k8s.io/cluster-api-provider-vsphere/test/e2e/ipam"
Expand All @@ -26,15 +27,13 @@ import (
var _ = Describe("When testing ClusterClass changes [ClusterClass]", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

capie2e.ClusterClassChangesSpec(ctx, func() capie2e.ClusterClassChangesSpecInput {
Expand Down
17 changes: 7 additions & 10 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"

"sigs.k8s.io/cluster-api-provider-vsphere/test/e2e/ipam"
Expand All @@ -26,15 +27,13 @@ import (
var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.8=>current, CAPI 1.5=>1.6) [ClusterClass]", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup, "WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath, "WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
Expand Down Expand Up @@ -63,15 +62,13 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.8=
var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.7=>current, CAPI 1.4=>1.6) [ClusterClass]", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup, "WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath, "WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

capi_e2e.ClusterctlUpgradeSpec(ctx, func() capi_e2e.ClusterctlUpgradeSpecInput {
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/dhcp_overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ var _ = Describe("DHCPOverrides configuration test", func() {
When("Creating a cluster with DHCPOverrides configured", func() {
var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

const specName = "dhcp-overrides"
Expand Down
29 changes: 26 additions & 3 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ var (
// e2eIPAMKubeconfig is a kubeconfig to a cluster which provides IP address management via an in-cluster
// IPAM provider to claim IPs for the control plane IPs of created clusters.
e2eIPAMKubeconfig string

// ipamHelper is used to claim and cleanup IP addresses used for kubernetes control plane API Servers.
ipamHelper ipam.Helper
)

func init() {
Expand Down Expand Up @@ -152,23 +155,31 @@ var _ = SynchronizedBeforeSuite(func() []byte {
By("Initializing the bootstrap cluster")
vsphereframework.InitBootstrapCluster(ctx, bootstrapClusterProxy, e2eConfig, clusterctlConfigPath, artifactFolder)

ipamLabels := ipam.GetIPAddressClaimLabels()
var ipamLabelsRaw []string
for k, v := range ipamLabels {
ipamLabelsRaw = append(ipamLabelsRaw, fmt.Sprintf("%s=%s", k, v))
}

return []byte(
strings.Join([]string{
artifactFolder,
configPath,
clusterctlConfigPath,
bootstrapClusterProxy.GetKubeconfigPath(),
strings.Join(ipamLabelsRaw, ";"),
}, ","),
)
}, func(data []byte) {
// Before each ParallelNode.
parts := strings.Split(string(data), ",")
Expect(parts).To(HaveLen(4))
Expect(parts).To(HaveLen(5))

artifactFolder = parts[0]
configPath = parts[1]
clusterctlConfigPath = parts[2]
kubeconfigPath := parts[3]
ipamLabelsRaw := parts[4]

namespaces = map[*corev1.Namespace]context.CancelFunc{}

Expand All @@ -178,6 +189,18 @@ var _ = SynchronizedBeforeSuite(func() []byte {
e2eConfig, err = vsphereframework.LoadE2EConfig(ctx, configPath)
Expect(err).NotTo(HaveOccurred())
bootstrapClusterProxy = framework.NewClusterProxy("bootstrap", kubeconfigPath, initScheme(), framework.WithMachineLogCollector(LogCollector{}))

ipamLabels := map[string]string{}
for _, s := range strings.Split(ipamLabelsRaw, ";") {
splittedLabel := strings.Split(s, "=")
Expect(splittedLabel).To(HaveLen(2))

ipamLabels[splittedLabel[0]] = splittedLabel[1]
}
if e2eIPAMKubeconfig != "" {
ipamHelper, err = ipam.New(e2eIPAMKubeconfig, ipamLabels, skipCleanup)
Expect(err).ToNot(HaveOccurred())
}
})

// Using a SynchronizedAfterSuite for controlling how to delete resources shared across ParallelNodes (~ginkgo threads).
Expand All @@ -191,12 +214,12 @@ var _ = SynchronizedAfterSuite(func() {
By("Cleaning up orphaned IPAddressClaims")
vSphereFolderName, err := getClusterctlConfigVariable(clusterctlConfigPath, "VSPHERE_FOLDER")
Expect(err).ToNot(HaveOccurred())
Expect(ipam.Teardown(ctx, e2eIPAMKubeconfig, vSphereFolderName, vsphereClient)).To(Succeed())
Expect(ipamHelper.Teardown(ctx, vSphereFolderName, vsphereClient)).To(Succeed())
}

By("Cleaning up the vSphere session", terminateVSphereSession)
By("Tearing down the management cluster")
if !skipCleanup {
By("Tearing down the management cluster")
vsphereframework.TearDown(ctx, bootstrapClusterProvider, bootstrapClusterProxy)
}
})
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/gpu_pci_passthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ var _ = Describe("Cluster creation with GPU devices as PCI passthrough [speciali

var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

BeforeEach(func() {
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/hardware_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ var _ = Describe("Hardware version upgrade", func() {

var (
testSpecificClusterctlConfigPath string
testSpecificIPAMCleanupFunc func()
testSpecificIPAddressClaims ipam.IPAddressClaims
)
BeforeEach(func() {
testSpecificClusterctlConfigPath, testSpecificIPAMCleanupFunc = ipam.ConfigureControlPlaneIPs(ctx, e2eIPAMKubeconfig, clusterctlConfigPath, skipCleanup)
testSpecificClusterctlConfigPath, testSpecificIPAddressClaims = ipamHelper.ClaimIPs(ctx, clusterctlConfigPath)
})
defer AfterEach(func() {
if testSpecificIPAMCleanupFunc != nil {
testSpecificIPAMCleanupFunc()
}
Expect(ipamHelper.Cleanup(ctx, testSpecificIPAddressClaims)).To(Succeed())
})

BeforeEach(func() {
Expand Down
Loading

0 comments on commit 61348ae

Please sign in to comment.