Skip to content

Commit

Permalink
Add InPlace upgrade flow tests for different K8s versions
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Ganesh <[email protected]>
  • Loading branch information
Rahul Ganesh committed Feb 7, 2024
1 parent 6c9e784 commit 6d49b70
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
23 changes: 6 additions & 17 deletions internal/pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,25 +351,14 @@ func WithEtcdEncryptionFiller(kms *anywherev1.KMS, resources []string) ClusterFi

func WithInPlaceUpgradeStrategy() ClusterFiller {

Check warning on line 352 in internal/pkg/api/cluster.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported function WithInPlaceUpgradeStrategy should have comment or be unexported (revive)
return func(c *anywherev1.Cluster) {
if c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy == nil {
c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
} else {
c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
c.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy = &anywherev1.ControlPlaneUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
for _, wng := range c.Spec.WorkerNodeGroupConfigurations {
if wng.UpgradeRolloutStrategy == nil {
wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
} else {
wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
for idx, wng := range c.Spec.WorkerNodeGroupConfigurations {
wng.UpgradeRolloutStrategy = &anywherev1.WorkerNodesUpgradeRolloutStrategy{
Type: anywherev1.InPlaceStrategyType,
}
c.Spec.WorkerNodeGroupConfigurations[idx] = wng
}
}
}
48 changes: 46 additions & 2 deletions test/e2e/tinkerbell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,50 @@ func TestTinkerbellKubernetes125UbuntuAddWorkerNodeGroupWithAPI(t *testing.T) {
)
}

func TestTinkerbellKubernetes125UbuntuTo126InPlaceUpgrade(t *testing.T) {
provider := framework.NewTinkerbell(t)
kube125 := v1alpha1.Kube125
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterFiller(api.WithKubernetesVersion(kube125)),
framework.WithClusterFiller(api.WithControlPlaneCount(1)),
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
).WithClusterConfig(
provider.WithKubeVersionAndOS(v1alpha1.Kube125, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlowForBareMetal(
test,
framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube126), api.WithInPlaceUpgradeStrategy()),
provider.WithProviderUpgrade(framework.Ubuntu126Image()),
)
}

func TestTinkerbellKubernetes126UbuntuTo127InPlaceUpgrade(t *testing.T) {
provider := framework.NewTinkerbell(t)
kube126 := v1alpha1.Kube126
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterFiller(api.WithKubernetesVersion(kube126)),
framework.WithClusterFiller(api.WithControlPlaneCount(1)),
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
).WithClusterConfig(
provider.WithKubeVersionAndOS(v1alpha1.Kube126, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlowForBareMetal(
test,
framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube127), api.WithInPlaceUpgradeStrategy()),
provider.WithProviderUpgrade(framework.Ubuntu127Image()),
)
}

func TestTinkerbellKubernetes127UbuntuTo128InPlaceUpgrade(t *testing.T) {
provider := framework.NewTinkerbell(t)
kube127 := v1alpha1.Kube127
Expand All @@ -330,15 +374,15 @@ func TestTinkerbellKubernetes127UbuntuTo128InPlaceUpgrade(t *testing.T) {
framework.WithClusterFiller(api.WithKubernetesVersion(kube127)),
framework.WithClusterFiller(api.WithControlPlaneCount(1)),
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
framework.WithClusterFiller(api.WithWorkerKubernetesVersion(nodeGroupLabel1, &kube127)),
framework.WithClusterFiller(api.WithInPlaceUpgradeStrategy()),
framework.WithControlPlaneHardware(1),
framework.WithWorkerHardware(1),
).WithClusterConfig(
provider.WithKubeVersionAndOS(v1alpha1.Kube127, framework.Ubuntu2004, nil),
)
runInPlaceUpgradeFlowForBareMetal(
test,
framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube128)),
framework.WithClusterUpgrade(api.WithKubernetesVersion(v1alpha1.Kube128), api.WithInPlaceUpgradeStrategy()),
provider.WithProviderUpgrade(framework.Ubuntu128Image()),
)
}
Expand Down

0 comments on commit 6d49b70

Please sign in to comment.