@@ -529,7 +529,7 @@ func assertGatewayClassSuccessful(t *testing.T, name string) (*gatewayapiv1.Gate
529529 // Wait up to 2 minutes for the gateway class to be Accepted.
530530 err := wait .PollUntilContextTimeout (context .Background (), 2 * time .Second , 2 * time .Minute , false , func (context context.Context ) (bool , error ) {
531531 if err := kclient .Get (context , nsName , gwc ); err != nil {
532- t .Logf ("failed to get gateway class %s, retrying..." , name )
532+ t .Logf ("Failed to get gatewayclass %s: %v; retrying..." , name , err )
533533 return false , nil
534534 }
535535 for _ , condition := range gwc .Status .Conditions {
@@ -540,14 +540,15 @@ func assertGatewayClassSuccessful(t *testing.T, name string) (*gatewayapiv1.Gate
540540 }
541541 }
542542 }
543- t .Logf ("found gateway class %s, but it is not yet Accepted. Retrying ..." , name )
543+ t .Logf ("Found gatewayclass %s, but it is not yet accepted; retrying ..." , name )
544544 return false , nil
545545 })
546546 if err != nil {
547- return nil , fmt .Errorf ("gateway class %s not %v, last recorded status message: %s" , name , gatewayapiv1 .GatewayClassConditionStatusAccepted , recordedConditionMsg )
547+ return nil , fmt .Errorf ("gatewayclass %s is not %v; last recorded status message: %s" , name , gatewayapiv1 .GatewayClassConditionStatusAccepted , recordedConditionMsg )
548548 }
549549
550- t .Logf ("gateway class %s successful" , name )
550+ t .Logf ("Observed that gatewayclass %s has been accepted: %+v" , name , gwc .Status )
551+
551552 return gwc , nil
552553}
553554
@@ -562,14 +563,14 @@ func assertGatewaySuccessful(t *testing.T, namespace, name string) (*gatewayapiv
562563
563564 err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
564565 if err := kclient .Get (context , nsName , gw ); err != nil {
565- t .Logf ("failed to get gateway %s, retrying..." , name )
566+ t .Logf ("Failed to get gateway %v: %v; retrying..." , nsName , err )
566567 return false , nil
567568 }
568569 for _ , condition := range gw .Status .Conditions {
569570 if condition .Type == string (gatewayapiv1 .GatewayConditionAccepted ) {
570571 recordedConditionMsg = condition .Message
571572 if condition .Status == metav1 .ConditionTrue {
572- t .Logf ("found gateway %s/%s as Accepted" , namespace , name )
573+ t .Logf ("Found gateway %v as Accepted" , nsName )
573574 return true , nil
574575 }
575576 }
@@ -578,9 +579,11 @@ func assertGatewaySuccessful(t *testing.T, namespace, name string) (*gatewayapiv
578579 })
579580 if err != nil {
580581 t .Logf ("Last observed gateway:\n %s" , util .ToYaml (gw ))
581- return nil , fmt .Errorf ("gateway %s not %v, last recorded status message: %s" , name , gatewayapiv1 .GatewayConditionAccepted , recordedConditionMsg )
582+ return nil , fmt .Errorf ("gateway %v not %v, last recorded status message: %s" , nsName , gatewayapiv1 .GatewayConditionAccepted , recordedConditionMsg )
582583 }
583584
585+ t .Logf ("Observed that gateway %v has been accepted: %+v" , nsName , gw .Status )
586+
584587 return gw , nil
585588}
586589
@@ -598,15 +601,15 @@ func assertHttpRouteSuccessful(t *testing.T, namespace, name string, gateway *ga
598601 // Wait 1 minute for parent/s to update
599602 err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
600603 if err := kclient .Get (context , nsName , httproute ); err != nil {
601- t .Logf ("failed to get httproute %s/%s, retrying..." , namespace , name )
604+ t .Logf ("Failed to get httproute %v: %v; retrying..." , nsName , err )
602605 return false , nil
603606 }
604607 numParents := len (httproute .Status .Parents )
605608 if numParents == 0 {
606- t .Logf ("httpRoute %s/%s has no parent conditions, retrying..." , namespace , name )
609+ t .Logf ("Found no parents in httproute %v with status %+v; retrying..." , nsName , httproute . Status )
607610 return false , nil
608611 }
609- t .Logf ("found httproute %s/%s with %d parent/s" , namespace , name , numParents )
612+ t .Logf ("Found httproute %v with %d parent/s; status: %+v " , nsName , numParents , httproute . Status )
610613 return true , nil
611614 })
612615 if err != nil {
@@ -646,14 +649,15 @@ func assertHttpRouteSuccessful(t *testing.T, namespace, name string, gateway *ga
646649 return nil , fmt .Errorf ("httpRoute %s/%s, parent %v/%v not %v, last recorded status message: %s" , namespace , name , parent .ParentRef .Namespace , parent .ParentRef .Name , gatewayapiv1 .RouteConditionResolvedRefs , resolvedRefConditionMsg )
647650 }
648651 }
649- t .Logf ("httpRoute %s/%s successful" , namespace , name )
652+
653+ t .Logf ("Observed that all parents of httproute %v report accepted and resolved; status: %+v" , nsName , httproute .Status )
654+
650655 return httproute , nil
651656}
652657
653658// assertHttpRouteConnection checks if the http route of the given name replies successfully,
654659// and returns an error if not
655660func assertHttpRouteConnection (t * testing.T , hostname string , gateway * gatewayapiv1.Gateway ) error {
656- t .Helper ()
657661 domain := ""
658662
659663 // Create the http client to check the header.
@@ -676,14 +680,15 @@ func assertHttpRouteConnection(t *testing.T, hostname string, gateway *gatewayap
676680 // Obtain the standard formatting of the dnsRecord.
677681 dnsRecordName := operatorcontroller .GatewayDNSRecordName (gateway , domain )
678682
679- // Make sure the DNSRecord is ready to use.
683+ t . Logf ( "Making sure DNSRecord %v for domain %q is ready to use..." , dnsRecordName , domain )
680684 if err := assertDNSRecord (t , dnsRecordName ); err != nil {
681685 return err
682686 }
683687
684688 // Wait and check that the dns name resolves first. Takes a long time, so
685689 // if the hostname is actually an IP address, skip this.
686690 if net .ParseIP (hostname ) == nil {
691+ t .Logf ("Attempting to resolve %s..." , hostname )
687692 if err := wait .PollUntilContextTimeout (context .Background (), 10 * time .Second , dnsResolutionTimeout , false , func (context context.Context ) (bool , error ) {
688693 _ , err := net .LookupHost (hostname )
689694 if err != nil {
@@ -692,7 +697,7 @@ func assertHttpRouteConnection(t *testing.T, hostname string, gateway *gatewayap
692697 }
693698 return true , nil
694699 }); err != nil {
695- t .Fatalf ("HTTP route name %s was unable to be resolved : %v" , hostname , err )
700+ t .Fatalf ("Failed to resolve host name %s: %v" , hostname , err )
696701 }
697702 }
698703
@@ -701,7 +706,7 @@ func assertHttpRouteConnection(t *testing.T, hostname string, gateway *gatewayap
701706 body string
702707 headers http.Header
703708 )
704- // Wait for http route to respond, and when it does, check for the status code.
709+ t . Logf ( "Probing %s..." , hostname )
705710 if err := wait .PollUntilContextTimeout (context .Background (), 5 * time .Second , 5 * time .Minute , false , func (context context.Context ) (bool , error ) {
706711 var err error
707712 statusCode , headers , body , err = getHTTPResponse (client , hostname )
@@ -713,15 +718,15 @@ func assertHttpRouteConnection(t *testing.T, hostname string, gateway *gatewayap
713718 t .Logf ("GET %s failed: status %v, expected %v, retrying..." , hostname , statusCode , http .StatusOK )
714719 return false , nil // retry on 503 as pod/service may not be ready
715720 }
716- t .Logf ("request to %s was successful" , hostname )
721+ t .Logf ("Request to %s was successful" , hostname )
717722 return true , nil
718723
719724 }); err != nil {
720725 if statusCode != 0 {
721726 t .Log ("Response headers for most recent request:" , headers )
722727 t .Log ("Reponse body for most recent request:" , body )
723728 }
724- t .Fatalf ("error contacting %s's endpoint : %v" , hostname , err )
729+ t .Fatalf ("Error connecting to %s : %v" , hostname , err )
725730 }
726731
727732 return nil
@@ -843,20 +848,21 @@ func assertDNSRecord(t *testing.T, recordName types.NamespacedName) error {
843848
844849 err := wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , 1 * time .Minute , false , func (context context.Context ) (bool , error ) {
845850 if err := kclient .Get (context , recordName , dnsRecord ); err != nil {
846- t .Logf ("failed to get DNSRecord %s/%s : %v, retrying..." , recordName . Namespace , recordName . Name , err )
851+ t .Logf ("Failed to get DNSRecord %v : %v; retrying..." , recordName , err )
847852 return false , nil
848853 }
849854 // Determine the current state of the DNSRecord.
850855 if len (dnsRecord .Status .Zones ) > 0 {
851856 for _ , zone := range dnsRecord .Status .Zones {
852857 for _ , condition := range zone .Conditions {
853858 if condition .Type == v1 .DNSRecordPublishedConditionType && condition .Status == string (metav1 .ConditionTrue ) {
859+ t .Logf ("Found DNSRecord %v %s=%s" , recordName , condition .Type , condition .Status )
854860 return true , nil
855861 }
856862 }
857863 }
858864 }
859- t .Logf ("found DNSRecord %s/%s but could not determine its readiness. Retrying ..." , recordName . Namespace , recordName . Name )
865+ t .Logf ("Found DNSRecord %v but could not determine its readiness; retrying ..." , recordName )
860866 return false , nil
861867 })
862868 return err
0 commit comments