From 5b4205f8e492880209f37a2a33ad8b59ee889915 Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Wed, 8 Mar 2023 13:28:21 +0000 Subject: [PATCH] own --- test/e2e/clusterctl_upgrade.go | 4 +- test/e2e/clusterctl_upgrade_test.go | 83 +++++++++++++++++++++++- test/framework/ownerreference_helpers.go | 6 ++ 3 files changed, 89 insertions(+), 4 deletions(-) diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index aee0bf0f5ed8..d4f2042d0560 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -98,7 +98,7 @@ type ClusterctlUpgradeSpecInput struct { ControlPlaneWaiters clusterctl.ControlPlaneWaiters PreInit func(managementClusterProxy framework.ClusterProxy) PreUpgrade func(managementClusterProxy framework.ClusterProxy) - PostUpgrade func(managementClusterProxy framework.ClusterProxy) + PostUpgrade func(managementClusterProxy framework.ClusterProxy, namespace, clusterName string) // PreCleanupManagementCluster hook can be used for extra steps that might be required from providers, for example, remove conflicting service (such as DHCP) running on // the target management cluster and run it on bootstrap (before the latter resumes LCM) if both clusters share the same LAN PreCleanupManagementCluster func(managementClusterProxy framework.ClusterProxy) @@ -432,7 +432,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg if input.PostUpgrade != nil { By("Running Post-upgrade steps against the management cluster") - input.PostUpgrade(managementClusterProxy) + input.PostUpgrade(managementClusterProxy, testNamespace.Name, managementClusterName) } // After the upgrade check that there were no unexpected rollouts. diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index 450837ebd8de..62fc0c521078 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -21,9 +21,11 @@ package e2e import ( . "github.com/onsi/ginkgo/v2" + + "sigs.k8s.io/cluster-api/test/framework" ) -var _ = Describe("When testing clusterctl upgrades (v0.3=>current)", func() { +var _ = Describe("When testing clusterctl upgrades (v0.3=>current) [PR-Blocking]", func() { ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput { return ClusterctlUpgradeSpecInput{ E2EConfig: e2eConfig, @@ -39,6 +41,17 @@ var _ = Describe("When testing clusterctl upgrades (v0.3=>current)", func() { UpgradeClusterctlVariables: map[string]string{ "CLUSTER_TOPOLOGY": "false", }, + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -53,7 +66,18 @@ var _ = Describe("When testing clusterctl upgrades (v0.4=>current)", func() { SkipCleanup: skipCleanup, InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/clusterctl-{OS}-{ARCH}", InitWithProvidersContract: "v1alpha4", - InitWithKubernetesVersion: "v1.23.13", + InitWithKubernetesVersion: "v1.25.3", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -78,6 +102,17 @@ var _ = Describe("When testing clusterctl upgrades (v1.0=>current)", func() { // try to deploy the latest version of our test-extension from docker.yaml. InitWithRuntimeExtensionProviders: []string{}, InitWithKubernetesVersion: "v1.23.13", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -102,6 +137,17 @@ var _ = Describe("When testing clusterctl upgrades (v1.2=>current)", func() { // try to deploy the latest version of our test-extension from docker.yaml. InitWithRuntimeExtensionProviders: []string{}, InitWithKubernetesVersion: "v1.26.0", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -127,6 +173,17 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.2=>cur InitWithRuntimeExtensionProviders: []string{}, InitWithKubernetesVersion: "v1.26.0", WorkloadFlavor: "topology", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -142,6 +199,17 @@ var _ = Describe("When testing clusterctl upgrades (v1.3=>current)", func() { InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.3.0/clusterctl-{OS}-{ARCH}", InitWithProvidersContract: "v1beta1", InitWithKubernetesVersion: "v1.26.0", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) @@ -158,6 +226,17 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.3=>cur InitWithProvidersContract: "v1beta1", InitWithKubernetesVersion: "v1.26.0", WorkloadFlavor: "topology", + // This check ensures that ownerReference apiVersions are updated for all types after the upgrade. + PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) { + framework.ValidateOwnerReferencesOnUpdate(ctx, proxy, namespace, + framework.CoreTypeOwnerReferenceAssertion, + framework.ExpOwnerReferenceAssertions, + framework.DockerInfraOwnerReferenceAssertions, + framework.KubeadmBootstrapOwnerReferenceAssertions, + framework.KubeadmControlPlaneOwnerReferenceAssertions, + framework.KubernetesReferenceAssertions, + ) + }, } }) }) diff --git a/test/framework/ownerreference_helpers.go b/test/framework/ownerreference_helpers.go index a1c0cc1fd136..6f1db6967281 100644 --- a/test/framework/ownerreference_helpers.go +++ b/test/framework/ownerreference_helpers.go @@ -40,6 +40,12 @@ import ( "sigs.k8s.io/cluster-api/util/patch" ) +// ValidateOwnerReferencesResilience checks that expected owner references are in place, deletes them, and verifies that expect owner references are properly rebuilt. +func ValidateOwnerReferencesOnUpdate(ctx context.Context, proxy ClusterProxy, namespace string, assertFuncs ...map[string]func(reference []metav1.OwnerReference) error) { + // Check that the ownerReferences are as expected on the first iteration. + AssertOwnerReferences(namespace, proxy.GetKubeconfigPath(), assertFuncs...) +} + // ValidateOwnerReferencesResilience checks that expected owner references are in place, deletes them, and verifies that expect owner references are properly rebuilt. func ValidateOwnerReferencesResilience(ctx context.Context, proxy ClusterProxy, namespace, clusterName string, assertFuncs ...map[string]func(reference []metav1.OwnerReference) error) { // Check that the ownerReferences are as expected on the first iteration.