From 34b0612bade77932ac0463da1a9b23b56246fdf0 Mon Sep 17 00:00:00 2001 From: Agnes Tevesz Date: Thu, 31 Oct 2024 15:46:47 -0500 Subject: [PATCH] DWX-18779 DW acceptance tests for catalog, hive Cover the dw environment, db catalog and hive vw creations and deletions as part of acceptance testing. --- ...er_acc_test.go => resource_dw_acc_test.go} | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) rename resources/dw/{cluster/aws/resource_cluster_acc_test.go => resource_dw_acc_test.go} (93%) diff --git a/resources/dw/cluster/aws/resource_cluster_acc_test.go b/resources/dw/resource_dw_acc_test.go similarity index 93% rename from resources/dw/cluster/aws/resource_cluster_acc_test.go rename to resources/dw/resource_dw_acc_test.go index 32670a57..251624da 100644 --- a/resources/dw/cluster/aws/resource_cluster_acc_test.go +++ b/resources/dw/resource_dw_acc_test.go @@ -8,21 +8,23 @@ // OF ANY KIND, either express or implied. Refer to the License for the specific // permissions and limitations governing your use of the file. -package aws_test +package dw import ( "context" "fmt" + "os" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/client/operations" "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/dw/models" "github.com/cloudera/terraform-provider-cdp/cdpacctest" "github.com/cloudera/terraform-provider-cdp/utils" - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - "os" - "strings" - "testing" ) const ( @@ -130,7 +132,9 @@ func TestAccCluster_basic(t *testing.T) { testAccAwsCredentialBasicConfig(credName, os.Getenv(AwsXAccRoleArn)), testAccAwsEnvironmentConfig(&envParams), testAccAwsDataLakeConfig(&dlParams), - testAccAwsClusterBasicConfig(&envParams)), + testAccAwsClusterBasicConfig(&envParams), + testAccDwCatalog(), + testAccHiveVirtualWarehouse()), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "name", envParams.Name), resource.TestCheckResourceAttr(resourceName, "status", "Accepted"), @@ -224,6 +228,24 @@ func testAccAwsClusterBasicConfig(params *awsEnvironmentTestParameters) string { `, params.SubnetIds) } +func testAccDwCatalog() string { + return ` + resource "cdp_dw_database_catalog" "test_catalog" { + cluster_id = cdp_dw_aws_cluster.test_data_warehouse_aws.cluster_id + } + ` +} + +func testAccHiveVirtualWarehouse() string { + return ` + resource "cdp_vw_hive" "test_hive" { + cluster_id = cdp_dw_aws_cluster.test_data_warehouse_aws.cluster_id + database_catalog_id = cdp_dw_database_catalog.test_catalog.id + name = "tf-test-hive" + } + ` +} + func testCheckClusterDestroy(s *terraform.State) error { for _, rs := range s.RootModule().Resources { if rs.Type != "cdp_dw_aws_cluster" {