mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
chore: add e2e test for backwards client ssh compatibility (#8958)
* chore: add e2e test for backwards client ssh compatibility This was discussed as part of our regression review for outdated agents, so here is the reverse with an extremely old client. * fmt
This commit is contained in:
@ -65,20 +65,18 @@ export const createTemplate = async (
|
||||
export const sshIntoWorkspace = async (
|
||||
page: Page,
|
||||
workspace: string,
|
||||
binaryPath = "go",
|
||||
binaryArgs = ["run", coderMainPath()],
|
||||
): Promise<ssh.Client> => {
|
||||
const sessionToken = await findSessionToken(page)
|
||||
return new Promise<ssh.Client>((resolve, reject) => {
|
||||
const cp = spawn(
|
||||
"go",
|
||||
["run", coderMainPath(), "ssh", "--stdio", workspace],
|
||||
{
|
||||
const cp = spawn(binaryPath, [...binaryArgs, "ssh", "--stdio", workspace], {
|
||||
env: {
|
||||
...process.env,
|
||||
CODER_SESSION_TOKEN: sessionToken,
|
||||
CODER_URL: "http://localhost:3000",
|
||||
},
|
||||
},
|
||||
)
|
||||
})
|
||||
cp.on("error", (err) => reject(err))
|
||||
const proxyStream = new Duplex({
|
||||
read: (size) => {
|
||||
|
52
site/e2e/tests/outdatedCLI.spec.ts
Normal file
52
site/e2e/tests/outdatedCLI.spec.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import { test } from "@playwright/test"
|
||||
import { randomUUID } from "crypto"
|
||||
import {
|
||||
createTemplate,
|
||||
createWorkspace,
|
||||
downloadCoderVersion,
|
||||
sshIntoWorkspace,
|
||||
startAgent,
|
||||
} from "../helpers"
|
||||
|
||||
const clientVersion = "v0.14.0"
|
||||
|
||||
test("ssh with client " + clientVersion, async ({ page }) => {
|
||||
const token = randomUUID()
|
||||
const template = await createTemplate(page, {
|
||||
apply: [
|
||||
{
|
||||
complete: {
|
||||
resources: [
|
||||
{
|
||||
agents: [
|
||||
{
|
||||
token,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
const workspace = await createWorkspace(page, template)
|
||||
await startAgent(page, token)
|
||||
const binaryPath = await downloadCoderVersion(clientVersion)
|
||||
|
||||
const client = await sshIntoWorkspace(page, workspace, binaryPath)
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// We just exec a command to be certain the agent is running!
|
||||
client.exec("exit 0", (err, stream) => {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
}
|
||||
stream.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
return reject(new Error(`Command exited with code ${code}`))
|
||||
}
|
||||
client.end()
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user