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:
Kyle Carberry
2023-08-07 22:36:46 -07:00
committed by GitHub
parent 73b136e3f0
commit bac3a588b3
2 changed files with 60 additions and 10 deletions

View File

@ -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) => {

View 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()
})
})
})
})