Skip to content

Commit

Permalink
reduced code to more streamline
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakm-ntnx committed Jan 31, 2024
1 parent b9fae9b commit 70d1e59
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 65 deletions.
30 changes: 18 additions & 12 deletions test/e2e/cluster_topology_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -82,7 +84,7 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})
Expand All @@ -91,14 +93,16 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -108,7 +112,7 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})
Expand All @@ -117,14 +121,16 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_29")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_29")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -134,7 +140,7 @@ var _ = Describe("When creating a cluster with topology with simple workflow", L
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})
Expand Down
70 changes: 38 additions & 32 deletions test/e2e/cluster_topology_scale_out_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
const flavor = "topology"

var (
namespace *corev1.Namespace
clusterName string
cluster *clusterv1.Cluster
cancelWatches context.CancelFunc
testHelper testHelperInterface
namespace *corev1.Namespace
clusterName string
cluster *clusterv1.Cluster
cancelWatches context.CancelFunc
testHelper testHelperInterface
nutanixE2ETest *NutanixE2ETest
)

Expand All @@ -61,18 +61,20 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
dumpSpecResourcesAndCleanup(ctx, specName, bootstrapClusterProxy, artifactFolder, namespace, cancelWatches, cluster, e2eConfig.GetIntervals, skipCleanup)
})

It("Scale out a cluster with topology from 1 CP node to 3 CP nodes", func() {
It("Scale out a cluster with topology from 1 CP node to 3 CP nodes with Kube127", func() {
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -82,15 +84,15 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

clusterTopologyConfig = NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(3),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err = nutanixE2ETest.UpgradeCluster(ctx, clusterTopologyConfig)
Expand All @@ -103,23 +105,25 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
nutanixE2ETest.WaitForMachineDeploymentMachinesToBeUpgraded(ctx, clusterTopologyConfig, clusterResources)

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})

It("Scale out a cluster with topology from 1 Worker node to 3 Worker nodes", func() {
It("Scale out a cluster with topology from 1 Worker node to 3 Worker nodes with Kube127", func() {
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -129,15 +133,15 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

clusterTopologyConfig = NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(3),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err = nutanixE2ETest.UpgradeCluster(ctx, clusterTopologyConfig)
Expand All @@ -150,23 +154,25 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
nutanixE2ETest.WaitForMachineDeploymentMachinesToBeUpgraded(ctx, clusterTopologyConfig, clusterResources)

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})

It("Scale out a cluster with topology from 1 CP and Worker node to 3 CP and Worker nodes", func() {
It("Scale out a cluster with topology from 1 CP and Worker node to 3 CP and Worker nodes with Kube127", func() {
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

targetKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -176,15 +182,15 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

clusterTopologyConfig = NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(targetKubeVer),
WithControlPlaneCount(3),
WithWorkerNodeCount(3),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(targetKubeVer),
WithWorkerMachineTemplateImage(targetKubeVer),
)

clusterResources, err = nutanixE2ETest.UpgradeCluster(ctx, clusterTopologyConfig)
Expand All @@ -197,7 +203,7 @@ var _ = Describe("When scaling out cluster with topology ", Label("clusterclass"
nutanixE2ETest.WaitForMachineDeploymentMachinesToBeUpgraded(ctx, clusterTopologyConfig, clusterResources)

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, targetKubeVer, clusterResources)

By("PASSED!")
})
Expand Down
48 changes: 27 additions & 21 deletions test/e2e/cluster_topology_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
const flavor = "topology"

var (
namespace *corev1.Namespace
clusterName string
cluster *clusterv1.Cluster
cancelWatches context.CancelFunc
testHelper testHelperInterface
namespace *corev1.Namespace
clusterName string
cluster *clusterv1.Cluster
cancelWatches context.CancelFunc
testHelper testHelperInterface
nutanixE2ETest *NutanixE2ETest
)

Expand Down Expand Up @@ -65,14 +65,17 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

fromKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")
toKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27")),
WithKubernetesVersion(fromKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_27")),
WithControlPlaneMachineTemplateImage(fromKubeVer),
WithWorkerMachineTemplateImage(fromKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -82,15 +85,15 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_27"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, fromKubeVer, clusterResources)

clusterTopologyConfig = NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")),
WithKubernetesVersion(toKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithControlPlaneMachineTemplateImage(toKubeVer),
WithWorkerMachineTemplateImage(toKubeVer),
)

clusterResources, err = nutanixE2ETest.UpgradeCluster(ctx, clusterTopologyConfig)
Expand All @@ -103,7 +106,7 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
nutanixE2ETest.WaitForMachineDeploymentMachinesToBeUpgraded(ctx, clusterTopologyConfig, clusterResources)

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, toKubeVer, clusterResources)

By("PASSED!")
})
Expand All @@ -112,14 +115,17 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
clusterName = testHelper.generateTestClusterName(specName)
Expect(clusterName).NotTo(BeNil())

fromKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")
toKubeVer := testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29")

By("Creating a workload cluster with topology")
clusterTopologyConfig := NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28")),
WithKubernetesVersion(fromKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_28")),
WithControlPlaneMachineTemplateImage(fromKubeVer),
WithWorkerMachineTemplateImage(fromKubeVer),
)

clusterResources, err := nutanixE2ETest.CreateCluster(ctx, clusterTopologyConfig)
Expand All @@ -129,15 +135,15 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
cluster = clusterResources.Cluster

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_28"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, fromKubeVer, clusterResources)

clusterTopologyConfig = NewClusterTopologyConfig(
WithName(clusterName),
WithKubernetesVersion(testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29")),
WithKubernetesVersion(toKubeVer),
WithControlPlaneCount(1),
WithWorkerNodeCount(1),
WithControlPlaneMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_29")),
WithWorkerMachineTemplateImage(testHelper.getVariableFromE2eConfig("NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME_v1_29")),
WithControlPlaneMachineTemplateImage(toKubeVer),
WithWorkerMachineTemplateImage(toKubeVer),
)

clusterResources, err = nutanixE2ETest.UpgradeCluster(ctx, clusterTopologyConfig)
Expand All @@ -150,7 +156,7 @@ var _ = Describe("When upgrading the k8s version of cluster with topology", Labe
nutanixE2ETest.WaitForMachineDeploymentMachinesToBeUpgraded(ctx, clusterTopologyConfig, clusterResources)

By("Waiting until nodes are ready")
nutanixE2ETest.WaitForNodesReady(ctx, testHelper.getVariableFromE2eConfig("KUBERNETES_VERSION_v1_29"), clusterResources)
nutanixE2ETest.WaitForNodesReady(ctx, toKubeVer, clusterResources)

By("PASSED!")
})
Expand Down

0 comments on commit 70d1e59

Please sign in to comment.