Skip to content

Commit 0957cb3

Browse files
committed
Run HTTPS E2E tests only when HTTPS endpoint is ready
1 parent 92e5880 commit 0957cb3

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

test/v1/service.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,26 @@ func CreateServiceReady(t testing.TB, clients *test.Clients, names *test.Resourc
114114
if err != nil {
115115
return nil, err
116116
}
117-
return getResourceObjects(t, clients, names, svc)
117+
118+
readinessCheck := IsServiceReady
119+
120+
// When HTTPS is enabled, wait for Service to be Ready with HTTPS URL set to avoid
121+
// connection resets during load testing (see #14435).
122+
if test.ServingFlags.HTTPS {
123+
t.Log("HTTPS mode: waiting for Service Ready with HTTPS URL")
124+
readinessCheck = IsServiceReadyWithHTTPS
125+
}
126+
127+
return getResourceObjects(t, clients, names, svc, readinessCheck)
118128
}
119129

120-
func getResourceObjects(t testing.TB, clients *test.Clients, names *test.ResourceNames, svc *v1.Service) (*ResourceObjects, error) {
130+
func getResourceObjects(
131+
t testing.TB,
132+
clients *test.Clients,
133+
names *test.ResourceNames,
134+
svc *v1.Service,
135+
readinessCheck func(s *v1.Service) (bool, error),
136+
) (*ResourceObjects, error) {
121137
// Populate Route and Configuration Objects with name
122138
names.Route = serviceresourcenames.Route(svc)
123139
names.Config = serviceresourcenames.Configuration(svc)
@@ -126,7 +142,7 @@ func getResourceObjects(t testing.TB, clients *test.Clients, names *test.Resourc
126142
names.Service = svc.Name
127143

128144
t.Log("Waiting for Service to transition to Ready.", "service", names.Service)
129-
if err := WaitForServiceState(clients.ServingClient, names.Service, IsServiceReady, "ServiceIsReady"); err != nil {
145+
if err := WaitForServiceState(clients.ServingClient, names.Service, readinessCheck, "ServiceIsReady"); err != nil {
130146
return nil, err
131147
}
132148

@@ -301,6 +317,26 @@ func IsServiceReady(s *v1.Service) (bool, error) {
301317
return s.IsReady(), nil
302318
}
303319

320+
// IsServiceReadyWithHTTPS checks if the service is Ready and has an HTTPS URL in status.
321+
func IsServiceReadyWithHTTPS(s *v1.Service) (bool, error) {
322+
ready, err := IsServiceReady(s)
323+
if err != nil {
324+
return false, err
325+
}
326+
327+
if !ready {
328+
return false, nil
329+
}
330+
331+
// Service is Ready, now check if HTTPS URL is set
332+
if s.Status.URL == nil {
333+
return false, nil
334+
}
335+
336+
// Only return true when scheme is HTTPS
337+
return s.Status.URL.Scheme == "https", nil
338+
}
339+
304340
// IsServiceFailed will check the status conditions of the service and return true if the service is
305341
// not ready.
306342
func IsServiceFailed(s *v1.Service) (bool, error) {

0 commit comments

Comments
 (0)