Skip to content

Commit

Permalink
resource/alicloud_hbase_instance: Add cloud_essd_pl0
Browse files Browse the repository at this point in the history
  • Loading branch information
quanyun-ali committed Nov 12, 2024
1 parent 6ad4d08 commit 3079485
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 17 deletions.
10 changes: 6 additions & 4 deletions alicloud/resource_alicloud_hbase_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func resourceAlicloudHBaseInstance() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"cloud_ssd", "cloud_essd_pl1", "cloud_efficiency", "local_hdd_pro", "local_ssd_pro", ""}, false),
ValidateFunc: StringInSlice([]string{"cloud_ssd", "cloud_essd_pl1", "cloud_essd_pl0", "cloud_efficiency", "local_hdd_pro", "local_ssd_pro", ""}, false),
DiffSuppressFunc: engineDiffSuppressFunc,
},
"core_disk_size": {
Expand Down Expand Up @@ -362,6 +362,8 @@ func resourceAlicloudHBaseInstanceRead(d *schema.ResourceData, meta interface{})
// Postpaid -> PostPaid
d.Set("pay_type", convertHbaseInstancePayTypeResponse(instance["PayType"]))
if instance["PayType"] == string(Prepaid) {
time.Sleep(20)
instance, err := hbaseService.DescribeHBaseInstance(d.Id())
period, err := computePeriodByUnit(instance["CreatedTimeUTC"], instance["ExpireTimeUTC"], d.Get("duration").(int), "Month")
if err != nil {
return WrapError(err)
Expand Down Expand Up @@ -589,7 +591,7 @@ func resourceAlicloudHBaseInstanceUpdate(d *schema.ResourceData, meta interface{
}
// Cumbersome operation,async call, wait for state change
// wait instance status is running after modifying
stateConf := BuildStateConf([]string{Hb_NODE_RESIZING}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
stateConf := BuildStateConf([]string{Hb_NODE_RESIZING, HBASE_SCALE_IN}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
5*time.Minute, hBaseService.HBaseClusterStateRefreshFunc(d.Id(), []string{Hb_NODE_RESIZING_FAILED}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapError(err)
Expand Down Expand Up @@ -646,7 +648,7 @@ func resourceAlicloudHBaseInstanceUpdate(d *schema.ResourceData, meta interface{
}
// Cumbersome operation,async call, wait for state change
// wait instance status is running after modifying
stateConf := BuildStateConf([]string{Hb_DISK_RESIZING}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
stateConf := BuildStateConf([]string{Hb_DISK_RESIZING, HBASE_SCALE_IN}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
2*time.Minute, hBaseService.HBaseClusterStateRefreshFunc(d.Id(), []string{Hb_DISK_RESIZE_FAILED}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapError(err)
Expand All @@ -668,7 +670,7 @@ func resourceAlicloudHBaseInstanceUpdate(d *schema.ResourceData, meta interface{
}
// Cumbersome operation,async call, wait for state change
// wait instance status is running after modifying
stateConf := BuildStateConf([]string{Hb_HBASE_COLD_EXPANDING}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
stateConf := BuildStateConf([]string{Hb_HBASE_COLD_EXPANDING, HBASE_SCALE_IN}, []string{Hb_ACTIVATION}, d.Timeout(schema.TimeoutUpdate),
10*time.Second, hBaseService.HBaseClusterStateRefreshFunc(d.Id(), []string{Hb_DISK_RESIZE_FAILED}))
if _, err := stateConf.WaitForState(); err != nil {
return WrapError(err)
Expand Down
74 changes: 61 additions & 13 deletions alicloud/resource_alicloud_hbase_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ resource "alicloud_security_group" "default" {
`, name)
}

func TestAccAlicloudHBaseInstanceVpc(t *testing.T) {
func TestAccAliCloudHBaseInstanceVpc(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_hbase_instance.default"
ra := resourceAttrInit(resourceId, nil)
Expand All @@ -174,17 +174,21 @@ func TestAccAlicloudHBaseInstanceVpc(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccConfig(map[string]interface{}{
"name": "${var.name}",
"engine": "hbaseue",
"engine_version": "2.0",
"master_instance_type": "hbase.sn2.2xlarge",
"core_instance_type": "hbase.sn2.2xlarge",
"core_disk_type": "cloud_ssd",
"vpc_id": "${data.alicloud_vpcs.default.ids.0}",
"vswitch_id": "${local.vswitch_id}",
"immediate_delete_flag": "true",
"ip_white": "192.168.0.1",
"cold_storage_size": "800",
"name": "${var.name}",
"engine": "hbaseue",
"engine_version": "2.0",
"master_instance_type": "hbase.sn2.2xlarge",
"core_instance_type": "hbase.sn2.2xlarge",
"core_disk_type": "cloud_ssd",
"vpc_id": "${data.alicloud_vpcs.default.ids.0}",
"vswitch_id": "${local.vswitch_id}",
"zone_id": "${data.alicloud_hbase_zones.default.ids.0}",
"immediate_delete_flag": "true",
"ip_white": "192.168.0.1",
"cold_storage_size": "800",
"auto_renew": "0",
"core_instance_quantity": "2",
"pay_type": "PostPaid",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
Expand All @@ -211,6 +215,18 @@ func TestAccAlicloudHBaseInstanceVpc(t *testing.T) {
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"pay_type": "PrePaid",
"duration": "1",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"pay_type": "PrePaid",
"duration": "1",
}),
),
},
{
ResourceName: resourceId,
ImportState: true,
Expand Down Expand Up @@ -323,6 +339,38 @@ func TestAccAlicloudHBaseInstanceVpc(t *testing.T) {
// ),
//},

{
Config: testAccConfig(map[string]interface{}{
"master_instance_type": "hbase.sn1.4xlarge",
"core_instance_type": "hbase.sn1.4xlarge",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"master_instance_type": "hbase.sn1.4xlarge",
"core_instance_type": "hbase.sn1.4xlarge",
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"core_instance_quantity": "3",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"core_instance_quantity": "3",
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"pay_type": "PostPaid",
}),
Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"pay_type": "PostPaid",
}),
),
},
{
Config: testAccConfig(map[string]interface{}{
"security_groups": []string{"${alicloud_security_group.default.0.id}"},
Expand Down Expand Up @@ -370,7 +418,7 @@ func TestAccAlicloudHBaseInstanceVpc(t *testing.T) {
})
}

func TestAccAlicloudHBaseInstance_VpcId(t *testing.T) {
func TestAccAliCloudHBaseInstance_VpcId(t *testing.T) {
var v map[string]interface{}
resourceId := "alicloud_hbase_instance.default"
ra := resourceAttrInit(resourceId, nil)
Expand Down
1 change: 1 addition & 0 deletions alicloud/service_alicloud_hbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
Hb_DELETING = "DELETING"
Hb_CREATE_FAILED = "CREATE_FAILED"
Hb_NODE_RESIZING = "HBASE_SCALE_OUT"
HBASE_SCALE_IN = "HBASE_SCALE_IN"
Hb_NODE_RESIZING_FAILED = "NODE_RESIZE_FAILED"
Hb_DISK_RESIZING = "HBASE_EXPANDING"
Hb_DISK_RESIZE_FAILED = "DISK_RESIZING_FAILED"
Expand Down

0 comments on commit 3079485

Please sign in to comment.