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

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented May 2, 2024

Opt out supported for "lite" tests. Environment checking happens
to verify terraform + docker exist before running.

The error if you are missing docker (or terraform):

/bin/sh: line 1: docker: command not found
Error: Terraform provisioners require docker & terraform. At least one of these is not present in the runtime environment. To check yourself:
        $ terraform --version
        $ docker --version

Closes #12821

Copy link
Member Author

Emyrk commented May 2, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Emyrk and the rest of your teammates on Graphite Graphite

@Emyrk Emyrk force-pushed the stevenmasley/mem_provisioner branch from da51c9b to 487f0a8 Compare May 2, 2024 23:15
@Emyrk Emyrk force-pushed the stevenmasley/tf_e2e branch from c9cd564 to 9064a9c Compare May 2, 2024 23:15
Base automatically changed from stevenmasley/mem_provisioner to main May 3, 2024 15:14
@Emyrk Emyrk force-pushed the stevenmasley/tf_e2e branch from 4407314 to f4d7c0d Compare May 3, 2024 15:55
@Emyrk Emyrk changed the title chore: terraform provisioners enabled in e2e by default chore: enable terraform provisioners in e2e by default May 3, 2024
Comment on lines -225 to +227
"typescript.tsdk": "./site/node_modules/typescript/lib"
"typescript.tsdk": "./site/node_modules/typescript/lib",
// Playwright tests in VSCode will open a browser to live "view" the test.
"playwright.reuseBrowser": true
Copy link
Member Author

Choose a reason for hiding this comment

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

This is required to run a "live" debugger in VSCode with the chrome window open the whole time. Otherwise the window keeps opening and closing for each snapshot step.

Comment on lines +162 to +166
// StarterTemplates are ids of starter templates that can be used in place of
// the responses payload. These starter templates will require real provisioners.
export enum StarterTemplates {
STARTER_DOCKER = "docker",
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably add ways to add more to the templates later. For now, just using the starter template is easier.

Comment on lines +42 to +44
// Disabling terraform tests is optional for environments without Docker + Terraform.
// By default, we opt into these tests.
export const requireTerraformTests = !process.env.CODER_E2E_DISABLE_TERRAFORM;
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 include this option if the Terraform stuff ever gets a bit messy. Right now for example docker containers are leaky.

Comment on lines +154 to +157
test.skip(
true,
"creating docker containers is currently leaky. They are not cleaned up when the tests are over.",
);
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

@Emyrk Emyrk marked this pull request as ready for review May 3, 2024 17:19
// Will assume the query param has a valid ProvisionerType, as this query param is only used
// in testing.
defaultInitialValues.provisioner_type =
(searchParams.get("provisioner_type") as ProvisionerType) || "terraform";
Copy link
Member

Choose a reason for hiding this comment

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

I'd kind of rather leave this as a string, because we're not doing any validation on it, so it could be anything

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean make provisioner_type a string?

Copy link
Member

Choose a reason for hiding this comment

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

I think the .get here returns string | undefined, and the || narrows it to string, but I think the cast here narrow it more than it should, basically. we don't actually know that the returned value is a valid ProvisionerType here because we didn't check!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is correct. The type of the defaultInitialValues.provisioner_type is ProvisionerType which I would like to keep. Essentially I think adding validation is probably the best approach, but since this is a hidden query param only used in testing, I just skipped it for now. The BE will return a validation error if someone discovers this and tries to do something unsupported.

Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

thanks for addressing things! nothing worth blocking over anymore

@Emyrk Emyrk merged commit a4bd50c into main May 8, 2024
28 checks passed
@Emyrk Emyrk deleted the stevenmasley/tf_e2e branch May 8, 2024 18:34
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an e2e test that uses a real TF provisioner
2 participants