Skip to content

Commit

Permalink
own
Browse files Browse the repository at this point in the history
  • Loading branch information
killianmuldoon committed Mar 15, 2023
1 parent 838dcbb commit 5b4205f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
83 changes: 81 additions & 2 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
Expand All @@ -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,
)
},
}
})
})
6 changes: 6 additions & 0 deletions test/framework/ownerreference_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5b4205f

Please sign in to comment.