-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial Unity Catalog integration tests (#1592)
Added some coverage for: * `databricks_grants` * `databricks_schemas` * `databricks_schema` * `databricks_catalogs` * `databricks_catalog` * `databricks_external_location` * `databricks_storage_credential` * `databricks_metastore_assignment` * `databricks_metastore_data_access` * `databricks_metastore`
- Loading branch information
Showing
8 changed files
with
171 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package acceptance | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/internal/acceptance" | ||
"github.com/databricks/terraform-provider-databricks/qa" | ||
) | ||
|
||
func TestUcAccExternalLocation(t *testing.T) { | ||
qa.RequireCloudEnv(t, "ucws") | ||
acceptance.Test(t, []acceptance.Step{ | ||
{ | ||
Template: ` | ||
resource "databricks_storage_credential" "external" { | ||
name = "cred-{var.RANDOM}" | ||
aws_iam_role { | ||
role_arn = "{env.TEST_METASTORE_DATA_ACCESS_ARN}" | ||
} | ||
comment = "Managed by TF" | ||
} | ||
resource "databricks_external_location" "some" { | ||
name = "external" | ||
url = "s3://{env.TEST_BUCKET}/some{var.RANDOM}" | ||
credential_name = databricks_storage_credential.external.id | ||
comment = "Managed by TF" | ||
} | ||
resource "databricks_grants" "some" { | ||
external_location = databricks_external_location.some.id | ||
grant { | ||
principal = "{env.TEST_DATA_ENG_GROUP}" | ||
privileges = ["CREATE_TABLE", "READ_FILES"] | ||
} | ||
}`, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package acceptance | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/internal/acceptance" | ||
"github.com/databricks/terraform-provider-databricks/qa" | ||
) | ||
|
||
func TestUcAccMetastoreAssignment(t *testing.T) { | ||
qa.RequireCloudEnv(t, "ucws") | ||
acceptance.Test(t, []acceptance.Step{ | ||
{ | ||
Template: `resource "databricks_metastore_assignment" "this" { | ||
metastore_id = "{env.TEST_METASTORE_ID}" | ||
workspace_id = {env.TEST_WORKSPACE_ID} | ||
}`, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package acceptance | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/internal/acceptance" | ||
"github.com/databricks/terraform-provider-databricks/qa" | ||
) | ||
|
||
func TestUcAccMetastoreDataAccessOnAws(t *testing.T) { | ||
qa.RequireCloudEnv(t, "ucws") | ||
acceptance.Test(t, []acceptance.Step{ | ||
{ | ||
Template: ` | ||
resource "databricks_metastore" "this" { | ||
name = "primary" | ||
storage_root = "s3://{env.TEST_BUCKET}/test{var.RANDOM}" | ||
force_destroy = true | ||
} | ||
resource "databricks_metastore_data_access" "this" { | ||
metastore_id = databricks_metastore.this.id | ||
name = "{var.RANDOM}" | ||
aws_iam_role { | ||
role_arn = "{env.TEST_METASTORE_DATA_ACCESS_ARN}" | ||
} | ||
is_default = true | ||
}`, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package acceptance | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/databricks/terraform-provider-databricks/internal/acceptance" | ||
"github.com/databricks/terraform-provider-databricks/qa" | ||
) | ||
|
||
func TestUcAccSchema(t *testing.T) { | ||
qa.RequireCloudEnv(t, "ucws") | ||
acceptance.Test(t, []acceptance.Step{ | ||
{ | ||
Template: ` | ||
resource "databricks_catalog" "sandbox" { | ||
name = "sandbox{var.RANDOM}" | ||
comment = "this catalog is managed by terraform" | ||
properties = { | ||
purpose = "testing" | ||
} | ||
} | ||
data "databricks_catalogs" "all" { | ||
depends_on = [databricks_catalog.sandbox] | ||
} | ||
resource "databricks_grants" "sandbox" { | ||
catalog = databricks_catalog.sandbox.name | ||
grant { | ||
principal = "{env.TEST_DATA_SCI_GROUP}" | ||
privileges = ["USAGE", "CREATE"] | ||
} | ||
grant { | ||
principal = "{env.TEST_DATA_ENG_GROUP}" | ||
privileges = ["USAGE"] | ||
} | ||
} | ||
resource "databricks_schema" "things" { | ||
catalog_name = databricks_catalog.sandbox.id | ||
name = "things{var.RANDOM}" | ||
comment = "this database is managed by terraform" | ||
properties = { | ||
kind = "various" | ||
} | ||
} | ||
data "databricks_schemas" "sandbox" { | ||
catalog_name = databricks_catalog.sandbox.id | ||
depends_on = [databricks_schema.things] | ||
} | ||
resource "databricks_grants" "things" { | ||
schema = databricks_schema.things.id | ||
grant { | ||
principal = "{env.TEST_DATA_ENG_GROUP}" | ||
privileges = ["USAGE"] | ||
} | ||
}`, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters