From cae443bda32b2f1d6dc12cea427376ebe09620ad Mon Sep 17 00:00:00 2001 From: Knative Automation Date: Thu, 11 Apr 2024 01:56:08 +0000 Subject: [PATCH] upgrade to latest dependencies bumping knative.dev/networking ca2ffb8...a3d8b0f: > a3d8b0f Replace all usages of deprecated wait.PollImmediate with wait.PollUntilContextTimeout (# 957) > 1a6e0da some conformance tests assume we're getting back a runtime request (# 964) > 2a4859c this fixes the probe handler to reflect that it doesn't care about the path (# 963) > b321831 upgrade to latest dependencies (# 962) > 2002961 :gift: Add test flags for the conformance suite (# 960) Signed-off-by: Knative Automation --- go.mod | 2 +- go.sum | 4 +- .../networking/pkg/prober/prober.go | 2 +- .../test/conformance/ingress/basic.go | 8 ++-- .../test/conformance/ingress/class.go | 2 +- .../test/conformance/ingress/grpc.go | 4 +- .../test/conformance/ingress/headers.go | 44 ++++++++++--------- .../test/conformance/ingress/httpoption.go | 2 +- .../test/conformance/ingress/path.go | 8 ++-- .../test/conformance/ingress/percentage.go | 4 +- .../test/conformance/ingress/retry.go | 2 +- .../test/conformance/ingress/rule.go | 8 ++-- .../test/conformance/ingress/timeout.go | 13 ++++-- .../test/conformance/ingress/tls.go | 6 +-- .../test/conformance/ingress/update.go | 12 ++--- .../test/conformance/ingress/util.go | 14 ++++-- .../test/conformance/ingress/visibility.go | 6 +-- .../test/conformance/ingress/websocket.go | 4 +- .../knative.dev/networking/test/e2e_flags.go | 12 +++++ vendor/knative.dev/networking/test/ingress.go | 2 +- .../test_images/runtime/handlers/handler.go | 5 +-- .../test/test_images/runtime/main.go | 7 ++- vendor/modules.txt | 2 +- 23 files changed, 102 insertions(+), 71 deletions(-) diff --git a/go.mod b/go.mod index 4f4d06230..5c61ff898 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( k8s.io/apimachinery v0.29.3 k8s.io/client-go v0.29.3 knative.dev/hack v0.0.0-20240404013450-1133b37da8d7 - knative.dev/networking v0.0.0-20240409134343-ca2ffb806de2 + knative.dev/networking v0.0.0-20240410205709-a3d8b0fc9cd2 knative.dev/pkg v0.0.0-20240409141558-1ff9a77566f6 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 8b45300b4..77aeb9c81 100644 --- a/go.sum +++ b/go.sum @@ -692,8 +692,8 @@ k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCf k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= knative.dev/hack v0.0.0-20240404013450-1133b37da8d7 h1:fkWYWvdHm1mVHevKW2vVJnZtxH0NzOlux8imesweKwE= knative.dev/hack v0.0.0-20240404013450-1133b37da8d7/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= -knative.dev/networking v0.0.0-20240409134343-ca2ffb806de2 h1:Sjr1rJ97ow6ipuLSGnR2EZFcVnwMRdVpjgMzVdGvv/U= -knative.dev/networking v0.0.0-20240409134343-ca2ffb806de2/go.mod h1:m9aH65g5JGuwhH6moqAmF0+X6PvIQwElVx5dw2+jDno= +knative.dev/networking v0.0.0-20240410205709-a3d8b0fc9cd2 h1:W8M/cxPYUOIjNcwQ3w2Il/qlYKpZBPJ89ysTr5MTI/A= +knative.dev/networking v0.0.0-20240410205709-a3d8b0fc9cd2/go.mod h1:yXbBRuzGKDkHSdvqUT7/1j9br5gkJL9LAyxpHfcF3h8= knative.dev/pkg v0.0.0-20240409141558-1ff9a77566f6 h1:jJVStFc+y8c7veKYDyQFwQTod+w5pzZqopz/nLH2dJo= knative.dev/pkg v0.0.0-20240409141558-1ff9a77566f6/go.mod h1:ZWUA+Z6zFI93VyExtnH0P5JtVQ0TvWpKvbxtFvmRJ9I= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/networking/pkg/prober/prober.go b/vendor/knative.dev/networking/pkg/prober/prober.go index ec9330606..42d5b36eb 100644 --- a/vendor/knative.dev/networking/pkg/prober/prober.go +++ b/vendor/knative.dev/networking/pkg/prober/prober.go @@ -186,7 +186,7 @@ func (m *Manager) doAsync(ctx context.Context, target string, arg interface{}, p result bool inErr error ) - err := wait.PollImmediate(period, timeout, func() (bool, error) { + err := wait.PollUntilContextTimeout(ctx, period, timeout, true, func(ctx context.Context) (bool, error) { result, inErr = Do(ctx, m.transport, target, ops...) // Do not return error, which is from verifierError, as retry is expected until timeout. return result, nil diff --git a/vendor/knative.dev/networking/test/conformance/ingress/basic.go b/vendor/knative.dev/networking/test/conformance/ingress/basic.go index 11c476c56..81dd4a139 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/basic.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/basic.go @@ -36,7 +36,7 @@ func TestBasics(t *testing.T) { // Create a simple Ingress over the Service. _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -52,7 +52,7 @@ func TestBasics(t *testing.T) { }}, }) - RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) } // TestBasicsHTTP2 verifies that the same no-frills Ingress over a Service with http/2 configured @@ -69,7 +69,7 @@ func TestBasicsHTTP2(t *testing.T) { // Create a simple Ingress over the Service. _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -85,7 +85,7 @@ func TestBasicsHTTP2(t *testing.T) { }}, }) - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) if ri == nil { return } diff --git a/vendor/knative.dev/networking/test/conformance/ingress/class.go b/vendor/knative.dev/networking/test/conformance/ingress/class.go index 2f0ceb776..2a2142500 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/class.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/class.go @@ -79,7 +79,7 @@ func verifyIngressWithAnnotations(ctx context.Context, t *testing.T, clients *te original, _ := CreateIngress(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{backend.ServiceName + ".example.com"}, + Hosts: []string{backend.ServiceName + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ diff --git a/vendor/knative.dev/networking/test/conformance/ingress/grpc.go b/vendor/knative.dev/networking/test/conformance/ingress/grpc.go index 90485c030..27cbcfd22 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/grpc.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/grpc.go @@ -43,7 +43,7 @@ func TestGRPC(t *testing.T) { const suffix = "- pong" name, port, _ := CreateGRPCService(ctx, t, clients, suffix) - domain := name + ".example.com" + domain := name + "." + test.NetworkingFlags.ServiceDomain // Create a simple Ingress over the Service. _, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{ @@ -106,7 +106,7 @@ func TestGRPCSplit(t *testing.T) { // Create a simple Ingress over the Service. name := test.ObjectNameForTest(t) - domain := name + ".example.com" + domain := name + "." + test.NetworkingFlags.ServiceDomain _, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ Hosts: []string{domain}, diff --git a/vendor/knative.dev/networking/test/conformance/ingress/headers.go b/vendor/knative.dev/networking/test/conformance/ingress/headers.go index 57617cdd5..83c2c6522 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/headers.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/headers.go @@ -43,7 +43,7 @@ func TestProbeHeaders(t *testing.T) { // Create a simple Ingress over the Service. ing, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -83,21 +83,25 @@ func TestProbeHeaders(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - ros := []RequestOption{} + req, err := http.NewRequest("GET", fmt.Sprintf("http://%s.%s", name, test.NetworkingFlags.ServiceDomain), nil) + if err != nil { + t.Fatal("Error creating request:", err) + } + req.Header.Set(header.ProbeKey, header.ProbeValue) + req.Header.Set(header.HashKey, tt.req) - ros = append(ros, func(r *http.Request) { - // Add the header to indicate this is a probe request. - r.Header.Set(header.ProbeKey, header.ProbeValue) - r.Header.Set(header.HashKey, tt.req) - }) + resp, err := client.Do(req) + if err != nil { + t.Fatal("Error making GET request:", err) + } + defer resp.Body.Close() - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", ros...) - if ri == nil { - t.Error("Couldn't make request") - return + if resp.StatusCode != http.StatusOK { + t.Errorf("Unexpected status code: %d, wanted %d", resp.StatusCode, http.StatusOK) + DumpResponse(ctx, t, resp) } - if got, want := ri.Request.Headers.Get(header.HashKey), tt.want; got != want { + if got, want := resp.Header.Get(header.HashKey), tt.want; got != want { t.Errorf("Header[%q] = %q, wanted %q", header.HashKey, got, want) } }) @@ -124,7 +128,7 @@ func TestTagHeaders(t *testing.T) { _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -195,7 +199,7 @@ func TestTagHeaders(t *testing.T) { }) } - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", ros...) + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, ros...) if ri == nil { t.Error("Couldn't make request") return @@ -221,7 +225,7 @@ func TestPreSplitSetHeaders(t *testing.T) { // Create a simple Ingress over the 10 Services. _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -243,7 +247,7 @@ func TestPreSplitSetHeaders(t *testing.T) { t.Run("Check without passing header", func(t *testing.T) { t.Parallel() - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) if ri == nil { return } @@ -256,7 +260,7 @@ func TestPreSplitSetHeaders(t *testing.T) { t.Run("Check with passing header", func(t *testing.T) { t.Parallel() - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", func(req *http.Request) { + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, func(req *http.Request) { // Specify a value for the header to verify that implementations // use set vs. append semantics. req.Header.Set(headerName, "bogus") @@ -306,7 +310,7 @@ func TestPostSplitSetHeaders(t *testing.T) { name := test.ObjectNameForTest(t) _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -324,7 +328,7 @@ func TestPostSplitSetHeaders(t *testing.T) { // particular test. seen := make(sets.Set[string], len(names)) for i := 0; i < maxRequests; i++ { - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) if ri == nil { return } @@ -347,7 +351,7 @@ func TestPostSplitSetHeaders(t *testing.T) { // particular test. seen := make(sets.Set[string], len(names)) for i := 0; i < maxRequests; i++ { - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com", func(req *http.Request) { + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, func(req *http.Request) { // Specify a value for the header to verify that implementations // use set vs. append semantics. req.Header.Set(headerName, "bogus") diff --git a/vendor/knative.dev/networking/test/conformance/ingress/httpoption.go b/vendor/knative.dev/networking/test/conformance/ingress/httpoption.go index ce421c07a..0d66e4b10 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/httpoption.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/httpoption.go @@ -68,7 +68,7 @@ func TestHTTPOption(t *testing.T) { func create(ctx context.Context, t *testing.T, clients *test.Clients, httpOption v1alpha1.HTTPOption) (string, *http.Client) { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) - hosts := []string{name + ".example.com"} + hosts := []string{name + "." + test.NetworkingFlags.ServiceDomain} secretName, tlsConfig, _ := CreateTLSSecret(ctx, t, clients, hosts) diff --git a/vendor/knative.dev/networking/test/conformance/ingress/path.go b/vendor/knative.dev/networking/test/conformance/ingress/path.go index b00507573..101aeeb34 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/path.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/path.go @@ -51,7 +51,7 @@ func TestPath(t *testing.T) { _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -131,7 +131,7 @@ func TestPath(t *testing.T) { t.Run(path, func(t *testing.T) { t.Parallel() - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com"+path) + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain+path) if ri == nil { return } @@ -159,7 +159,7 @@ func TestPathAndPercentageSplit(t *testing.T) { _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -217,7 +217,7 @@ func TestPathAndPercentageSplit(t *testing.T) { for i := 0; i < total; i++ { g.Go(func() error { - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com/foo") + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain+"/foo") if ri == nil { return errors.New("failed to request") } diff --git a/vendor/knative.dev/networking/test/conformance/ingress/percentage.go b/vendor/knative.dev/networking/test/conformance/ingress/percentage.go index 2ebae2bed..228a0fe55 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/percentage.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/percentage.go @@ -74,7 +74,7 @@ func TestPercentage(t *testing.T) { name := test.ObjectNameForTest(t) _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -103,7 +103,7 @@ func TestPercentage(t *testing.T) { for i := 0.0; i < totalRequests; i++ { g.Go(func() error { - ri := RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) if ri == nil { return errors.New("failed to request") } diff --git a/vendor/knative.dev/networking/test/conformance/ingress/retry.go b/vendor/knative.dev/networking/test/conformance/ingress/retry.go index 00e7d4ba9..c3ec7526c 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/retry.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/retry.go @@ -31,7 +31,7 @@ func TestRetry(t *testing.T) { t.Parallel() ctx, clients := context.Background(), test.Setup(t) name, port, _ := CreateRetryService(ctx, t, clients) - domain := name + ".example.com" + domain := name + "." + test.NetworkingFlags.ServiceDomain // Create a simple Ingress over the Service. _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ diff --git a/vendor/knative.dev/networking/test/conformance/ingress/rule.go b/vendor/knative.dev/networking/test/conformance/ingress/rule.go index 607abfd05..4a76c88b7 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/rule.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/rule.go @@ -39,7 +39,7 @@ func TestRule(t *testing.T) { _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{fooName + ".example.com"}, + Hosts: []string{fooName + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -58,7 +58,7 @@ func TestRule(t *testing.T) { }}, }, }, { - Hosts: []string{barName + ".example.com"}, + Hosts: []string{barName + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -77,12 +77,12 @@ func TestRule(t *testing.T) { }}, }) - ri := RuntimeRequest(ctx, t, client, "http://"+fooName+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+fooName+"."+test.NetworkingFlags.ServiceDomain) if got := ri.Request.Headers.Get(headerName); got != fooName { t.Errorf("Header[Host] = %q, wanted %q", got, fooName) } - ri = RuntimeRequest(ctx, t, client, "http://"+barName+".example.com") + ri = RuntimeRequest(ctx, t, client, "http://"+barName+"."+test.NetworkingFlags.ServiceDomain) if got := ri.Request.Headers.Get(headerName); got != barName { t.Errorf("Header[Host] = %q, wanted %q", got, barName) } diff --git a/vendor/knative.dev/networking/test/conformance/ingress/timeout.go b/vendor/knative.dev/networking/test/conformance/ingress/timeout.go index 4ac531589..4c24ad7ef 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/timeout.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/timeout.go @@ -38,7 +38,7 @@ func TestTimeout(t *testing.T) { // Create a simple Ingress over the Service. _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{name + ".example.com"}, + Hosts: []string{name + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -86,9 +86,16 @@ func TestTimeout(t *testing.T) { func checkTimeout(ctx context.Context, t *testing.T, client *http.Client, name string, code int, initial time.Duration, timeout time.Duration) { t.Helper() + if test.NetworkingFlags.RequestDelay < 0 { + t.Error("Error creating Request:", fmt.Errorf("request delay value must be greater than or equal to 0, receieved %d", test.NetworkingFlags.RequestDelay)) + } + if test.NetworkingFlags.RequestDelay > 0 { + t.Logf("delay of %d before doing the request", test.NetworkingFlags.RequestDelay) + time.Sleep(time.Duration(test.NetworkingFlags.RequestDelay) * time.Second) + } - resp, err := client.Get(fmt.Sprintf("http://%s.example.com?initialTimeout=%d&timeout=%d", - name, initial.Milliseconds(), timeout.Milliseconds())) + resp, err := client.Get(fmt.Sprintf("http://%s.%s?initialTimeout=%d&timeout=%d", + name, test.NetworkingFlags.ServiceDomain, initial.Milliseconds(), timeout.Milliseconds())) if err != nil { t.Fatal("Error making GET request:", err) } diff --git a/vendor/knative.dev/networking/test/conformance/ingress/tls.go b/vendor/knative.dev/networking/test/conformance/ingress/tls.go index 3bbf83b90..27a652eb2 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/tls.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/tls.go @@ -33,7 +33,7 @@ func TestIngressTLS(t *testing.T) { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) - hosts := []string{name + ".example.com"} + hosts := []string{name + "." + test.NetworkingFlags.ServiceDomain} secretName, tlsConfig, _ := CreateTLSSecret(ctx, t, clients, hosts) @@ -61,10 +61,10 @@ func TestIngressTLS(t *testing.T) { }, tlsConfig) // Check without TLS. - RuntimeRequest(ctx, t, client, "http://"+name+".example.com") + RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) // Check with TLS. - RuntimeRequest(ctx, t, client, "https://"+name+".example.com") + RuntimeRequest(ctx, t, client, "https://"+name+"."+test.NetworkingFlags.ServiceDomain) } // TODO(mattmoor): Consider adding variants where we have multiple hosts with distinct certificates. diff --git a/vendor/knative.dev/networking/test/conformance/ingress/update.go b/vendor/knative.dev/networking/test/conformance/ingress/update.go index e58c10310..00a9b092b 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/update.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/update.go @@ -42,7 +42,7 @@ func TestUpdate(t *testing.T) { hostname := test.ObjectNameForTest(t) ing, client, cancel := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{hostname + ".example.com"}, + Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -68,7 +68,7 @@ func TestUpdate(t *testing.T) { firstCancel() } - proberCancel := checkOK(ctx, t, "http://"+hostname+".example.com", client) + proberCancel := checkOK(ctx, t, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain, client) defer func() { proberCancel() previousVersionCancel() @@ -87,7 +87,7 @@ func TestUpdate(t *testing.T) { // Update the Ingress, and wait for it to report ready. UpdateIngressReady(ctx, t, clients, ing.Name, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{hostname + ".example.com"}, + Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -108,7 +108,7 @@ func TestUpdate(t *testing.T) { // Check that it serves the right message as soon as we get "Ready", // but before we stop probing. - ri := RuntimeRequest(ctx, t, client, "http://"+hostname+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain) if ri != nil { if got := ri.Request.Headers.Get(updateHeaderName); got != sentinel { t.Errorf("Header[%q] = %q, wanted %q", updateHeaderName, got, sentinel) @@ -130,7 +130,7 @@ func TestUpdate(t *testing.T) { // Update the Ingress, and wait for it to report ready. UpdateIngressReady(ctx, t, clients, ing.Name, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ - Hosts: []string{hostname + ".example.com"}, + Hosts: []string{hostname + "." + test.NetworkingFlags.ServiceDomain}, Visibility: v1alpha1.IngressVisibilityExternalIP, HTTP: &v1alpha1.HTTPIngressRuleValue{ Paths: []v1alpha1.HTTPIngressPath{{ @@ -151,7 +151,7 @@ func TestUpdate(t *testing.T) { // Check that it serves the right message as soon as we get "Ready", // but before we stop probing. - ri := RuntimeRequest(ctx, t, client, "http://"+hostname+".example.com") + ri := RuntimeRequest(ctx, t, client, "http://"+hostname+"."+test.NetworkingFlags.ServiceDomain) if ri != nil { if got := ri.Request.Headers.Get(updateHeaderName); got != sentinel { t.Errorf("Header[%q] = %q, wanted %q", updateHeaderName, got, sentinel) diff --git a/vendor/knative.dev/networking/test/conformance/ingress/util.go b/vendor/knative.dev/networking/test/conformance/ingress/util.go index 3eb41dadc..687cfc817 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/util.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/util.go @@ -749,7 +749,7 @@ func createPodAndService(ctx context.Context, t *testing.T, clients *test.Client } // Wait for the Pod to show up in the Endpoints resource. - waitErr := wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) { var ep *corev1.Endpoints err := reconciler.RetryTestErrors(func(attempts int) (err error) { ep, err = clients.KubeClient.CoreV1().Endpoints(svc.Namespace).Get(ctx, svc.Name, metav1.GetOptions{}) @@ -1046,7 +1046,6 @@ func CreateDialContext(ctx context.Context, t *testing.T, ing *v1alpha1.Ingress, // TODO(mattmoor): I'm open to tricks that would let us cleanly test multiple // public load balancers or LBs with multiple ingresses (below), but want to // keep our simple tests simple, thus the [0]s... - // We expect an ingress LB with the form foo.bar.svc.cluster.local (though // we aren't strictly sensitive to the suffix, this is just illustrative. internalDomain := ing.Status.PublicLoadBalancer.Ingress[0].DomainInternal @@ -1123,6 +1122,15 @@ func RuntimeRequestWithExpectations(ctx context.Context, t *testing.T, client *h opts ...RequestOption) *types.RuntimeInfo { t.Helper() + if test.NetworkingFlags.RequestDelay < 0 { + t.Error("Error creating Request:", fmt.Errorf("request delay value must be greater than or equal to 0, receieved %d", test.NetworkingFlags.RequestDelay)) + return nil + } + if test.NetworkingFlags.RequestDelay > 0 { + t.Logf("delay of %d before doing the request", test.NetworkingFlags.RequestDelay) + time.Sleep(time.Duration(test.NetworkingFlags.RequestDelay) * time.Second) + } + req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { t.Error("Error creating Request:", err) @@ -1204,7 +1212,7 @@ func WaitForIngressState(ctx context.Context, client *test.NetworkingClients, na defer span.End() var lastState *v1alpha1.Ingress - waitErr := wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) { err := reconciler.RetryTestErrors(func(attempts int) (err error) { lastState, err = client.Ingresses.Get(ctx, name, metav1.GetOptions{}) return err diff --git a/vendor/knative.dev/networking/test/conformance/ingress/visibility.go b/vendor/knative.dev/networking/test/conformance/ingress/visibility.go index 12d90f3dc..e68712f70 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/visibility.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/visibility.go @@ -85,7 +85,7 @@ func testProxyToHelloworld(ctx context.Context, t *testing.T, ingress *v1alpha1. // Using fixed hostnames can lead to conflicts when -count=N>1 // so pseudo-randomize the hostnames to avoid conflicts. - publicHostName := test.ObjectNameForTest(t) + ".publicproxy.example.com" + publicHostName := test.ObjectNameForTest(t) + ".publicproxy." + test.NetworkingFlags.ServiceDomain _, client, _ := CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ @@ -170,7 +170,7 @@ func TestVisibilitySplit(t *testing.T) { loadbalancerAddress := localIngress.Status.PrivateLoadBalancer.Ingress[0].DomainInternal proxyName, proxyPort, _ := CreateProxyService(ctx, t, clients, privateHostName, loadbalancerAddress) - publicHostName := fmt.Sprintf("%s.%s", name, "example.com") + publicHostName := fmt.Sprintf("%s.%s", name, test.NetworkingFlags.ServiceDomain) _, client, _ = CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ Hosts: []string{publicHostName}, @@ -334,7 +334,7 @@ func TestVisibilityPath(t *testing.T) { loadbalancerAddress := localIngress.Status.PrivateLoadBalancer.Ingress[0].DomainInternal proxyName, proxyPort, _ := CreateProxyService(ctx, t, clients, privateHostName, loadbalancerAddress) - publicHostName := fmt.Sprintf("%s.%s", name, "example.com") + publicHostName := fmt.Sprintf("%s.%s", name, test.NetworkingFlags.ServiceDomain) _, client, _ = CreateIngressReady(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ Hosts: []string{publicHostName}, diff --git a/vendor/knative.dev/networking/test/conformance/ingress/websocket.go b/vendor/knative.dev/networking/test/conformance/ingress/websocket.go index 6d1c10660..dbf0c2338 100644 --- a/vendor/knative.dev/networking/test/conformance/ingress/websocket.go +++ b/vendor/knative.dev/networking/test/conformance/ingress/websocket.go @@ -42,7 +42,7 @@ func TestWebsocket(t *testing.T) { const suffix = "- pong" name, port, _ := CreateWebsocketService(ctx, t, clients, suffix) - domain := name + ".example.com" + domain := name + "." + test.NetworkingFlags.ServiceDomain // Create a simple Ingress over the Service. _, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{ @@ -97,7 +97,7 @@ func TestWebsocketSplit(t *testing.T) { // Create a simple Ingress over the Service. name := test.ObjectNameForTest(t) - domain := name + ".example.com" + domain := name + "." + test.NetworkingFlags.ServiceDomain _, dialCtx, _ := createIngressReadyDialContext(ctx, t, clients, v1alpha1.IngressSpec{ Rules: []v1alpha1.IngressRule{{ Hosts: []string{domain}, diff --git a/vendor/knative.dev/networking/test/e2e_flags.go b/vendor/knative.dev/networking/test/e2e_flags.go index ac8f144e4..7200ac7e0 100644 --- a/vendor/knative.dev/networking/test/e2e_flags.go +++ b/vendor/knative.dev/networking/test/e2e_flags.go @@ -44,6 +44,8 @@ type NetworkingEnvironmentFlags struct { EnableBetaFeatures bool // Indicates whether we run tests for beta features SkipTests string // Indicates the test names we want to skip in alpha or beta features. ClusterSuffix string // Specifies the cluster DNS suffix to be used in tests. + ServiceDomain string // Specifies the domain to use when creating the test services. + RequestDelay int // Specifies delay in Seconds before the client tries to dial the service } func initializeNetworkingFlags() *NetworkingEnvironmentFlags { @@ -100,5 +102,15 @@ func initializeNetworkingFlags() *NetworkingEnvironmentFlags { "cluster.local", "Set this flag to the cluster suffix to be used in tests.") + flag.StringVar(&f.ServiceDomain, + "service-domain", + "example.com", + "Set this flag to the domain to be used in tests.") + + flag.IntVar(&f.RequestDelay, + "request-delay", + 0, + "Set this flag to the number of seconds to wait before calling the service.") + return &f } diff --git a/vendor/knative.dev/networking/test/ingress.go b/vendor/knative.dev/networking/test/ingress.go index a8cfd0d14..ef6a3faaa 100644 --- a/vendor/knative.dev/networking/test/ingress.go +++ b/vendor/knative.dev/networking/test/ingress.go @@ -35,7 +35,7 @@ func WaitForIngressState(ctx context.Context, client *NetworkingClients, name st defer span.End() var lastState *v1alpha1.Ingress - waitErr := wait.PollImmediate(PollInterval, PollTimeout, func() (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, PollInterval, PollTimeout, true, func(ctx context.Context) (bool, error) { var err error lastState, err = client.Ingresses.Get(ctx, name, metav1.GetOptions{}) if err != nil { diff --git a/vendor/knative.dev/networking/test/test_images/runtime/handlers/handler.go b/vendor/knative.dev/networking/test/test_images/runtime/handlers/handler.go index 9c96b9ede..76fde7046 100644 --- a/vendor/knative.dev/networking/test/test_images/runtime/handlers/handler.go +++ b/vendor/knative.dev/networking/test/test_images/runtime/handlers/handler.go @@ -24,16 +24,13 @@ import ( "strings" nethttp "knative.dev/networking/pkg/http" - "knative.dev/networking/pkg/http/probe" "knative.dev/pkg/network" ) // InitHandlers initializes all handlers. func InitHandlers(mux *http.ServeMux) { mux.HandleFunc("/", withHeaders(withRequestLog(runtimeHandler))) - - h := probe.NewHandler(withRequestLog(withKubeletProbeHeaderCheck)) - mux.HandleFunc(nethttp.HealthCheckPath, h.ServeHTTP) + mux.HandleFunc(nethttp.HealthCheckPath, withRequestLog(withKubeletProbeHeaderCheck)) } // withRequestLog logs each request before handling it. diff --git a/vendor/knative.dev/networking/test/test_images/runtime/main.go b/vendor/knative.dev/networking/test/test_images/runtime/main.go index b860e7ea7..309a5d9f4 100644 --- a/vendor/knative.dev/networking/test/test_images/runtime/main.go +++ b/vendor/knative.dev/networking/test/test_images/runtime/main.go @@ -22,6 +22,7 @@ import ( "net/http" "os" + "knative.dev/networking/pkg/http/probe" "knative.dev/networking/test" "knative.dev/networking/test/test_images/runtime/handlers" ) @@ -48,11 +49,13 @@ func main() { mux := http.NewServeMux() handlers.InitHandlers(mux) + h := probe.NewHandler(mux) + if cert, key := os.Getenv("CERT"), os.Getenv("KEY"); cert != "" && key != "" { log.Print("Server starting on port with TLS ", port) - test.ListenAndServeTLSGracefullyWithHandler(cert, key, ":"+port, mux) + test.ListenAndServeTLSGracefullyWithHandler(cert, key, ":"+port, h) } else { log.Print("Server starting on port ", port) - test.ListenAndServeGracefullyWithHandler(":"+port, mux) + test.ListenAndServeGracefullyWithHandler(":"+port, h) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 7b60726bb..f5857640f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -901,7 +901,7 @@ k8s.io/utils/trace # knative.dev/hack v0.0.0-20240404013450-1133b37da8d7 ## explicit; go 1.18 knative.dev/hack -# knative.dev/networking v0.0.0-20240409134343-ca2ffb806de2 +# knative.dev/networking v0.0.0-20240410205709-a3d8b0fc9cd2 ## explicit; go 1.21 knative.dev/networking/config knative.dev/networking/pkg