diff --git a/test/conformance/blue_green_test.go b/test/conformance/blue_green_test.go index 2b5fc56b3da9..1a7adbd38a99 100644 --- a/test/conformance/blue_green_test.go +++ b/test/conformance/blue_green_test.go @@ -50,22 +50,6 @@ const ( expectedGreen = "Re-energize yourself with a slice of pepperoni!" ) -// Probe until we get a successful response. This ensures the domain is -// routable before we send it a bunch of traffic. -func probeDomain(logger *logging.BaseLogger, clients *test.Clients, domain string) error { - client, err := pkgTest.NewSpoofingClient(clients.KubeClient, logger, domain, test.ServingFlags.ResolvableDomain) - if err != nil { - return err - } - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", domain), nil) - if err != nil { - return err - } - // TODO(tcnghia): Replace this probing with Status check when we have them. - _, err = client.Poll(req, pkgTest.Retrying(pkgTest.MatchesAny, http.StatusNotFound, http.StatusServiceUnavailable)) - return err -} - // sendRequests sends "num" requests to "domain", returning a string for each spoof.Response.Body. func sendRequests(client spoof.Interface, domain string, num int) ([]string, error) { responses := make([]string, num) @@ -254,7 +238,7 @@ func TestBlueGreenRoute(t *testing.T) { // does not expose a Status, so we rely on probes to know when they are effective. // It doesn't matter which domain we probe, we just need to choose one. logger.Infof("Probing domain %s", tealDomain) - if err := probeDomain(logger, clients, tealDomain); err != nil { + if err := test.ProbeDomain(logger, clients, tealDomain); err != nil { t.Fatalf("Error probing domain %s: %v", tealDomain, err) } diff --git a/test/conformance/single_threaded_test.go b/test/conformance/single_threaded_test.go index 6396c4956d2c..83e565d41106 100644 --- a/test/conformance/single_threaded_test.go +++ b/test/conformance/single_threaded_test.go @@ -81,12 +81,24 @@ func TestSingleConcurrency(t *testing.T) { t.Fatalf("The Revision %q still can't serve traffic: %v", names.Revision, err) } + logger.Info("When the Route reports as Ready, everything should be ready.") + if err := test.WaitForRouteState(clients.ServingClient, names.Route, test.IsRouteReady, "RouteIsReady"); err != nil { + t.Fatalf("The Route %s was not marked as Ready to serve traffic: %v", names.Route, err) + } + route, err := clients.ServingClient.Routes.Get(names.Route, metav1.GetOptions{}) if err != nil { t.Fatalf("Error fetching Route %s: %v", names.Route, err) } domain := route.Status.Domain + // Ready does not actually mean Ready for a Route just yet. + // See https://github.com/knative/serving/issues/1582 + logger.Infof("Probing domain %s", domain) + if err := test.ProbeDomain(logger, clients, domain); err != nil { + t.Fatalf("Error probing domain %s: %v", domain, err) + } + client, err := pkgTest.NewSpoofingClient(clients.KubeClient, logger, domain, test.ServingFlags.ResolvableDomain) if err != nil { t.Fatalf("Error creating spoofing client: %v", err) diff --git a/test/route.go b/test/route.go index e3908fac781c..ed5c2b8f757a 100644 --- a/test/route.go +++ b/test/route.go @@ -45,6 +45,23 @@ func CreateBlueGreenRoute(logger *logging.BaseLogger, clients *Clients, names, b return err } +// ProbeDomain sends requests to a domain until we get a successful +// response. This ensures the domain is routable before we send it a +// bunch of traffic. +func ProbeDomain(logger *logging.BaseLogger, clients *Clients, domain string) error { + client, err := pkgTest.NewSpoofingClient(clients.KubeClient, logger, domain, ServingFlags.ResolvableDomain) + if err != nil { + return err + } + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", domain), nil) + if err != nil { + return err + } + // TODO(tcnghia): Replace this probing with Status check when we have them. + _, err = client.Poll(req, pkgTest.Retrying(pkgTest.MatchesAny, http.StatusNotFound, http.StatusServiceUnavailable)) + return err +} + // RunRouteProber creates and runs a prober as background goroutine to keep polling Route. // It stops when getting an error response from Route. func RunRouteProber(logger *logging.BaseLogger, clients *Clients, domain string) <-chan error {