Skip to content
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

Improve golden planfile test maintainability #73

Open
kmoe opened this issue Sep 4, 2020 · 2 comments
Open

Improve golden planfile test maintainability #73

kmoe opened this issue Sep 4, 2020 · 2 comments
Labels

Comments

@kmoe
Copy link
Member

kmoe commented Sep 4, 2020

The golden plan file used for Plan tests is specific to OS and Terraform version. Make this easier to maintain across development environments.

@kmoe
Copy link
Member Author

kmoe commented Oct 1, 2020

Some options for doing this:

  1. Make a script that will regenerate the plan files for a given Terraform version and OS, and have devs run this whenever they bump a Terraform version. Script could use Docker to run things under different OSs.
  2. Make a custom CI step, with manual trigger, which can do the same and push the new planfiles to the relevant PR branch.
  3. Relax the check on plan files, so the TerraformVersion doesn't have to match for tests such as TestShowPlanFile013 to pass. The test will still break if the plan file format changes in any other way, which is fine. Probably best in combination with (1) or (2), so the planfiles can be regenerated when the format does change.

@kmoe
Copy link
Member Author

kmoe commented Nov 27, 2020

Step 3 is done, but this is not sufficient, because 0.13 is even stricter about planfile versions: in 0.13 terraform show itself will error (see #93):

--- FAIL: TestShowPlanFile013 (1.56s)
    --- FAIL: TestShowPlanFile013/non_default_planfile_013-0.13.5 (1.56s)
        util_test.go:104: [INFO] running Terraform command: /tmp/tfinstall829262588/v-0.13.5/terraform init -no-color -force-copy -input=false -lock-timeout=0s -backend=true -get=true -get-plugins=true -lock=true -upgrade=false -verify-plugins=true
        util_test.go:104: [INFO] running Terraform command: /tmp/tfinstall829262588/v-0.13.5/terraform show -json -no-color planfilefoo
        show_test.go:311: 
            Error: Invalid plan file
            
            Failed to read plan from plan file: plan file was created by Terraform 0.13.0,
            but this is 0.13.5; plan files cannot be transferred between different
            Terraform versions.

@kmoe kmoe removed their assignment Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant