Skip to content

[DO NOT MERGE] Testing#5593

Open
tanmay-db wants to merge 8 commits intomainfrom
stack/hosttype-replace
Open

[DO NOT MERGE] Testing#5593
tanmay-db wants to merge 8 commits intomainfrom
stack/hosttype-replace

Conversation

@tanmay-db
Copy link
Copy Markdown
Contributor

@tanmay-db tanmay-db commented Apr 15, 2026

Validating #5592 by removing isTesting check

NO_CHANGELOG=true

@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 15, 2026 13:16 — with GitHub Actions Inactive
@tanmay-db tanmay-db changed the title Stack/hosttype replace [Internal] Replace SDK HostType() with provider-owned HostTypeForTerraform() Apr 15, 2026
@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 15, 2026 13:26 — with GitHub Actions Inactive
@tanmay-db tanmay-db marked this pull request as ready for review April 15, 2026 13:28
@tanmay-db tanmay-db requested review from a team as code owners April 15, 2026 13:28
@tanmay-db tanmay-db requested review from hectorcast-db and rauchy and removed request for a team and rauchy April 15, 2026 13:28
… hack

- ResourceFixture: add Host field for explicit host control in tests
- Mock-based tests: explicitly set Host = "https://accounts.cloud.databricks.com"
  alongside AccountID (no implicit defaults)
- MockAccountsApply: set accounts host URL in config
- Fixture-based tests: add api = "account" to HCL/State for account-level routing
- Convert TestStorageCredentialImportAccountLevel from fixtures to mocks
- Remove empty Fixtures from data_current_config account tests (use mock path)

Tests still use SDK HostType() in production code — this PR only decouples
the test infrastructure so it no longer depends on isTesting + AccountID.

Co-authored-by: Isaac
MockAccountsApply now inherits the outer DatabricksClient Host from the
mock AccountClient's own Config. Exporter account tests no longer call
Config.WithTesting(), so account-level routing must come from an explicit
Host URL on the mock client rather than the SDK's isTesting back-door.
…c tests

Follow-up to decoupling MockAccountsApply from hardcoded accounts Host:
these callbacks previously relied on the SDK's isTesting shortcut for
account routing. Each now populates ma.AccountClient.Config with an
explicit Host so HostType() resolves via URL-prefix matching.
…aform()

- Add HostTypeForTerraform() method on *DatabricksClient that uses only
  Experimental_IsUnifiedHost and URL prefix matching (no resolvedHostType
  or isTesting dependency)
- Replace all 12 call sites of SDK's deprecated HostType() across 7 files
- Update exporter test helpers to use HostTypeForTerraform()
- Update TestResourceGroupCreate_ApiFieldNotSet_FallsBackToHostInference
  expectations to reflect URL-based host inference

Co-authored-by: Isaac
Verifies the production path: when a user configures
host = "https://accounts.cloud.databricks.com" without setting
api = "account", HostTypeForTerraform() detects the accounts URL
prefix and IsAccountLevel() returns true.

Co-authored-by: Isaac
@tanmay-db tanmay-db temporarily deployed to test-trigger-is April 20, 2026 12:17 — with GitHub Actions Inactive
@tanmay-db tanmay-db changed the title [Internal] Replace SDK HostType() with provider-owned HostTypeForTerraform() [DO NOT MERGE] Testing Apr 20, 2026
@tanmay-db tanmay-db removed the request for review from hectorcast-db April 20, 2026 12:45
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 5593
  • Commit SHA: 7681b4f9b4336a292ea37ecdea1d8fd30e765795

Checks will be approved automatically on success.

slimbnsalah pushed a commit to slimbnsalah/terraform-provider-databricks that referenced this pull request Apr 21, 2026
## Changes
Decouples provider tests from the Databricks Go SDK's
`Config.HostType()` back-door, where
`isTesting && AccountID != ""` causes `HostType()` to return
`AccountHost` regardless of the
configured `Host`. Tests previously relied on this shortcut by setting
only `AccountID` and
  leaving `Host` empty.

This PR makes every account-level test declare its Host explicitly, so
the SDK can eventually
  drop the `isTesting` special-case without provider-test fallout.

1. **`qa/testing.go`** — `ResourceFixture` gains a `Host` field that
threads into
`config.Config.Host`. `MockAccountsApply` now reads `Host` from the mock
account client's own
  config (`ma.AccountClient.Config.Host`) instead of hardcoding
  `https://accounts.cloud.databricks.com` — the test now owns the value.

2. **`exporter/importables_test.go`** —
`importContextForAccountTestWithClient` no longer
calls `client.Config.WithTesting()`. Exporter account tests no longer
ride the SDK's
  `isTesting` shortcut.

3. **~20 `ResourceFixture` tests** (`catalog/`, `mws/`, `scim/`,
`apps/`, `finops/`,
`permissions/`, `tokens/`) — set `Host` explicitly where needed, or add
`api = "account"` to
HCL so the resource's own routing logic runs. Dead `Fixtures:
[]qa.HTTPFixture{}` entries
  removed from tests that made no HTTP calls.

4. **`exporter/impl_{billing,serverless,uc}_test.go`** — 29 callbacks
now call
`setupAwsAccountConfig(ma)` (or `setupAzureAccountConfig(ma)` for
Azure-specific tests) at the
top, matching the existing convention in `impl_mws_test.go` /
`impl_oauth_test.go`. Replaces
partial `Config = &config.Config{AccountID: ...}` inline blocks that
silently relied on
  `WithTesting()` to fill in the Host.

  ### Storage credential conversion
`TestStorageCredentialImportAccountLevel` converted from `HTTPFixture`
to
  `MockAccountClientFunc` since the test exercises mock-client paths.


  ## Tests

  - `make fmt` ✅
  - `make lint` ✅
  - `make test` — 3084 tests pass, 0 failures
- Tested by removing the isTesting check:
databricks#5593

NO_CHANGELOG=true
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