Skip to content

chore: enable terraform provisioners in e2e by default #13134

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 24 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
create e2e terraform test with docker template
  • Loading branch information
Emyrk committed May 3, 2024
commit 50501e88d1156f893dba0587ed7b84da8bf5a6a1
5 changes: 4 additions & 1 deletion site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ export const createTemplate = async (
): Promise<string> => {
// Required to have templates submit their provisioner type as echo!
await page.addInitScript({
content: "window.playwright = true",
content: `window.playwrightProvisionerType = ${
// Starter templates use the terraform type.
isStarterTemplate(responses) ? "terraform" : "echo"
}`,
});

let path = "/templates/new";
Expand Down
2 changes: 1 addition & 1 deletion site/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default defineConfig({
`go run -tags embed ${coderMain} server`,
"--global-config $(mktemp -d -t e2e-XXXXXXXXXX)",
`--access-url=http://localhost:${coderPort}`,
`--http-address=localhost:${coderPort}`,
`--http-address=0.0.0.0:${coderPort}`,
"--in-memory",
"--telemetry=false",
"--dangerous-disable-rate-limits",
Expand Down
41 changes: 33 additions & 8 deletions site/e2e/tests/createWorkspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,42 @@ test("create workspace with disable_param search params", async ({ page }) => {
await expect(page.getByLabel(/Second parameter/i)).toBeDisabled();
});

test("docker based workspace", async ({ page }) => {
test("create docker workspace", async ({ page }) => {
test.skip(
true,
"creating docker containers is currently leaky. They are not cleaned up when the tests are over.",
);
Comment on lines +155 to +158
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to resolve this in another PR. Terraform provisioners are now working, just need to do some cleanup before I allow this test into the mainstage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked here: #13163

requiresTerraform();
const templateName = await createTemplate(
page,
StarterTemplates.STARTER_DOCKER,
const template = await createTemplate(page, StarterTemplates.STARTER_DOCKER);

const _ = await createWorkspace(page, template);

// The workspace agents must be ready before we try to interact with the workspace.
await page.waitForSelector(
`//div[@role="status"][@data-testid="agent-status-ready"]`,
{
state: "visible",
},
);

await page.goto(`/templates/${templateName}/workspace`, {
waitUntil: "domcontentloaded",
// Wait for the terminal button to be visible, and click it.
const terminalButton =
"//a[@data-testid='terminal'][normalize-space()='Terminal']";
await page.waitForSelector(terminalButton, {
state: "visible",
});

await expect(page.getByLabel(/First parameter/i)).toBeDisabled();
await expect(page.getByLabel(/Second parameter/i)).toBeDisabled();
// We can't click the terminal button because that opens a new tab.
// So grab the href, and manually navigate.
const terminalPageURL = await page.getAttribute(terminalButton, "href");
expect(terminalPageURL).not.toBeNull();
await page.goto(terminalPageURL!, {
waitUntil: "domcontentloaded",
});
await page.waitForSelector(
`//textarea[contains(@class,"xterm-helper-textarea")]`,
{
state: "visible",
},
);
});
4 changes: 2 additions & 2 deletions site/src/pages/CreateTemplatePage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { calculateAutostopRequirementDaysValue } from "utils/schedule";
import type { CreateTemplateData } from "./CreateTemplateForm";

const provisioner: ProvisionerType =
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Playwright needs to use a different provisioner type!
typeof (window as any).playwright !== "undefined" ? "echo" : "terraform";
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Playwright might need to use a different provisioner type!
(window as any).playwrightProvisionerType || "terraform";

export const newTemplate = (formData: CreateTemplateData) => {
const { autostop_requirement_days_of_week, autostop_requirement_weeks } =
Expand Down
Loading