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

tfexec/internal/e2etest: Skip TestShow_noInitEtcdBackend on >=1.3.0 and prereleases #325

Merged
merged 1 commit into from Jul 1, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Jun 30, 2022

Reference: hashicorp/terraform#31326

Fixes the new test failures against Terraform main branch. This also adds testing for the cloud and remote backends, which should be more stable as they are integral to the Terraform experience.

Previously:

$ TFEXEC_E2ETEST_VERSIONS=refs/heads/main go test -count=1 -run='TestShow_noInitEtcdBackend' -v ./tfexec/internal/e2etest
=== RUN   TestShow_noInitEtcdBackend
=== RUN   TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main
    util_test.go:112: caching exec "gitref:refs/heads/main" in dir "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/tfinstall2067874872/gitref-refs-heads-main"
2022/06/30 15:56:57 git_revision.go:88: running terraform pre-clone check (timeout: 1m0s)
2022/06/30 15:56:57 git_revision.go:94: terraform pre-clone check finished
2022/06/30 15:56:57 git_revision.go:123: cloning terraform repository from https://github.com/hashicorp/terraform.git to /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform3971808670 (timeout: 5m0s)
2022/06/30 15:57:37 git_revision.go:136: cloning terraform finished
2022/06/30 15:57:37 git_revision.go:142: terraform repository HEAD is at acb79a75451e39126f1cdc596ff802a91d64d712
2022/06/30 15:57:37 git_revision.go:169: building terraform (timeout: 10m0s)
2022/06/30 15:57:37 go_build.go:55: executing go ["build" "-o" "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7123048666161/terraform"] in "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform3971808670"
2022/06/30 15:57:51 git_revision.go:171: building of terraform finished
    util_test.go:173: [INFO] running Terraform command: /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7123048666161/terraform show -json -no-color
    show_test.go:232: expected error ErrNoInit, got *fmt.wrapError: exit status 1

        Error: Invalid backend type

          on main.tf line 2, in terraform:
           2:   backend "etcd" {

        The "etcd" backend is not supported in Terraform v1.3 or later.
--- FAIL: TestShow_noInitEtcdBackend (55.76s)
    --- FAIL: TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main (55.76s)
FAIL
FAIL    github.com/hashicorp/terraform-exec/tfexec/internal/e2etest     56.060s
FAIL

After change:

$ TFEXEC_E2ETEST_VERSIONS=refs/heads/main go test -count=1 -run='TestShow_noInitEtcdBackend' -v ./tfexec/internal/e2etest
=== RUN   TestShow_noInitEtcdBackend
=== RUN   TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main
    util_test.go:112: caching exec "gitref:refs/heads/main" in dir "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/tfinstall2843106250/gitref-refs-heads-main"
2022/06/30 15:59:17 git_revision.go:88: running terraform pre-clone check (timeout: 1m0s)
2022/06/30 15:59:17 git_revision.go:94: terraform pre-clone check finished
2022/06/30 15:59:17 git_revision.go:123: cloning terraform repository from https://github.com/hashicorp/terraform.git to /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform22313428 (timeout: 5m0s)
2022/06/30 15:59:59 git_revision.go:136: cloning terraform finished
2022/06/30 15:59:59 git_revision.go:142: terraform repository HEAD is at acb79a75451e39126f1cdc596ff802a91d64d712
2022/06/30 15:59:59 git_revision.go:169: building terraform (timeout: 10m0s)
2022/06/30 15:59:59 go_build.go:55: executing go ["build" "-o" "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7122130413204/terraform"] in "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform22313428"
2022/06/30 16:00:12 git_revision.go:171: building of terraform finished
    show_test.go:223: etcd backend was removed in Terraform 1.3, so test is not valid
--- PASS: TestShow_noInitEtcdBackend (56.66s)
    --- SKIP: TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main (56.66s)
PASS
ok      github.com/hashicorp/terraform-exec/tfexec/internal/e2etest     57.704s

…nd prereleases

Reference: hashicorp/terraform#31326

Fixes the new test failures against Terraform `main` branch. This also adds testing for the `cloud` and `remote` backends, which should be more stable as they are integral to the Terraform experience.

Previously:

```console
$ TFEXEC_E2ETEST_VERSIONS=refs/heads/main go test -count=1 -run='TestShow_noInitEtcdBackend' -v ./tfexec/internal/e2etest
=== RUN   TestShow_noInitEtcdBackend
=== RUN   TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main
    util_test.go:112: caching exec "gitref:refs/heads/main" in dir "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/tfinstall2067874872/gitref-refs-heads-main"
2022/06/30 15:56:57 git_revision.go:88: running terraform pre-clone check (timeout: 1m0s)
2022/06/30 15:56:57 git_revision.go:94: terraform pre-clone check finished
2022/06/30 15:56:57 git_revision.go:123: cloning terraform repository from https://github.com/hashicorp/terraform.git to /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform3971808670 (timeout: 5m0s)
2022/06/30 15:57:37 git_revision.go:136: cloning terraform finished
2022/06/30 15:57:37 git_revision.go:142: terraform repository HEAD is at acb79a75451e39126f1cdc596ff802a91d64d712
2022/06/30 15:57:37 git_revision.go:169: building terraform (timeout: 10m0s)
2022/06/30 15:57:37 go_build.go:55: executing go ["build" "-o" "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7123048666161/terraform"] in "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform3971808670"
2022/06/30 15:57:51 git_revision.go:171: building of terraform finished
    util_test.go:173: [INFO] running Terraform command: /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7123048666161/terraform show -json -no-color
    show_test.go:232: expected error ErrNoInit, got *fmt.wrapError: exit status 1

        Error: Invalid backend type

          on main.tf line 2, in terraform:
           2:   backend "etcd" {

        The "etcd" backend is not supported in Terraform v1.3 or later.
--- FAIL: TestShow_noInitEtcdBackend (55.76s)
    --- FAIL: TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main (55.76s)
FAIL
FAIL    github.com/hashicorp/terraform-exec/tfexec/internal/e2etest     56.060s
FAIL
```

After change:

```console
$ TFEXEC_E2ETEST_VERSIONS=refs/heads/main go test -count=1 -run='TestShow_noInitEtcdBackend' -v ./tfexec/internal/e2etest
=== RUN   TestShow_noInitEtcdBackend
=== RUN   TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main
    util_test.go:112: caching exec "gitref:refs/heads/main" in dir "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/tfinstall2843106250/gitref-refs-heads-main"
2022/06/30 15:59:17 git_revision.go:88: running terraform pre-clone check (timeout: 1m0s)
2022/06/30 15:59:17 git_revision.go:94: terraform pre-clone check finished
2022/06/30 15:59:17 git_revision.go:123: cloning terraform repository from https://github.com/hashicorp/terraform.git to /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform22313428 (timeout: 5m0s)
2022/06/30 15:59:59 git_revision.go:136: cloning terraform finished
2022/06/30 15:59:59 git_revision.go:142: terraform repository HEAD is at acb79a75451e39126f1cdc596ff802a91d64d712
2022/06/30 15:59:59 git_revision.go:169: building terraform (timeout: 10m0s)
2022/06/30 15:59:59 go_build.go:55: executing go ["build" "-o" "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-terraform-acb79a75451e39126f1cdc596ff802a91d64d7122130413204/terraform"] in "/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/hc-install-build-terraform22313428"
2022/06/30 16:00:12 git_revision.go:171: building of terraform finished
    show_test.go:223: etcd backend was removed in Terraform 1.3, so test is not valid
--- PASS: TestShow_noInitEtcdBackend (56.66s)
    --- SKIP: TestShow_noInitEtcdBackend/etcd_backend-refs/heads/main (56.66s)
PASS
ok      github.com/hashicorp/terraform-exec/tfexec/internal/e2etest     57.704s
```
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

LGTM, thanks you for the fix! ❤️

@kmoe was suggesting we could create a custom error type for unknown/unsupported backends, but I reckon that can be addressed in a separate PR.

@radeksimko radeksimko merged commit 94d4135 into main Jul 1, 2022
@radeksimko radeksimko deleted the bflad-etcd-backend-removal branch July 1, 2022 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants