Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_hdinsight_interactive_query_cluster: Removing unsupported acc test #21981

Merged
merged 4 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/hdinsight/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -45,7 +46,7 @@ var hdInsightInteractiveQueryClusterZookeeperNodeDefinition = HDInsightNodeDefin
}

func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Create: resourceHDInsightInteractiveQueryClusterCreate,
Read: resourceHDInsightInteractiveQueryClusterRead,
Update: hdinsightClusterUpdate("Interactive Query", resourceHDInsightInteractiveQueryClusterRead),
Expand Down Expand Up @@ -114,21 +115,6 @@ func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {

"storage_account_gen2": SchemaHDInsightsGen2StorageAccounts(),

"roles": {
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
},

"tags": tags.Schema(),

"https_endpoint": {
Expand All @@ -146,6 +132,42 @@ func resourceHDInsightInteractiveQueryCluster() *pluginsdk.Resource {
"extension": SchemaHDInsightsExtension(),
},
}

if !features.FourPointOh() {
resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
Deprecated: "HDInsight interactive query clusters can no longer be configured through `autoscale.0.capacity`. Use `autoscale.0.recurrence` instead.",
}
} else {
hdInsightInteractiveQueryClusterWorkerNodeDefinition.CanAutoScaleByCapacity = false
resource.Schema["roles"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"head_node": SchemaHDInsightNodeDefinition("roles.0.head_node", hdInsightInteractiveQueryClusterHeadNodeDefinition, true),

"worker_node": SchemaHDInsightNodeDefinition("roles.0.worker_node", hdInsightInteractiveQueryClusterWorkerNodeDefinition, true),

"zookeeper_node": SchemaHDInsightNodeDefinition("roles.0.zookeeper_node", hdInsightInteractiveQueryClusterZookeeperNodeDefinition, true),
},
},
}
}

return resource
}

func resourceHDInsightInteractiveQueryClusterCreate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,21 +567,6 @@ func TestAccAzureRMHDInsightInteractiveQueryCluster_autoscale(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_hdinsight_interactive_query_cluster", "test")
r := HDInsightInteractiveQueryClusterResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.autoscale_capacity(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("https_endpoint").Exists(),
check.That(data.ResourceName).Key("ssh_endpoint").Exists(),
),
},
data.ImportStep("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"),
{
Config: r.autoscale_schedule(data),
Check: acceptance.ComposeTestCheckFunc(
Expand Down Expand Up @@ -2006,55 +1991,6 @@ resource "azurerm_hdinsight_interactive_query_cluster" "test" {
`, r.template(data), data.RandomString, data.RandomInteger, data.RandomInteger)
}

func (r HDInsightInteractiveQueryClusterResource) autoscale_capacity(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_hdinsight_interactive_query_cluster" "test" {
name = "acctesthdi-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
cluster_version = "4.0"
tier = "Standard"
component_version {
interactive_hive = "3.1"
}
gateway {
username = "acctestusrgw"
password = "TerrAform123!"
}
storage_account {
storage_container_id = azurerm_storage_container.test.id
storage_account_key = azurerm_storage_account.test.primary_access_key
is_default = true
}
roles {
head_node {
vm_size = "Standard_D13_V2"
username = "acctestusrvm"
password = "AccTestvdSC4daf986!"
}
worker_node {
vm_size = "Standard_D14_V2"
username = "acctestusrvm"
password = "AccTestvdSC4daf986!"
target_instance_count = 2
autoscale {
capacity {
min_instance_count = 2
max_instance_count = 3
}
}
}
zookeeper_node {
vm_size = "Standard_A4_V2"
username = "acctestusrvm"
password = "AccTestvdSC4daf986!"
}
}
}
`, r.template(data), data.RandomInteger)
}

func (r HDInsightInteractiveQueryClusterResource) autoscale_schedule(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,20 +363,8 @@ A `extension` block supports the following:

An `autoscale` block supports the following:

* `capacity` - (Optional) A `capacity` block as defined below.

* `recurrence` - (Optional) A `recurrence` block as defined below.

-> **NOTE:** Either a `capacity` or `recurrence` block must be specified - but not both.

---

A `capacity` block supports the following:

* `max_instance_count` - (Required) The maximum number of worker nodes to autoscale to based on the cluster's activity.

* `min_instance_count` - (Required) The minimum number of worker nodes to autoscale to based on the cluster's activity.

---

A `recurrence` block supports the following:
Expand Down