From f77a95bf177f4c06846507cad94c3726408200e0 Mon Sep 17 00:00:00 2001 From: Daniel Intskirveli Date: Tue, 12 Nov 2019 12:46:30 -0500 Subject: [PATCH] Update more tests --- azurerm/helpers/azure/hdinsight.go | 2 + ...source_arm_hdinsight_kafka_cluster_test.go | 132 ++++++++++++++++++ ...ource_arm_hdinsight_ml_services_cluster.go | 2 - .../resource_arm_hdinsight_rserver_cluster.go | 2 - 4 files changed, 134 insertions(+), 4 deletions(-) diff --git a/azurerm/helpers/azure/hdinsight.go b/azurerm/helpers/azure/hdinsight.go index d046d42ed7a37..c76f692bf3ff6 100644 --- a/azurerm/helpers/azure/hdinsight.go +++ b/azurerm/helpers/azure/hdinsight.go @@ -183,6 +183,8 @@ func SchemaHDInsightsGen2StorageAccounts() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, Optional: true, + // HDInsight doesn't seem to allow adding more than one gen2 cluster right now. + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "storage_resource_id": { diff --git a/azurerm/resource_arm_hdinsight_kafka_cluster_test.go b/azurerm/resource_arm_hdinsight_kafka_cluster_test.go index 866efb9ccc6bc..56af36c493113 100644 --- a/azurerm/resource_arm_hdinsight_kafka_cluster_test.go +++ b/azurerm/resource_arm_hdinsight_kafka_cluster_test.go @@ -48,6 +48,43 @@ func TestAccAzureRMHDInsightKafkaCluster_basic(t *testing.T) { }) } +func TestAccAzureRMHDInsightKafkaCluster_gen2storage(t *testing.T) { + resourceName := "azurerm_hdinsight_kafka_cluster.test" + ri := tf.AccRandTimeInt() + rs := strings.ToLower(acctest.RandString(11)) + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMHDInsightClusterDestroy("azurerm_hdinsight_kafka_cluster"), + Steps: []resource.TestStep{ + { + Config: testAccAzureRMHDInsightKafkaCluster_gen2storage(ri, rs, location), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMHDInsightClusterExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "https_endpoint"), + resource.TestCheckResourceAttrSet(resourceName, "ssh_endpoint"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "roles.0.head_node.0.password", + "roles.0.head_node.0.vm_size", + "roles.0.worker_node.0.password", + "roles.0.worker_node.0.vm_size", + "roles.0.zookeeper_node.0.password", + "roles.0.zookeeper_node.0.vm_size", + "storage_account", + }, + }, + }, + }) +} + func TestAccAzureRMHDInsightKafkaCluster_requiresImport(t *testing.T) { if !features.ShouldResourcesBeImported() { t.Skip("Skipping since resources aren't required to be imported") @@ -303,6 +340,62 @@ resource "azurerm_hdinsight_kafka_cluster" "test" { `, template, rInt) } +func testAccAzureRMHDInsightKafkaCluster_gen2storage(rInt int, rString string, location string) string { + template := testAccAzureRMHDInsightKafkaCluster_gen2template(rInt, rString, location) + return fmt.Sprintf(` +%s + +resource "azurerm_hdinsight_kafka_cluster" "test" { + depends_on = [azurerm_role_assignment.test] + + name = "acctesthdi-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + cluster_version = "3.6" + tier = "Standard" + + component_version { + kafka = "1.1" + } + + gateway { + enabled = true + username = "acctestusrgw" + password = "TerrAform123!" + } + + storage_account_gen2 { + storage_resource_id = azurerm_storage_account.gen2test.id + filesystem_id = azurerm_storage_data_lake_gen2_filesystem.gen2test.id + managed_identity_resource_id = azurerm_user_assigned_identity.test.id + is_default = true + } + + roles { + head_node { + vm_size = "Standard_D3_V2" + username = "acctestusrvm" + password = "AccTestvdSC4daf986!" + } + + worker_node { + vm_size = "Standard_D3_V2" + username = "acctestusrvm" + password = "AccTestvdSC4daf986!" + target_instance_count = 3 + number_of_disks_per_node = 2 + } + + zookeeper_node { + vm_size = "Standard_D3_V2" + username = "acctestusrvm" + password = "AccTestvdSC4daf986!" + } + } +} +`, template, rInt) +} + func testAccAzureRMHDInsightKafkaCluster_requiresImport(rInt int, rString string, location string) string { template := testAccAzureRMHDInsightKafkaCluster_basic(rInt, rString, location) return fmt.Sprintf(` @@ -609,3 +702,42 @@ resource "azurerm_storage_container" "test" { } `, rInt, location, rString) } + +func testAccAzureRMHDInsightKafkaCluster_gen2template(rInt int, rString string, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "gen2test" { + name = "accgen2test%s" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + account_kind = "StorageV2" + account_tier = "Standard" + account_replication_type = "LRS" + is_hns_enabled = true +} + +resource "azurerm_storage_data_lake_gen2_filesystem" "gen2test" { + name = "acctest" + storage_account_id = azurerm_storage_account.gen2test.id +} + +resource "azurerm_user_assigned_identity" "test" { + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + + name = "test-identity" +} + +data "azurerm_subscription" "primary" {} + +resource "azurerm_role_assignment" "test" { + scope = "${data.azurerm_subscription.primary.id}" + role_definition_name = "Storage Blob Data Owner" + principal_id = "${azurerm_user_assigned_identity.test.principal_id}" +} +`, rInt, location, rString) +} diff --git a/azurerm/resource_arm_hdinsight_ml_services_cluster.go b/azurerm/resource_arm_hdinsight_ml_services_cluster.go index fd74b947d940e..215fb7107f881 100644 --- a/azurerm/resource_arm_hdinsight_ml_services_cluster.go +++ b/azurerm/resource_arm_hdinsight_ml_services_cluster.go @@ -89,8 +89,6 @@ func resourceArmHDInsightMLServicesCluster() *schema.Resource { "storage_account": azure.SchemaHDInsightsStorageAccounts(), - "storage_account_gen2": azure.SchemaHDInsightsGen2StorageAccounts(), - "roles": { Type: schema.TypeList, Required: true, diff --git a/azurerm/resource_arm_hdinsight_rserver_cluster.go b/azurerm/resource_arm_hdinsight_rserver_cluster.go index c2050f8661b49..e2353249f452c 100644 --- a/azurerm/resource_arm_hdinsight_rserver_cluster.go +++ b/azurerm/resource_arm_hdinsight_rserver_cluster.go @@ -89,8 +89,6 @@ func resourceArmHDInsightRServerCluster() *schema.Resource { "storage_account": azure.SchemaHDInsightsStorageAccounts(), - "storage_account_gen2": azure.SchemaHDInsightsGen2StorageAccounts(), - "roles": { Type: schema.TypeList, Required: true,