Skip to content

Commit 8065fc4

Browse files
committed
e2e: check available and ready v1beta2 conditions on machine and cluster to be true after upgrading CAPI
1 parent 4a2e16a commit 8065fc4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import (
5353
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
5454
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
5555
"sigs.k8s.io/cluster-api/util"
56+
v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
5657
)
5758

5859
// ClusterctlUpgradeSpecInput is the input for ClusterctlUpgradeSpec.
@@ -705,6 +706,10 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
705706
upgrade.PostUpgrade(managementClusterProxy, workloadCluster.Namespace, workloadCluster.Name)
706707
}
707708

709+
Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
710+
verifyV1Beta2ConditionsTrue(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
711+
[]string{clusterv1.AvailableV1Beta2Condition, clusterv1.ReadyV1Beta2Condition})
712+
708713
Byf("[%d] Verify client-side SSA still works", i)
709714
clusterUpdate := &unstructured.Unstructured{}
710715
clusterUpdate.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("Cluster"))
@@ -767,6 +772,38 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
767772
})
768773
}
769774

775+
// verifyV1Beta2ConditionsTrue checks the Cluster and Machines of a Cluster that
776+
// the given v1beta2 condition types are set to true without a message, if they exist.
777+
func verifyV1Beta2ConditionsTrue(ctx context.Context, c client.Client, clusterName, clusterNamespace string, v1beta2conditionTypes []string) {
778+
cluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{
779+
Getter: c,
780+
Name: clusterName,
781+
Namespace: clusterNamespace,
782+
})
783+
for _, conditionType := range v1beta2conditionTypes {
784+
if v1beta2conditions.Has(cluster, conditionType) {
785+
condition := v1beta2conditions.Get(cluster, conditionType)
786+
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Cluster should be set to true", conditionType)
787+
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Cluster should have an empty message", conditionType)
788+
}
789+
}
790+
791+
machines := framework.GetMachinesByCluster(ctx, framework.GetMachinesByClusterInput{
792+
Lister: c,
793+
ClusterName: clusterName,
794+
Namespace: clusterNamespace,
795+
})
796+
for _, machine := range machines {
797+
for _, conditionType := range v1beta2conditionTypes {
798+
if v1beta2conditions.Has(&machine, conditionType) {
799+
condition := v1beta2conditions.Get(&machine, conditionType)
800+
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Machine %q should be set to true", conditionType, machine.Name)
801+
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Machine %q should have an empty message", conditionType, machine.Name)
802+
}
803+
}
804+
}
805+
}
806+
770807
func setupClusterctl(ctx context.Context, clusterctlBinaryURL, clusterctlConfigPath string) (string, string) {
771808
clusterctlBinaryPath := downloadToTmpFile(ctx, clusterctlBinaryURL)
772809

0 commit comments

Comments
 (0)