Skip to content

Commit 830c07a

Browse files
committed
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: knative/serving#5157
1 parent e0ac318 commit 830c07a

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

test/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ mode, use
6767
test/local-e2e-tests.sh -short
6868
```
6969

70+
### Running tests with HTTPS
71+
72+
When running tests against a Knative cluster configured with `defaultExternalScheme=https`,
73+
use the `--https` flag to make tests expect HTTPS URLs for services:
74+
75+
```bash
76+
test/local-e2e-tests.sh --https
77+
```
78+
79+
This is particularly useful for the domain mapping tests, which need to know whether
80+
to expect HTTP or HTTPS URLs from services.
81+
7082
### Running E2E tests as a project admin
7183

7284
It is possible to run the E2E tests by a user with reduced privileges, e.g. project admin.

test/e2e/domain_mapping_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ func domainDescribe(r *test.KnRunResultCollector, domainName string, tls bool) {
146146
out := r.KnTest().Kn().Run("domain", "describe", domainName)
147147
r.AssertNoError(out)
148148
var url string
149-
if tls {
149+
// Use HTTPS if either TLS is explicitly configured or the --https flag is set
150+
if tls || ClientFlags.HTTPS {
150151
url = "https://" + domainName
151152
} else {
152153
url = "http://" + domainName

test/e2e/e2e_flags.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright 2025 The Knative Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// This file contains logic to encapsulate flags which are needed to specify
18+
// what cluster, etc. to use for e2e tests.
19+
20+
package e2e
21+
22+
import (
23+
"flag"
24+
25+
// Load the generic flags of knative.dev/pkg too.
26+
_ "knative.dev/pkg/test"
27+
)
28+
29+
// ClientFlags holds the flags or defaults for knative/client settings in the user's environment.
30+
var ClientFlags = initializeClientFlags()
31+
32+
// ClientEnvironmentFlags holds the e2e flags needed only by the client repo.
33+
type ClientEnvironmentFlags struct {
34+
HTTPS bool // Indicates where the test service will be created with https
35+
}
36+
37+
func initializeClientFlags() *ClientEnvironmentFlags {
38+
var f ClientEnvironmentFlags
39+
40+
flag.BoolVar(&f.HTTPS, "https", false,
41+
"Set this flag to true to run all tests with https.")
42+
43+
return &f
44+
}

0 commit comments

Comments
 (0)