Skip to content

chore: add e2e test for backwards client ssh compatibility #8958

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
{
env: {
...process.env,
CODER_SESSION_TOKEN: sessionToken,
CODER_URL: "http://localhost:3000",
},
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) => {
Expand Down
52 changes: 52 additions & 0 deletions site/e2e/tests/outdatedCLI.spec.ts
Original file line number Diff line number Diff line change
@@ -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()
})
})
})
})