- Notifications
You must be signed in to change notification settings - Fork925
fix: use pre-built binary instead ofgo run
in e2e tests#16236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -36,6 +36,7 @@ site/.swc | ||
.gen-golden | ||
# Build | ||
bin/ | ||
build/ | ||
dist/ | ||
out/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -15,7 +15,7 @@ import * as ssh from "ssh2"; | ||
import { TarWriter } from "utils/tar"; | ||
import { | ||
agentPProfPort, | ||
coderBinary, | ||
coderPort, | ||
defaultOrganizationName, | ||
defaultPassword, | ||
@@ -311,12 +311,9 @@ export const createGroup = async (page: Page): Promise<string> => { | ||
export const sshIntoWorkspace = async ( | ||
page: Page, | ||
workspace: string, | ||
binaryPath =coderBinary, | ||
binaryArgs: string[] = [], | ||
): Promise<ssh.Client> => { | ||
const sessionToken = await findSessionToken(page); | ||
return new Promise<ssh.Client>((resolve, reject) => { | ||
const cp = spawn(binaryPath, [...binaryArgs, "ssh", "--stdio", workspace], { | ||
@@ -398,7 +395,7 @@ export const startAgent = async ( | ||
page: Page, | ||
token: string, | ||
): Promise<ChildProcess> => { | ||
return startAgentWithCommand(page, token,coderBinary); | ||
}; | ||
/** | ||
@@ -479,27 +476,21 @@ export const startAgentWithCommand = async ( | ||
}, | ||
}); | ||
cp.stdout.on("data", (data: Buffer) => { | ||
console.info(`[agent][stdout] ${data.toString().replace(/\n$/g, "")}`); | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
}); | ||
cp.stderr.on("data", (data: Buffer) => { | ||
console.info(`[agent][stderr] ${data.toString().replace(/\n$/g, "")}`); | ||
}); | ||
await page | ||
.getByTestId("agent-status-ready") | ||
.waitFor({ state: "visible", timeout:15_000 }); | ||
return cp; | ||
}; | ||
export const stopAgent = async (cp: ChildProcess) => { | ||
// The command `kill` is used to terminate an agent started as a standalone binary. | ||
exec(`kill ${cp.pid}`, (error) => { | ||
if (error) { | ||
throw new Error(`exec error: ${JSON.stringify(error)}`); | ||
} | ||
@@ -922,10 +913,8 @@ export const updateTemplate = async ( | ||
const sessionToken = await findSessionToken(page); | ||
const child = spawn( | ||
coderBinary, | ||
[ | ||
"templates", | ||
"push", | ||
"--test.provisioner", | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { execSync } from "node:child_process"; | ||
import * as path from "node:path"; | ||
export default function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Is there a reason why this is a default function instead of a named one? Not sure if our setup is looking for default exports specifically MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yeah, if you look in playwright.config.ts we specify a it's not safe to do any of this in the playwright.config.ts file directly because that gets executed once per worker (ie. potentially dozens of times per run) | ||
// If running terraform tests, verify the requirements exist in the | ||
// environment. | ||
// | ||
// These execs will throw an error if the status code is non-zero. | ||
// So if both these work, then we can launch terraform provisioners. | ||
let hasTerraform = false; | ||
let hasDocker = false; | ||
try { | ||
execSync("terraform --version"); | ||
hasTerraform = true; | ||
} catch { | ||
/* empty */ | ||
} | ||
try { | ||
execSync("docker --version"); | ||
hasDocker = true; | ||
} catch { | ||
/* empty */ | ||
} | ||
if (!hasTerraform || !hasDocker) { | ||
const msg = `Terraform provisioners require docker & terraform binaries to function. \n${ | ||
hasTerraform | ||
? "" | ||
: "\tThe `terraform` executable is not present in the runtime environment.\n" | ||
}${ | ||
hasDocker | ||
? "" | ||
: "\tThe `docker` executable is not present in the runtime environment.\n" | ||
}`; | ||
throw new Error(msg); | ||
} | ||
if (!process.env.CI) { | ||
console.info("==> make site/e2e/bin/coder"); | ||
execSync("make site/e2e/bin/coder", { | ||
cwd: path.join(__dirname, "../../../"), | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,8 +18,6 @@ test.beforeEach(async ({ page }) => { | ||
}); | ||
test("app", async ({ context, page }) => { | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const appContent = "Hello World"; | ||
const token = randomUUID(); | ||
const srv = http | ||
@@ -64,7 +62,7 @@ test("app", async ({ context, page }) => { | ||
// Wait for the web terminal to open in a new tab | ||
const pagePromise = context.waitForEvent("page"); | ||
await page.getByText(appName).click({ timeout:10_000 }); | ||
const app = await pagePromise; | ||
await app.waitForLoadState("domcontentloaded"); | ||
await app.getByText(appContent).isVisible(); | ||
Uh oh!
There was an error while loading.Please reload this page.