Skip to content

integration/bundle: install Terraform locally so tests bypass registry.terraform.io#5175

Draft
shreyas-goenka wants to merge 1 commit intomainfrom
shreyas-goenka/install-terraform-integration
Draft

integration/bundle: install Terraform locally so tests bypass registry.terraform.io#5175
shreyas-goenka wants to merge 1 commit intomainfrom
shreyas-goenka/install-terraform-integration

Conversation

@shreyas-goenka
Copy link
Copy Markdown
Contributor

Summary

The Databricks-internal CI runners can't reach `registry.terraform.io`, so deploy-touching integration tests in `integration/bundle` (`TestGenerateFromExistingJobAndDeploy`, `TestGenerateFromExistingPipelineAndDeploy`, `TestSparkJarTaskDeployAndRunOn{Volumes,Workspace}`) fail inside `terraform init`:

```
Could not retrieve the list of available versions for provider
databricks/databricks: could not connect to registry.terraform.io: ... EOF
```

`acceptance/install_terraform.py` already exists and stages Terraform 1.5.5 + the matching Databricks provider into a local filesystem mirror, and the CLI already honors `DATABRICKS_TF_CLI_CONFIG_FILE` (see `bundle/deploy/terraform/init.go:195`). This PR wires that into the `integration/bundle` package via TestMain so deploy tests use the local mirror instead of going to registry.terraform.io.

Changes

  • `internal/testutil/terraform.go` — `SetupTerraform()` runs `install_terraform.py` against `acceptance/build/{GOOS}_{GOARCH}` and exports `TF_CLI_CONFIG_FILE`, `DATABRICKS_TF_CLI_CONFIG_FILE`, `DATABRICKS_TF_EXEC_PATH`, `TERRAFORM`.
  • `integration/bundle/main_test.go` — `TestMain` calls `SetupTerraform()` once per package run before any test executes.

Same setup works for `go test ./integration/bundle/...` on a laptop and in CI.

Test plan

  • `go test ./integration/bundle/... -run TestNonExistent` triggers TestMain, downloads terraform + provider 1.113.0, writes `.terraformrc` with the filesystem_mirror block.
  • CLOUD_ENV-gated tests still skip without a workspace (TestMain runs first).
  • Run the previously-failing tests on aws-prod-ucws and confirm `terraform init` succeeds.
  • Next `cli-isolated-nightly` run shows `TestGenerateFromExistingJobAndDeploy` etc. passing.

This pull request was AI-assisted by Isaac.

The Databricks-internal CI runners that execute these tests cannot reach
registry.terraform.io, so `bundle deploy` inside tests like
TestGenerateFromExistingJobAndDeploy fails inside `terraform init` with:

    Could not retrieve the list of available versions for provider
    databricks/databricks: could not connect to registry.terraform.io: ... EOF

acceptance/install_terraform.py already exists and downloads Terraform 1.5.5
plus the matching Databricks provider into a local filesystem mirror
(driven from `acceptance` tests). Wire it into the integration/bundle
package via a new TestMain and a small testutil helper:

- internal/testutil/terraform.go: SetupTerraform() invokes the script
  against acceptance/build/{GOOS}_{GOARCH} and exports
  TF_CLI_CONFIG_FILE / DATABRICKS_TF_CLI_CONFIG_FILE /
  DATABRICKS_TF_EXEC_PATH / TERRAFORM. The CLI's existing
  getEnvVarWithMatchingVersion path picks these up (init.go:195) and
  routes terraform init at the local mirror instead of registry.terraform.io.
- integration/bundle/main_test.go: TestMain calls SetupTerraform() once
  per package run before any test executes. Same setup runs for `go test
  ./integration/bundle/...` on a developer laptop and in CI.

Verified locally: `go test ./integration/bundle/... -run TestNonExistent`
runs TestMain, downloads terraform + provider 1.113.0 to
acceptance/build/darwin_arm64/, and writes the .terraformrc with the
filesystem_mirror block. CLOUD_ENV-gated tests still skip without a
workspace, but TestMain has already staged Terraform by then.

Co-authored-by: Isaac
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.

1 participant