Skip to content

Commit bac3a58

Browse files
authored
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
1 parent 73b136e commit bac3a58

File tree

2 files changed

+60
-10
lines changed

2 files changed

+60
-10
lines changed

site/e2e/helpers.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,18 @@ export const createTemplate = async (
6565
export const sshIntoWorkspace = async (
6666
page: Page,
6767
workspace: string,
68+
binaryPath = "go",
69+
binaryArgs = ["run", coderMainPath()],
6870
): Promise<ssh.Client> => {
6971
const sessionToken = await findSessionToken(page)
7072
return new Promise<ssh.Client>((resolve, reject) => {
71-
const cp = spawn(
72-
"go",
73-
["run", coderMainPath(), "ssh", "--stdio", workspace],
74-
{
75-
env: {
76-
...process.env,
77-
CODER_SESSION_TOKEN: sessionToken,
78-
CODER_URL: "http://localhost:3000",
79-
},
73+
const cp = spawn(binaryPath, [...binaryArgs, "ssh", "--stdio", workspace], {
74+
env: {
75+
...process.env,
76+
CODER_SESSION_TOKEN: sessionToken,
77+
CODER_URL: "http://localhost:3000",
8078
},
81-
)
79+
})
8280
cp.on("error", (err) => reject(err))
8381
const proxyStream = new Duplex({
8482
read: (size) => {

site/e2e/tests/outdatedCLI.spec.ts

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { test } from "@playwright/test"
2+
import { randomUUID } from "crypto"
3+
import {
4+
createTemplate,
5+
createWorkspace,
6+
downloadCoderVersion,
7+
sshIntoWorkspace,
8+
startAgent,
9+
} from "../helpers"
10+
11+
const clientVersion = "v0.14.0"
12+
13+
test("ssh with client " + clientVersion, async ({ page }) => {
14+
const token = randomUUID()
15+
const template = await createTemplate(page, {
16+
apply: [
17+
{
18+
complete: {
19+
resources: [
20+
{
21+
agents: [
22+
{
23+
token,
24+
},
25+
],
26+
},
27+
],
28+
},
29+
},
30+
],
31+
})
32+
const workspace = await createWorkspace(page, template)
33+
await startAgent(page, token)
34+
const binaryPath = await downloadCoderVersion(clientVersion)
35+
36+
const client = await sshIntoWorkspace(page, workspace, binaryPath)
37+
await new Promise<void>((resolve, reject) => {
38+
// We just exec a command to be certain the agent is running!
39+
client.exec("exit 0", (err, stream) => {
40+
if (err) {
41+
return reject(err)
42+
}
43+
stream.on("exit", (code) => {
44+
if (code !== 0) {
45+
return reject(new Error(`Command exited with code ${code}`))
46+
}
47+
client.end()
48+
resolve()
49+
})
50+
})
51+
})
52+
})

0 commit comments

Comments
 (0)