@@ -53,6 +53,7 @@ import (
53
53
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
54
54
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
55
55
"sigs.k8s.io/cluster-api/util"
56
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
56
57
)
57
58
58
59
// ClusterctlUpgradeSpecInput is the input for ClusterctlUpgradeSpec.
@@ -705,6 +706,10 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
705
706
upgrade .PostUpgrade (managementClusterProxy , workloadCluster .Namespace , workloadCluster .Name )
706
707
}
707
708
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
+
708
713
Byf ("[%d] Verify client-side SSA still works" , i )
709
714
clusterUpdate := & unstructured.Unstructured {}
710
715
clusterUpdate .SetGroupVersionKind (clusterv1 .GroupVersion .WithKind ("Cluster" ))
@@ -767,6 +772,38 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
767
772
})
768
773
}
769
774
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
+
770
807
func setupClusterctl (ctx context.Context , clusterctlBinaryURL , clusterctlConfigPath string ) (string , string ) {
771
808
clusterctlBinaryPath := downloadToTmpFile (ctx , clusterctlBinaryURL )
772
809
0 commit comments