Skip to content

Commit

Permalink
DWX-18779 DW acceptance tests for catalog, hive
Browse files Browse the repository at this point in the history
Cover the dw environment, db catalog and hive vw creations and
deletions as part of acceptance testing.
  • Loading branch information
tevesz committed Oct 31, 2024
1 parent 2140a39 commit 34b0612
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 34b0612

Please sign in to comment.