Skip to content

Commit

Permalink
update api upgrade test to specifically use appropropriate templates …
Browse files Browse the repository at this point in the history
…for version (#6656) (#6665)
  • Loading branch information
cxbrowne1207 authored Sep 7, 2023
1 parent 0ae355f commit d9014be
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions internal/pkg/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ func WithKubernetesVersion(v anywherev1.KubernetesVersion) ClusterFiller {
}

// WithBundlesRef sets BundlesRef with the provided name to use.
func WithBundlesRef(name string, namespace string, apiVersion string) ClusterFiller {
func WithBundlesRef(bundlesRef *anywherev1.BundlesRef) ClusterFiller {
return func(c *anywherev1.Cluster) {
c.Spec.BundlesRef = &anywherev1.BundlesRef{Name: name, Namespace: namespace, APIVersion: apiVersion}
c.Spec.BundlesRef = bundlesRef
}
}

Expand Down
21 changes: 8 additions & 13 deletions test/e2e/cloudstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4112,10 +4112,7 @@ func TestCloudStackKubernetesRedHat123To124UpgradeFromLatestMinorReleaseAPI(t *t
)
managementCluster.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release))
managementCluster.UpdateClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube123),
),
cloudstack.WithRedhat123(),
cloudstack.WithKubeVersionAndOS(v1alpha1.Kube123, framework.RedHat8, release),
)
test := framework.NewMulticlusterE2ETest(t, managementCluster)
wc := framework.NewClusterE2ETest(
Expand All @@ -4129,14 +4126,15 @@ func TestCloudStackKubernetesRedHat123To124UpgradeFromLatestMinorReleaseAPI(t *t
api.ClusterToConfigFiller(
api.WithManagementCluster(managementCluster.ClusterName),
),
cloudstack.WithRedhat123(),
cloudstack.WithKubeVersionAndOS(v1alpha1.Kube123, framework.RedHat8, release),
)
test.WithWorkloadClusters(wc)

runMulticlusterUpgradeFromReleaseFlowAPI(
test,
release,
cloudstack.WithRedhat124(),
v1alpha1.Kube124,
framework.RedHat8,
)
}

Expand All @@ -4153,11 +4151,7 @@ func TestCloudStackKubernetesRedHat123to124UpgradeFromLatestMinorReleaseGitHubFl
)
managementCluster.GenerateClusterConfigForVersion(release.Version, framework.ExecuteWithEksaRelease(release))
managementCluster.UpdateClusterConfig(
api.ClusterToConfigFiller(
api.WithKubernetesVersion(v1alpha1.Kube123),
),

cloudstack.WithRedhat123(),
cloudstack.WithKubeVersionAndOS(v1alpha1.Kube123, framework.RedHat8, release),
framework.WithFluxGithubConfig(),
)
test := framework.NewMulticlusterE2ETest(t, managementCluster)
Expand All @@ -4174,15 +4168,16 @@ func TestCloudStackKubernetesRedHat123to124UpgradeFromLatestMinorReleaseGitHubFl
api.ClusterToConfigFiller(
api.WithManagementCluster(managementCluster.ClusterName),
),
cloudstack.WithRedhat123(),
cloudstack.WithKubeVersionAndOS(v1alpha1.Kube123, framework.RedHat8, release),
framework.WithFluxGithubConfig(),
)
test.WithWorkloadClusters(wc)

runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(
test,
release,
cloudstack.WithRedhat124(),
v1alpha1.Kube124,
framework.RedHat8,
)
}

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ func TestDockerKubernetes123to124UpgradeFromLatestMinorReleaseAPI(t *testing.T)
runMulticlusterUpgradeFromReleaseFlowAPI(
test,
release,
api.ClusterToConfigFiller(api.WithKubernetesVersion(v1alpha1.Kube124)),
v1alpha1.Kube124,
"",
)
}

Expand Down
30 changes: 20 additions & 10 deletions test/e2e/upgrade_from_latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func runUpgradeWithFluxFromReleaseFlow(test *framework.ClusterE2ETest, latestRel
test.DeleteCluster()
}

func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETest, release *releasev1.EksARelease, upgradeChanges api.ClusterConfigFiller) {
func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETest, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion, os framework.OS) {
provider := test.ManagementCluster.Provider
test.CreateManagementCluster(framework.ExecuteWithEksaRelease(release))

test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
Expand All @@ -69,7 +70,9 @@ func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETes

oldCluster := test.ManagementCluster.GetEKSACluster()

test.ManagementCluster.UpdateClusterConfig(upgradeChanges)
test.ManagementCluster.UpdateClusterConfig(
provider.WithKubeVersionAndOS(kubeVersion, os, nil),
)
test.ManagementCluster.UpgradeCluster()
test.ManagementCluster.ValidateCluster(test.ManagementCluster.ClusterConfig.Cluster.Spec.KubernetesVersion)
test.ManagementCluster.StopIfFailed()
Expand All @@ -79,8 +82,9 @@ func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETes
// Upgrade bundle workload clusters now because they still have the old versions of the bundle.
test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
wc.UpdateClusterConfig(
api.JoinClusterConfigFillers(upgradeChanges),
provider.WithKubeVersionAndOS(kubeVersion, os, nil),
api.ClusterToConfigFiller(
api.WithBundlesRef(nil),
api.WithEksaVersion(cluster.Spec.EksaVersion),
),
)
Expand All @@ -95,8 +99,9 @@ func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETes
// Create workload cluster with old bundle
test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
wc.UpdateClusterConfig(
provider.WithKubeVersionAndOS(kubeVersion, os, release),
api.ClusterToConfigFiller(
api.WithBundlesRef(oldCluster.Spec.BundlesRef.Name, oldCluster.Spec.BundlesRef.Namespace, oldCluster.Spec.BundlesRef.APIVersion),
api.WithBundlesRef(oldCluster.Spec.BundlesRef),
api.WithEksaVersion(nil),
),
)
Expand All @@ -112,7 +117,8 @@ func runMulticlusterUpgradeFromReleaseFlowAPI(test *framework.MulticlusterE2ETes
test.DeleteManagementCluster()
}

func runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(test *framework.MulticlusterE2ETest, release *releasev1.EksARelease, upgradeChanges api.ClusterConfigFiller) {
func runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(test *framework.MulticlusterE2ETest, release *releasev1.EksARelease, kubeVersion anywherev1.KubernetesVersion, os framework.OS) {
provider := test.ManagementCluster.Provider
test.CreateManagementCluster(framework.ExecuteWithEksaRelease(release))

test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
Expand All @@ -123,18 +129,21 @@ func runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(test *framework.Multiclust

oldCluster := test.ManagementCluster.GetEKSACluster()

test.ManagementCluster.UpdateClusterConfig(upgradeChanges)
test.ManagementCluster.UpdateClusterConfig(
provider.WithKubeVersionAndOS(kubeVersion, os, nil),
)
test.ManagementCluster.UpgradeCluster()
test.ManagementCluster.ValidateCluster(test.ManagementCluster.ClusterConfig.Cluster.Spec.KubernetesVersion)
test.ManagementCluster.StopIfFailed()

cluster := test.ManagementCluster.GetEKSACluster()

// Upgrade bundle workload clusters now because they still have the old versions of the bundle.
// Upgrade bundle workload clusters now using the new EksaVersion
test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
test.PushWorkloadClusterToGit(wc,
api.JoinClusterConfigFillers(upgradeChanges),
provider.WithKubeVersionAndOS(kubeVersion, os, nil),
api.ClusterToConfigFiller(
api.WithBundlesRef(nil),
api.WithEksaVersion(cluster.Spec.EksaVersion),
),
)
Expand All @@ -144,11 +153,12 @@ func runMulticlusterUpgradeFromReleaseFlowAPIWithFlux(test *framework.Multiclust
wc.ValidateClusterDelete()
})

// Create workload cluster with old bundle
// Create workload cluster with the old EksaVersion
test.RunConcurrentlyInWorkloadClusters(func(wc *framework.WorkloadCluster) {
test.PushWorkloadClusterToGit(wc,
provider.WithKubeVersionAndOS(kubeVersion, os, release),
api.ClusterToConfigFiller(
api.WithBundlesRef(oldCluster.Spec.BundlesRef.Name, oldCluster.Spec.BundlesRef.Namespace, oldCluster.Spec.BundlesRef.APIVersion),
api.WithBundlesRef(oldCluster.Spec.BundlesRef),
api.WithEksaVersion(nil),
),
)
Expand Down
8 changes: 2 additions & 6 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2691,12 +2691,8 @@ func TestVSphereKubernetes123to124UpgradeFromLatestMinorReleaseBottleRocketAPI(t
runMulticlusterUpgradeFromReleaseFlowAPI(
test,
release,
api.JoinClusterConfigFillers(
provider.WithBottleRocket124(),
api.VSphereToConfigFiller(
provider.Bottlerocket124Template(), // Set the template so it doesn't get autoimported
),
),
v1alpha1.Kube124,
framework.Bottlerocket1,
)
}

Expand Down
7 changes: 4 additions & 3 deletions test/framework/clustervalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import (
)

func validationsForExpectedObjects() []clusterf.StateValidation {
mediumRetier := retrier.NewWithMaxRetries(120, 5*time.Second)
longRetier := retrier.NewWithMaxRetries(120, 10*time.Second)
mediumRetier := retrier.New(10 * time.Minute)
longRetier := retrier.New(30 * time.Minute)
return []clusterf.StateValidation{
clusterf.RetriableStateValidation(mediumRetier, validations.ValidateClusterReady),
clusterf.RetriableStateValidation(mediumRetier, validations.ValidateEKSAObjects),
clusterf.RetriableStateValidation(longRetier, validations.ValidateControlPlaneNodes),
clusterf.RetriableStateValidation(longRetier, validations.ValidateWorkerNodes),
clusterf.RetriableStateValidation(mediumRetier, validations.ValidateCilium),
// This should be checked last as the Cluster should only be ready after all the other validations pass.
clusterf.RetriableStateValidation(mediumRetier, validations.ValidateClusterReady),
}
}

Expand Down

0 comments on commit d9014be

Please sign in to comment.