Skip to content

Commit 44e35d2

Browse files
committed
fix: revert hostPort to 80/443, use dynamic port in template tests
Revert Kind hostPort mapping back to standard ports 80/443 to avoid breaking existing tests that assume standard ingress ports. Use port 0 in node/typescript integration tests so the OS assigns a free port, preventing EADDRINUSE conflicts regardless of port mapping.
1 parent 1ef2bdf commit 44e35d2

File tree

9 files changed

+8395
-8401
lines changed

9 files changed

+8395
-8401
lines changed

e2e/e2e_config_ci_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ func runGitHubWorkflow(t *testing.T, dir string) {
7878
"-W", ".github/workflows/func-deploy.yaml",
7979
"-s", "KUBECONFIG="+readFile(t, Kubeconfig),
8080
"--var", "REGISTRY_URL="+Registry,
81-
// Use a non-standard port for function test servers to avoid
82-
// conflicting with Kind's hostPort mapping (8080 → container:80).
83-
"--env", "PORT=8082",
8481
)
8582
cmd.Dir = dir
8683
cmd.Stdout = os.Stdout

e2e/e2e_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ const (
8080
// must be properly configured in the cluster's DNS and Knative serving.
8181
DefaultDomain = "localtest.me"
8282

83-
// DefaultHTTPPort is the host port where the cluster's ingress listens for
84-
// HTTP traffic. The cluster.sh script maps containerPort 80 to hostPort 8080
85-
// to avoid requiring CAP_NET_BIND_SERVICE / privileged port access.
86-
// Override with FUNC_E2E_HTTP_PORT.
87-
DefaultHTTPPort = "8080"
83+
// DefaultHTTPPort is the host port where the cluster's ingress listens
84+
// for HTTP traffic. Override with FUNC_E2E_HTTP_PORT.
85+
DefaultHTTPPort = "80"
8886

8987
// DefaultRegistry to use when running the e2e tests. This is the URL
9088
// of the registry created by default when using the cluster.sh script
@@ -136,7 +134,6 @@ var (
136134
Domain string
137135

138136
// HTTPPort is the host port where the cluster ingress serves HTTP traffic.
139-
// The cluster.sh default maps containerPort 80 → hostPort 8080.
140137
// Can be set with FUNC_E2E_HTTP_PORT.
141138
HTTPPort string
142139

generate/zz_filesystem_generated.go

Lines changed: 8383 additions & 8382 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/cluster.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ nodes:
115115
image: kindest/node:${kind_node_version}
116116
extraPortMappings:
117117
- containerPort: 80
118-
hostPort: 8080
118+
hostPort: 80
119119
listenAddress: "127.0.0.1"
120120
- containerPort: 443
121-
hostPort: 8443
121+
hostPort: 443
122122
listenAddress: "127.0.0.1"
123123
- containerPort: 30022
124124
hostPort: 30022

hack/gitlab.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,14 @@ EOF
183183
$KUBECTL wait pod --for=condition=Ready -l '!job-name' -n gitlab --timeout=5m
184184

185185
echo '::group::Waiting for Gitlab'
186-
local -r gitlab_port="${FUNC_E2E_HTTP_PORT:-8080}"
187-
if ! curl --retry 120 -f --retry-all-errors --retry-delay 5 "http://${gitlab_host}:${gitlab_port}"; then
186+
if ! curl --retry 120 -f --retry-all-errors --retry-delay 5 "${gitlab_host}"; then
188187
$KUBECTL logs pod/gitlab -n gitlab
189188
echo '::endgroup::'
190189
return 1
191190
fi
192191
echo
193192
echo '::endgroup::'
194-
echo "the GitLab server is available at: http://${gitlab_host}:${gitlab_port}"
193+
echo "the GitLab server is available at: http://${gitlab_host}"
195194
echo "${green}✅ GitLab${reset}"
196195
}
197196

templates/node/cloudevents/test/integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const message = HTTP.binary(new CloudEvent({
2323
}));
2424

2525
test('Integration: handles a valid event', t => {
26-
start(func).then(server => {
26+
start(func, { port: 0 }).then(server => {
2727
t.plan(5);
2828
request(server)
2929
.post('/')

templates/node/http/test/integration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const errHandler = t => err => {
1212
};
1313

1414
test('Integration: handles an HTTP GET', t => {
15-
start(func).then(server => {
15+
start(func, { port: 0 }).then(server => {
1616
t.plan(2);
1717
request(server)
1818
.get('/?name=tiger')
@@ -27,7 +27,7 @@ test('Integration: handles an HTTP GET', t => {
2727
});
2828

2929
test('Integration: handles an HTTP POST', t => {
30-
start(func).then(server => {
30+
start(func, { port: 0 }).then(server => {
3131
t.plan(2);
3232
request(server)
3333
.post('/')

templates/typescript/cloudevents/test/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const errHandler = (t: Test) => (err: Error) => {
3131
};
3232

3333
test('Integration: handles a valid event', (t) => {
34-
start(func.handle, {} as InvokerOptions).then((server) => {
34+
start(func.handle, { port: 0 } as InvokerOptions).then((server) => {
3535
t.plan(5);
3636
request(server)
3737
.post('/')

templates/typescript/http/test/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const errHandler = (t: Test) => (err: Error) => {
1616
};
1717

1818
test('Integration: handles a valid request', (t) => {
19-
start(func.handle, {} as InvokerOptions).then((server) => {
19+
start(func.handle, { port: 0 } as InvokerOptions).then((server) => {
2020
t.plan(3);
2121
request(server)
2222
.post('/')

0 commit comments

Comments
 (0)