@@ -562,27 +562,39 @@ func assertGatewaySuccessful(t *testing.T, namespace, name string) (*gatewayapiv
562562
563563 gw := & gatewayapiv1.Gateway {}
564564 nsName := types.NamespacedName {Namespace : namespace , Name : name }
565- recordedConditionMsg := "not found"
565+ recordedAcceptedConditionMsg , recordedProgrammedConditionMsg := "not found" , "not found"
566566
567567 err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
568568 if err := kclient .Get (context , nsName , gw ); err != nil {
569569 t .Logf ("Failed to get gateway %v: %v; retrying..." , nsName , err )
570570 return false , nil
571571 }
572+ acceptedConditionFound , programmedConditionFound := false , false
572573 for _ , condition := range gw .Status .Conditions {
573574 if condition .Type == string (gatewayapiv1 .GatewayConditionAccepted ) {
574- recordedConditionMsg = condition .Message
575+ recordedAcceptedConditionMsg = condition .Message
575576 if condition .Status == metav1 .ConditionTrue {
576577 t .Logf ("Found gateway %v as Accepted" , nsName )
577- return true , nil
578+ acceptedConditionFound = true
579+ }
580+ }
581+ if condition .Type == string (gatewayapiv1 .GatewayConditionProgrammed ) {
582+ recordedProgrammedConditionMsg = condition .Message
583+ if condition .Status == metav1 .ConditionTrue {
584+ t .Logf ("Found gateway %v as Programmed" , nsName )
585+ programmedConditionFound = true
578586 }
579587 }
580588 }
589+ if acceptedConditionFound && programmedConditionFound {
590+ return true , nil
591+ }
592+ t .Logf ("Not all expected gateway conditions are found, retrying..." )
581593 return false , nil
582594 })
583595 if err != nil {
584596 t .Logf ("Last observed gateway:\n %s" , util .ToYaml (gw ))
585- return nil , fmt .Errorf ("gateway %v not %v , last recorded status message : %s " , nsName , gatewayapiv1 . GatewayConditionAccepted , recordedConditionMsg )
597+ return nil , fmt .Errorf ("gateway %v does not have all expected conditions , last recorded status messages : %q, %q " , nsName , recordedAcceptedConditionMsg , recordedProgrammedConditionMsg )
586598 }
587599
588600 t .Logf ("Observed that gateway %v has been accepted: %+v" , nsName , gw .Status )
@@ -851,21 +863,21 @@ func assertDNSRecord(t *testing.T, recordName types.NamespacedName) error {
851863
852864 err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
853865 if err := kclient .Get (context , recordName , dnsRecord ); err != nil {
854- t .Logf ("Failed to get DNSRecord %v: %v; retrying..." , recordName , err )
866+ t .Logf ("[%s] Failed to get DNSRecord %v: %v; retrying..." , time . Now (). Format ( time . DateTime ) , recordName , err )
855867 return false , nil
856868 }
857869 // Determine the current state of the DNSRecord.
858870 if len (dnsRecord .Status .Zones ) > 0 {
859871 for _ , zone := range dnsRecord .Status .Zones {
860872 for _ , condition := range zone .Conditions {
861873 if condition .Type == v1 .DNSRecordPublishedConditionType && condition .Status == string (metav1 .ConditionTrue ) {
862- t .Logf ("Found DNSRecord %v %s=%s" , recordName , condition .Type , condition .Status )
874+ t .Logf ("[%s] Found DNSRecord %v %s=%s" , time . Now (). Format ( time . DateTime ) , recordName , condition .Type , condition .Status )
863875 return true , nil
864876 }
865877 }
866878 }
867879 }
868- t .Logf ("Found DNSRecord %v but could not determine its readiness; retrying..." , recordName )
880+ t .Logf ("[%s] Found DNSRecord %v but could not determine its readiness; retrying..." , time . Now (). Format ( time . DateTime ) , recordName )
869881 return false , nil
870882 })
871883 return err
0 commit comments