Skip to content

Commit 31a8274

Browse files
committed
e2e: check available and ready v1beta2 conditions on machine and cluster to be true after upgrading CAPI
1 parent a491076 commit 31a8274

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.
@@ -698,6 +699,10 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
698699
}
699700
}
700701

702+
Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
703+
verifyV1Beta2ConditionsTrue(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
704+
[]string{clusterv1.AvailableV1Beta2Condition, clusterv1.ReadyV1Beta2Condition})
705+
701706
Byf("[%d] Verify client-side SSA still works", i)
702707
clusterUpdate := &unstructured.Unstructured{}
703708
clusterUpdate.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("Cluster"))
@@ -760,6 +765,38 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
760765
})
761766
}
762767

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

0 commit comments

Comments
 (0)