Skip to content

Commit 541ccd9

Browse files
authored
chore: change e2e testing port (coder#12751)
1 parent 03ab37b commit 541ccd9

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

site/e2e/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Default port from the server
2-
export const defaultPort = 3000;
2+
export const coderPort = process.env.CODER_E2E_PORT
3+
? Number(process.env.CODER_E2E_PORT)
4+
: 3111;
35
export const prometheusPort = 2114;
46

57
// Use alternate ports in case we're running in a Coder Workspace.

site/e2e/helpers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import type {
1212
UpdateTemplateMeta,
1313
} from "api/typesGenerated";
1414
import { TarWriter } from "utils/tar";
15-
import { prometheusPort, agentPProfPort } from "./constants";
16-
import { port } from "./playwright.config";
15+
import { agentPProfPort, coderPort, prometheusPort } from "./constants";
1716
import {
1817
Agent,
1918
type App,
@@ -156,7 +155,7 @@ export const sshIntoWorkspace = async (
156155
env: {
157156
...process.env,
158157
CODER_SESSION_TOKEN: sessionToken,
159-
CODER_URL: "http://localhost:3000",
158+
CODER_URL: `http://localhost:${coderPort}`,
160159
},
161160
});
162161
cp.on("error", (err) => reject(err));
@@ -304,7 +303,7 @@ export const startAgentWithCommand = async (
304303
const cp = spawn(command, [...args, "agent", "--no-reap"], {
305304
env: {
306305
...process.env,
307-
CODER_AGENT_URL: "http://localhost:" + port,
306+
CODER_AGENT_URL: `http://localhost:${coderPort}`,
308307
CODER_AGENT_TOKEN: token,
309308
CODER_AGENT_PPROF_ADDRESS: "127.0.0.1:" + agentPProfPort,
310309
CODER_AGENT_PROMETHEUS_ADDRESS: "127.0.0.1:" + prometheusPort,
@@ -701,7 +700,7 @@ export const updateTemplate = async (
701700
env: {
702701
...process.env,
703702
CODER_SESSION_TOKEN: sessionToken,
704-
CODER_URL: "http://localhost:3000",
703+
CODER_URL: `http://localhost:${coderPort}`,
705704
},
706705
},
707706
);

site/e2e/playwright.config.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { defineConfig } from "@playwright/test";
22
import path from "path";
3-
import { defaultPort, coderdPProfPort, gitAuth } from "./constants";
4-
5-
export const port = process.env.CODER_E2E_PORT
6-
? Number(process.env.CODER_E2E_PORT)
7-
: defaultPort;
3+
import { coderPort, coderdPProfPort, gitAuth } from "./constants";
84

95
export const wsEndpoint = process.env.CODER_E2E_WS_ENDPOINT;
106

@@ -35,7 +31,7 @@ export default defineConfig({
3531
],
3632
reporter: [["./reporter.ts"]],
3733
use: {
38-
baseURL: `http://localhost:${port}`,
34+
baseURL: `http://localhost:${coderPort}`,
3935
video: "retain-on-failure",
4036
...(wsEndpoint
4137
? {
@@ -50,12 +46,12 @@ export default defineConfig({
5046
}),
5147
},
5248
webServer: {
53-
url: `http://localhost:${port}/api/v2/deployment/config`,
49+
url: `http://localhost:${coderPort}/api/v2/deployment/config`,
5450
command:
5551
`go run -tags embed ${coderMain} server ` +
5652
`--global-config $(mktemp -d -t e2e-XXXXXXXXXX) ` +
57-
`--access-url=http://localhost:${port} ` +
58-
`--http-address=localhost:${port} ` +
53+
`--access-url=http://localhost:${coderPort} ` +
54+
`--http-address=localhost:${coderPort} ` +
5955
`--in-memory --telemetry=false ` +
6056
`--dangerous-disable-rate-limits ` +
6157
`--provisioner-daemons 10 ` +

site/e2e/reporter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
import axios from "axios";
1212
import * as fs from "fs/promises";
1313
import type { Writable } from "stream";
14+
import { coderdPProfPort } from "./constants";
1415

1516
class CoderReporter implements Reporter {
1617
config: FullConfig | null = null;
@@ -119,7 +120,7 @@ const filteredServerLogLines = (chunk: string): string[] =>
119120

120121
const exportDebugPprof = async (outputFile: string) => {
121122
const response = await axios.get(
122-
"http://127.0.0.1:6062/debug/pprof/goroutine?debug=1",
123+
`http://127.0.0.1:${coderdPProfPort}/debug/pprof/goroutine?debug=1`,
123124
);
124125
if (response.status !== 200) {
125126
throw new Error(`Error: Received status code ${response.status}`);

0 commit comments

Comments
 (0)