From 830c07a44dcd578b835da5bde804eb98efbaf63d Mon Sep 17 00:00:00 2001 From: Goutham K Date: Sat, 11 Oct 2025 20:57:13 +0000 Subject: [PATCH 1/5] Add --https flag for e2e tests This change introduces a --https flag similar to knative/serving#5157 to allow e2e tests to run correctly when the cluster is configured with defaultExternalScheme=https. Changes: - Add test/e2e/e2e_flags.go with --https flag infrastructure - Update domain_mapping_test.go to respect --https flag when determining expected URL schemes - Update test/README.md with documentation for the new flag The TestDomain test now adapts to cluster configuration: - Without --https: Expects HTTP for regular services, HTTPS for TLS services - With --https: Expects HTTPS for all services (matches defaultExternalScheme=https) This fixes the issue where TestDomain fails when defaultExternalScheme is set to https. Fixes: https://github.com/knative/serving/pull/5157 --- test/README.md | 12 +++++++++ test/e2e/domain_mapping_test.go | 3 ++- test/e2e/e2e_flags.go | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/e2e/e2e_flags.go diff --git a/test/README.md b/test/README.md index 60c0e83c78..83290ea437 100644 --- a/test/README.md +++ b/test/README.md @@ -67,6 +67,18 @@ mode, use test/local-e2e-tests.sh -short ``` +### Running tests with HTTPS + +When running tests against a Knative cluster configured with `defaultExternalScheme=https`, +use the `--https` flag to make tests expect HTTPS URLs for services: + +```bash +test/local-e2e-tests.sh --https +``` + +This is particularly useful for the domain mapping tests, which need to know whether +to expect HTTP or HTTPS URLs from services. + ### Running E2E tests as a project admin It is possible to run the E2E tests by a user with reduced privileges, e.g. project admin. diff --git a/test/e2e/domain_mapping_test.go b/test/e2e/domain_mapping_test.go index 049caf2c49..b7f75c1ca5 100644 --- a/test/e2e/domain_mapping_test.go +++ b/test/e2e/domain_mapping_test.go @@ -146,7 +146,8 @@ func domainDescribe(r *test.KnRunResultCollector, domainName string, tls bool) { out := r.KnTest().Kn().Run("domain", "describe", domainName) r.AssertNoError(out) var url string - if tls { + // Use HTTPS if either TLS is explicitly configured or the --https flag is set + if tls || ClientFlags.HTTPS { url = "https://" + domainName } else { url = "http://" + domainName diff --git a/test/e2e/e2e_flags.go b/test/e2e/e2e_flags.go new file mode 100644 index 0000000000..05927d8764 --- /dev/null +++ b/test/e2e/e2e_flags.go @@ -0,0 +1,44 @@ +/* +Copyright 2025 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This file contains logic to encapsulate flags which are needed to specify +// what cluster, etc. to use for e2e tests. + +package e2e + +import ( + "flag" + + // Load the generic flags of knative.dev/pkg too. + _ "knative.dev/pkg/test" +) + +// ClientFlags holds the flags or defaults for knative/client settings in the user's environment. +var ClientFlags = initializeClientFlags() + +// ClientEnvironmentFlags holds the e2e flags needed only by the client repo. +type ClientEnvironmentFlags struct { + HTTPS bool // Indicates where the test service will be created with https +} + +func initializeClientFlags() *ClientEnvironmentFlags { + var f ClientEnvironmentFlags + + flag.BoolVar(&f.HTTPS, "https", false, + "Set this flag to true to run all tests with https.") + + return &f +} From 7d093f8719a0121c709c7bc8483a50c1111e44b4 Mon Sep 17 00:00:00 2001 From: Goutham K Date: Sat, 11 Oct 2025 21:31:35 +0000 Subject: [PATCH 2/5] Refactor e2e_flags.go: clean up comments and improve flag structure --- test/e2e/e2e_flags.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/e2e/e2e_flags.go b/test/e2e/e2e_flags.go index 05927d8764..4b45c4c252 100644 --- a/test/e2e/e2e_flags.go +++ b/test/e2e/e2e_flags.go @@ -22,16 +22,13 @@ package e2e import ( "flag" - // Load the generic flags of knative.dev/pkg too. _ "knative.dev/pkg/test" ) -// ClientFlags holds the flags or defaults for knative/client settings in the user's environment. var ClientFlags = initializeClientFlags() -// ClientEnvironmentFlags holds the e2e flags needed only by the client repo. type ClientEnvironmentFlags struct { - HTTPS bool // Indicates where the test service will be created with https + HTTPS bool } func initializeClientFlags() *ClientEnvironmentFlags { From b09be4562fc43acde3360da1d4deef513d293328 Mon Sep 17 00:00:00 2001 From: Goutham K Date: Sat, 11 Oct 2025 21:34:09 +0000 Subject: [PATCH 3/5] Simplify --https flag documentation Make the description more generic and concise --- test/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/README.md b/test/README.md index 83290ea437..ce8a1f4b18 100644 --- a/test/README.md +++ b/test/README.md @@ -69,15 +69,13 @@ test/local-e2e-tests.sh -short ### Running tests with HTTPS -When running tests against a Knative cluster configured with `defaultExternalScheme=https`, -use the `--https` flag to make tests expect HTTPS URLs for services: +When running tests against a cluster configured to use HTTPS, use the `--https` flag to make tests expect HTTPS URLs: ```bash test/local-e2e-tests.sh --https ``` -This is particularly useful for the domain mapping tests, which need to know whether -to expect HTTP or HTTPS URLs from services. + ### Running E2E tests as a project admin From 9e7320f32ea2abb2f8b2411d73e7f9a23e2f3698 Mon Sep 17 00:00:00 2001 From: Goutham K Date: Sat, 11 Oct 2025 21:34:45 +0000 Subject: [PATCH 4/5] Remove redundant blank lines in HTTPS tests section of README --- test/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/README.md b/test/README.md index ce8a1f4b18..dc337a8a8f 100644 --- a/test/README.md +++ b/test/README.md @@ -75,8 +75,6 @@ When running tests against a cluster configured to use HTTPS, use the `--https` test/local-e2e-tests.sh --https ``` - - ### Running E2E tests as a project admin It is possible to run the E2E tests by a user with reduced privileges, e.g. project admin. From a8af4a475195a4293af1c45fc63276a610271f48 Mon Sep 17 00:00:00 2001 From: Goutham K Date: Sun, 12 Oct 2025 01:44:18 +0000 Subject: [PATCH 5/5] doc update --- test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index dc337a8a8f..ccc834af40 100644 --- a/test/README.md +++ b/test/README.md @@ -72,7 +72,7 @@ test/local-e2e-tests.sh -short When running tests against a cluster configured to use HTTPS, use the `--https` flag to make tests expect HTTPS URLs: ```bash -test/local-e2e-tests.sh --https + test/local-e2e-tests.sh --https ``` ### Running E2E tests as a project admin