From a577cd8d95cd38138a11c84ccb9676f87675937a Mon Sep 17 00:00:00 2001 From: Rahul Ganesh Date: Thu, 19 Oct 2023 16:55:40 -0700 Subject: [PATCH] Add E2E tests for modular upgrade for bare-metal provider Signed-off-by: Rahul Ganesh --- test/e2e/tinkerbell_test.go | 16 ++++++++++----- test/e2e/upgrade.go | 1 - test/framework/tinkerbell.go | 40 ++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/test/e2e/tinkerbell_test.go b/test/e2e/tinkerbell_test.go index 692ce2736d12..f40cf54c5ea1 100644 --- a/test/e2e/tinkerbell_test.go +++ b/test/e2e/tinkerbell_test.go @@ -120,7 +120,7 @@ func TestTinkerbellKubernetes127UbuntuTo128Upgrade(t *testing.T) { } func TestTinkerbellKubernetes127UbuntuTo128UpgradeCPOnly(t *testing.T) { - provider := framework.NewTinkerbell(t, framework.WithUbuntu127TinkerbellForCP(), framework.WithUbuntu127TinkerbellForWorker()) + provider := framework.NewTinkerbell(t) kube127 := v1alpha1.Kube127 test := framework.NewClusterE2ETest( t, @@ -128,9 +128,12 @@ func TestTinkerbellKubernetes127UbuntuTo128UpgradeCPOnly(t *testing.T) { framework.WithClusterFiller(api.WithKubernetesVersion(kube127)), framework.WithClusterFiller(api.WithControlPlaneCount(1)), framework.WithClusterFiller(api.WithWorkerNodeCount(1)), - framework.WithClusterFiller(api.WithWorkerKubernetesVersion(worker0, &kube127)), + framework.WithClusterFiller(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127)), framework.WithControlPlaneHardware(2), framework.WithWorkerHardware(1), + ).WithClusterConfig( + provider.WithCPKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004), + provider.WithWorkerKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004), ) runSimpleUpgradeFlowWorkerNodeVersionForBareMetal( test, @@ -140,7 +143,7 @@ func TestTinkerbellKubernetes127UbuntuTo128UpgradeCPOnly(t *testing.T) { } func TestTinkerbellKubernetes127UbuntuTo128UpgradeWorkerOnly(t *testing.T) { - provider := framework.NewTinkerbell(t, framework.WithUbuntu128TinkerbellForCP(), framework.WithUbuntu127TinkerbellForWorker()) + provider := framework.NewTinkerbell(t) kube127 := v1alpha1.Kube127 kube128 := v1alpha1.Kube128 test := framework.NewClusterE2ETest( @@ -150,13 +153,16 @@ func TestTinkerbellKubernetes127UbuntuTo128UpgradeWorkerOnly(t *testing.T) { framework.WithClusterFiller(api.WithKubernetesVersion(kube128)), framework.WithClusterFiller(api.WithControlPlaneCount(1)), framework.WithClusterFiller(api.WithWorkerNodeCount(1)), - framework.WithClusterFiller(api.WithWorkerKubernetesVersion(worker0, &kube127)), + framework.WithClusterFiller(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127)), framework.WithControlPlaneHardware(1), framework.WithWorkerHardware(2), + ).WithClusterConfig( + provider.WithCPKubeVersionAndOS(v1alpha1.Kube128, framework.Ubuntu2004), + provider.WithWorkerKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004), ) runSimpleUpgradeFlowWorkerNodeVersionForBareMetal( test, - framework.WithClusterUpgrade(api.WithWorkerKubernetesVersion(worker0, &kube128)), + framework.WithClusterUpgrade(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube128)), provider.WithProviderUpgrade(framework.Ubuntu128ImageForWorker()), ) } diff --git a/test/e2e/upgrade.go b/test/e2e/upgrade.go index 9ddf43fb22ce..ff52cd59d1e0 100644 --- a/test/e2e/upgrade.go +++ b/test/e2e/upgrade.go @@ -52,7 +52,6 @@ func runSimpleUpgradeFlowForBareMetal(test *framework.ClusterE2ETest, updateVers } func runSimpleUpgradeFlowWorkerNodeVersionForBareMetal(test *framework.ClusterE2ETest, clusterOpts ...framework.ClusterE2ETestOpt) { - test.GenerateClusterConfig() test.GenerateHardwareConfig() test.PowerOffHardware() test.CreateCluster(framework.WithControlPlaneWaitTimeout("20m")) diff --git a/test/framework/tinkerbell.go b/test/framework/tinkerbell.go index 7f3738e7afd9..c0bc5784d3c5 100644 --- a/test/framework/tinkerbell.go +++ b/test/framework/tinkerbell.go @@ -156,6 +156,26 @@ func (t *Tinkerbell) WithKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersi ) } +// WithCPKubeVersionAndOS returns a cluster config filler that sets the cluster kube version and the right image for CP +// tinkerbell machine configs. +func (t *Tinkerbell) WithCPKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, os OS) api.ClusterConfigFiller { + return api.JoinClusterConfigFillers( + api.TinkerbellToConfigFiller( + imageForKubeVersionAndOS(kubeVersion, os, controlPlaneIdentifier), + ), + ) +} + +// WithWorkerKubeVersionAndOS returns a cluster config filler that sets the cluster kube version and the right image for all +// Worker tinkerbell machine configs. +func (t *Tinkerbell) WithWorkerKubeVersionAndOS(kubeVersion anywherev1.KubernetesVersion, os OS) api.ClusterConfigFiller { + return api.JoinClusterConfigFillers( + api.TinkerbellToConfigFiller( + imageForKubeVersionAndOS(kubeVersion, os, workerIdentifier), + ), + ) +} + // WithNewWorkerNodeGroup returns an api.ClusterFiller that adds a new workerNodeGroupConfiguration and // a corresponding TinkerbellMachineConfig to the cluster config. func (t *Tinkerbell) WithNewWorkerNodeGroup(name string, workerNodeGroup *WorkerNodeGroup) api.ClusterConfigFiller { @@ -211,26 +231,6 @@ func WithUbuntu128Tinkerbell() TinkerbellOpt { return withKubeVersionAndOS(anywherev1.Kube128, Ubuntu2004, "", nil) } -// WithUbuntu127TinkerbellForCP tink test with ubuntu 1.27 for Control Plane Machine Config. -func WithUbuntu127TinkerbellForCP() TinkerbellOpt { - return withKubeVersionAndOS(anywherev1.Kube127, Ubuntu2004, controlPlaneIdentifier, nil) -} - -// WithUbuntu128TinkerbellForCP tink test with ubuntu 1.28 for Control Plane Machine Config. -func WithUbuntu128TinkerbellForCP() TinkerbellOpt { - return withKubeVersionAndOS(anywherev1.Kube128, Ubuntu2004, controlPlaneIdentifier, nil) -} - -// WithUbuntu127TinkerbellForWorker tink test with ubuntu 1.27 for Worker Node Group Machine Config. -func WithUbuntu127TinkerbellForWorker() TinkerbellOpt { - return withKubeVersionAndOS(anywherev1.Kube127, Ubuntu2004, workerIdentifier, nil) -} - -// WithUbuntu128TinkerbellForWorker tink test with ubuntu 1.28 for Worker Node Group Machine Config. -func WithUbuntu128TinkerbellForWorker() TinkerbellOpt { - return withKubeVersionAndOS(anywherev1.Kube128, Ubuntu2004, workerIdentifier, nil) -} - // WithRedHat124Tinkerbell tink test with redhat 1.24. func WithRedHat124Tinkerbell() TinkerbellOpt { return withKubeVersionAndOS(anywherev1.Kube124, RedHat8, "", nil)