From 402d119818591436bfa5135e31fdd43be0a82192 Mon Sep 17 00:00:00 2001 From: Tanmay Rustagi Date: Thu, 1 Feb 2024 15:24:38 +0100 Subject: [PATCH] integration test --- catalog/resource_connection.go | 4 +++ catalog/resource_storage_credential.go | 5 ++++ internal/acceptance/connection_test.go | 2 ++ internal/acceptance/external_location_test.go | 4 +++ internal/acceptance/schema_test.go | 2 ++ internal/acceptance/volume_test.go | 29 ++++++++++++++++--- 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/catalog/resource_connection.go b/catalog/resource_connection.go index 3f556f1631..975893e02a 100644 --- a/catalog/resource_connection.go +++ b/catalog/resource_connection.go @@ -126,6 +126,10 @@ func ResourceConnection() *schema.Resource { } } + if !d.HasChangeExcept("owner") { + return nil + } + updateConnectionRequest.Owner = "" _, err = w.Connections.Update(ctx, updateConnectionRequest) if err != nil { diff --git a/catalog/resource_storage_credential.go b/catalog/resource_storage_credential.go index a4f94baec6..4e5ceb272f 100644 --- a/catalog/resource_storage_credential.go +++ b/catalog/resource_storage_credential.go @@ -196,6 +196,11 @@ func ResourceStorageCredential() *schema.Resource { return err } } + + if !d.HasChangeExcept("owner") { + return nil + } + update.Owner = "" _, err = w.StorageCredentials.Update(ctx, update) if err != nil { diff --git a/internal/acceptance/connection_test.go b/internal/acceptance/connection_test.go index 714ea33a53..b1c493c7d7 100644 --- a/internal/acceptance/connection_test.go +++ b/internal/acceptance/connection_test.go @@ -26,6 +26,8 @@ func TestUcAccConnectionsResourceFullLifecycle(t *testing.T) { Template: connectionTemplateWithOwner("test.mysql.database.azure.com", "account users"), }, step{ Template: connectionTemplateWithOwner("test.mysql.database.aws.com", "account users"), + }, step{ + Template: connectionTemplateWithOwner("test.mysql.database.aws.com", "{env.TEST_DATA_ENG_GROUP}"), }, step{ Template: connectionTemplateWithOwner("test.mysql.database.azure.com", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}"), }) diff --git a/internal/acceptance/external_location_test.go b/internal/acceptance/external_location_test.go index 0352382129..7e219bed2a 100644 --- a/internal/acceptance/external_location_test.go +++ b/internal/acceptance/external_location_test.go @@ -91,6 +91,10 @@ func TestUcAccExternalLocationUpdate(t *testing.T) { Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment", "account users") + externalLocationTemplateWithOwner("Managed by TF -- Updated Comment", "account users") + grantsTemplateForExternalLocation, + }, step{ + Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment", "{env.TEST_DATA_ENG_GROUP}") + + externalLocationTemplateWithOwner("Managed by TF -- Updated Comment", "{env.TEST_DATA_ENG_GROUP}") + + grantsTemplateForExternalLocation, }, step{ Template: storageCredentialTemplateWithOwner("Managed by TF -- Updated Comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}") + externalLocationTemplateWithOwner("Managed by TF -- Updated Comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}") + diff --git a/internal/acceptance/schema_test.go b/internal/acceptance/schema_test.go index df2098ceb8..246668d440 100644 --- a/internal/acceptance/schema_test.go +++ b/internal/acceptance/schema_test.go @@ -92,6 +92,8 @@ func TestUcAccSchemaUpdate(t *testing.T) { Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform", "account users"), }, step{ Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment", "account users"), + }, step{ + Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment", "{env.TEST_DATA_ENG_GROUP}"), }, step{ Template: catalogTemplate + schemaTemplateWithOwner("this database is managed by terraform -- updated comment 2", "{env.TEST_METASTORE_ADMIN_GROUP_NAME}"), }) diff --git a/internal/acceptance/volume_test.go b/internal/acceptance/volume_test.go index c2ba2e5d0f..9fa4348983 100644 --- a/internal/acceptance/volume_test.go +++ b/internal/acceptance/volume_test.go @@ -46,9 +46,8 @@ func TestUcAccVolumesResourceWithoutInitialOwnerAWSFullLifecycle(t *testing.T) { volume_type = "EXTERNAL" storage_location = databricks_external_location.some.url }`, - }, - step{ - Template: prefixTestTemplate + ` + }, step{ + Template: prefixTestTemplate + ` resource "databricks_volume" "this" { name = "name-def" comment = "comment-def" @@ -58,7 +57,18 @@ func TestUcAccVolumesResourceWithoutInitialOwnerAWSFullLifecycle(t *testing.T) { volume_type = "EXTERNAL" storage_location = databricks_external_location.some.url }`, - }) + }, step{ + Template: prefixTestTemplate + ` + resource "databricks_volume" "this" { + name = "name-def" + comment = "comment-def" + owner = "{env.TEST_DATA_ENG_GROUP}" + catalog_name = "main" + schema_name = databricks_schema.this.name + volume_type = "EXTERNAL" + storage_location = databricks_external_location.some.url + }`, + }) } func TestUcAccVolumesResourceWithInitialOwnerAWSFullLifecycle(t *testing.T) { @@ -84,5 +94,16 @@ func TestUcAccVolumesResourceWithInitialOwnerAWSFullLifecycle(t *testing.T) { volume_type = "EXTERNAL" storage_location = databricks_external_location.some.url }`, + }, step{ + Template: prefixTestTemplate + ` + resource "databricks_volume" "this" { + name = "name-def" + comment = "comment-def" + owner = "{env.TEST_DATA_ENG_GROUP}" + catalog_name = "main" + schema_name = databricks_schema.this.name + volume_type = "EXTERNAL" + storage_location = databricks_external_location.some.url + }`, }) }