Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions test/e2e/cluster_upgrade_runtimesdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass with Runt
PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) {
// This check ensures that the resourceVersions are stable, i.e. it verifies there are no
// continuous reconciles when everything should be stable.
framework.ValidateResourceVersionStable(ctx, proxy, namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName))
spec := "k8s-upgrade-with-runtimesdk"
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: proxy,
Namespace: namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName),
WaitToBecomeStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-become-stable"),
WaitToRemainStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)
},
// "upgrades" is the same as the "topology" flavor but with an additional MachinePool.
Flavor: ptr.To("upgrades-runtimesdk"),
Expand All @@ -64,7 +72,15 @@ var _ = Describe("When upgrading a workload cluster using ClusterClass in a diff
PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) {
// This check ensures that the resourceVersions are stable, i.e. it verifies there are no
// continuous reconciles when everything should be stable.
framework.ValidateResourceVersionStable(ctx, proxy, namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName))
spec := "k8s-upgrade-with-runtimesdk"
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: proxy,
Namespace: namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName),
WaitToBecomeStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-become-stable"),
WaitToRemainStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)
},
// "upgrades" is the same as the "topology" flavor but with an additional MachinePool.
Flavor: ptr.To("upgrades-runtimesdk"),
Expand Down
9 changes: 8 additions & 1 deletion test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,14 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
// continuous reconciles when everything should be stable.
if i == len(input.Upgrades)-1 {
Byf("[%d] Checking that resourceVersions are stable", i)
framework.ValidateResourceVersionStable(ctx, managementClusterProxy, workloadCluster.Namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(workloadCluster.Name))
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: managementClusterProxy,
Namespace: workloadCluster.Namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(workloadCluster.Name),
WaitToBecomeStable: input.E2EConfig.GetIntervals(specName, "wait-resource-versions-become-stable"),
WaitToRemainStable: input.E2EConfig.GetIntervals(specName, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)

// NOTE: Checks on conditions works on v1beta2 only, so running this checks only in the last step which is
// always current version.
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/config/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ intervals:
default/wait-nodes-ready: ["10m", "10s"]
default/wait-machine-remediation: ["5m", "10s"]
default/wait-autoscaler: ["5m", "10s"]
default/wait-resource-versions-become-stable: ["2m", "15s"]
default/wait-resource-versions-remain-stable: ["2m", "5s"]
node-drain/wait-deployment-available: ["3m", "10s"]
node-drain/wait-control-plane: ["15m", "10s"]
node-drain/wait-machine-deleted: ["2m", "10s"]
Expand Down
30 changes: 27 additions & 3 deletions test/e2e/quick_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ var _ = Describe("When following the Cluster API quick-start", func() {
// This check ensures that the resourceVersions are stable, i.e. it verifies there are no
// continuous reconciles when everything should be stable.
By("Checking that resourceVersions are stable")
framework.ValidateResourceVersionStable(ctx, proxy, namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName))
spec := "quick-start"
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: proxy,
Namespace: namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName),
WaitToBecomeStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-become-stable"),
WaitToRemainStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)
},
}
})
Expand Down Expand Up @@ -116,7 +124,15 @@ var _ = Describe("When following the Cluster API quick-start with ClusterClass [
// This check ensures that the resourceVersions are stable, i.e. it verifies there are no
// continuous reconciles when everything should be stable.
By("Checking that resourceVersions are stable")
framework.ValidateResourceVersionStable(ctx, proxy, namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName))
spec := "quick-start"
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: proxy,
Namespace: namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName),
WaitToBecomeStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-become-stable"),
WaitToRemainStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)
},
}
})
Expand All @@ -141,7 +157,15 @@ var _ = Describe("When following the Cluster API quick-start with v1beta1 Cluste
// This check ensures that the resourceVersions are stable, i.e. it verifies there are no
// continuous reconciles when everything should be stable.
By("Checking that resourceVersions are stable")
framework.ValidateResourceVersionStable(ctx, proxy, namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName))
spec := "quick-start"
resourceVersionInput := framework.ValidateResourceVersionStableInput{
ClusterProxy: proxy,
Namespace: namespace,
OwnerGraphFilterFunction: clusterctlcluster.FilterClusterObjectsWithNameFilter(clusterName),
WaitToBecomeStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-become-stable"),
WaitToRemainStable: e2eConfig.GetIntervals(spec, "wait-resource-versions-remain-stable"),
}
framework.ValidateResourceVersionStable(ctx, resourceVersionInput)
},
}
})
Expand Down
28 changes: 22 additions & 6 deletions test/framework/resourceversion_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/google/go-cmp/cmp"
. "github.com/onsi/gomega"
Expand All @@ -32,14 +31,27 @@ import (
clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
)

// ValidateResourceVersionStableInput contains parameters for [ValidateResourceVersionStable].
type ValidateResourceVersionStableInput struct {
ClusterProxy ClusterProxy
Namespace string
OwnerGraphFilterFunction clusterctlcluster.GetOwnerGraphFilterFunction
WaitToBecomeStable []any
WaitToRemainStable []any
}

// ValidateResourceVersionStable checks that resourceVersions are stable.
func ValidateResourceVersionStable(ctx context.Context, proxy ClusterProxy, namespace string, ownerGraphFilterFunction clusterctlcluster.GetOwnerGraphFilterFunction) {
func ValidateResourceVersionStable(ctx context.Context, input ValidateResourceVersionStableInput) {
// Wait until resourceVersions are stable for a bit.
byf("Check resourceVersions are stable")
var previousResourceVersions map[string]string
var previousObjects map[string]client.Object
waitToBecomeStable := input.WaitToBecomeStable
if len(waitToBecomeStable) == 0 {
waitToBecomeStable = []any{"2m", "15s"}
}
Eventually(func(g Gomega) {
objectsWithResourceVersion, objects, err := getObjectsWithResourceVersion(ctx, proxy, namespace, ownerGraphFilterFunction)
objectsWithResourceVersion, objects, err := getObjectsWithResourceVersion(ctx, input.ClusterProxy, input.Namespace, input.OwnerGraphFilterFunction)
g.Expect(err).ToNot(HaveOccurred())

defer func() {
Expand All @@ -49,15 +61,19 @@ func ValidateResourceVersionStable(ctx context.Context, proxy ClusterProxy, name
}()
// This is intentionally failing on the first run.
g.Expect(objectsWithResourceVersion).To(BeComparableTo(previousResourceVersions))
}, 1*time.Minute, 15*time.Second).Should(Succeed(), "resourceVersions never became stable")
}, waitToBecomeStable...).MustPassRepeatedly(4).Should(Succeed(), "resourceVersions never became stable")

// Verify resourceVersions are stable for a while.
byf("Check resourceVersions remain stable")
waitToRemainStable := input.WaitToRemainStable
if len(waitToRemainStable) == 0 {
waitToRemainStable = []any{"2m", "5s"}
}
Consistently(func(g Gomega) {
objectsWithResourceVersion, objects, err := getObjectsWithResourceVersion(ctx, proxy, namespace, ownerGraphFilterFunction)
objectsWithResourceVersion, objects, err := getObjectsWithResourceVersion(ctx, input.ClusterProxy, input.Namespace, input.OwnerGraphFilterFunction)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(previousResourceVersions).To(BeComparableTo(objectsWithResourceVersion), printObjectDiff(previousObjects, objects))
}, 2*time.Minute, 15*time.Second).Should(Succeed(), "resourceVersions didn't stay stable")
}, waitToRemainStable...).Should(Succeed(), "resourceVersions didn't stay stable")
}

func printObjectDiff(previousObjects, newObjects map[string]client.Object) func() string {
Expand Down