Skip to content
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
chore: terraform provisioners enabled in e2e by default
Opt out supported for "lite" tests. Environment checking happens
to verify terraform + docker exist before running.
  • Loading branch information
Emyrk committed May 3, 2024
commit e82b2c34dc8e79b499a21267aebaaeb6c5831c0f
6 changes: 6 additions & 0 deletions site/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const requireEnterpriseTests = Boolean(
);
export const enterpriseLicense = process.env.CODER_E2E_ENTERPRISE_LICENSE ?? "";

// Disabling terraform tests is optional for environments without Docker + Terraform.
// By default, we opt into these tests.
export const requireTerraformTests = !Boolean(
process.env.CODER_E2E_DISABLE_TERRAFORM,
);

// Fake experiments to verify that site presents them as enabled.
export const e2eFakeExperiment1 = "e2e-fake-experiment-1";
export const e2eFakeExperiment2 = "e2e-fake-experiment-2";
12 changes: 11 additions & 1 deletion site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
coderPort,
enterpriseLicense,
prometheusPort,
requireEnterpriseTests,
requireEnterpriseTests, requireTerraformTests,
} from "./constants";
import { expectUrl } from "./expectUrl";
import {
Expand All @@ -43,6 +43,16 @@ export function requiresEnterpriseLicense() {
test.skip(!enterpriseLicense);
}

// requiresTerraform by default is enabled.
export function requiresTerraform() {
if (requireTerraformTests) {
return;
}

test.skip(!requireTerraformTests);
}


// createWorkspace creates a workspace for a template.
// It does not wait for it to be running, but it does navigate to the page.
export const createWorkspace = async (
Expand Down
25 changes: 23 additions & 2 deletions site/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,34 @@ import {
coderdPProfPort,
e2eFakeExperiment1,
e2eFakeExperiment2,
gitAuth,
gitAuth, requireTerraformTests,
} from "./constants";
import {execSync} from "child_process";
import {requiresTerraform} from "./helpers";

export const wsEndpoint = process.env.CODER_E2E_WS_ENDPOINT;

// This is where auth cookies are stored!
export const storageState = path.join(__dirname, ".auth.json");

if(requireTerraformTests) {
try {
// If running terraform tests, verify the requirements exist in the
// environment.
//
// These execs will throw an error if the status code is non-zero.
// So if both these work, then we can launch terraform provisioners.
const terraformExec = execSync('terraform --version')
const dockerExec = execSync('dockser --version')
} catch(e) {
throw new Error("Terraform provisioners require docker & terraform. " +
"At least one of these is not present in the runtime environment. To check yourself:\n" +
"\tterraform --version\n"+
"\tdocker --version")
}
}


const localURL = (port: number, path: string): string => {
return `http://localhost:${port}${path}`;
};
Expand Down Expand Up @@ -60,7 +80,8 @@ export default defineConfig({
"--dangerous-disable-rate-limits",
"--provisioner-daemons 10",
// TODO: Enable some terraform provisioners
"--provisioner-types=echo",
`--provisioner-types=echo${requireTerraformTests ? ",terraform": ""}`,
`--provisioner-daemons=10`,
"--web-terminal-renderer=dom",
"--pprof-enable",
]
Expand Down