Skip to content

Commit aacc37f

Browse files
committed
resource/alicloud_click_house_db_cluster: fix modify dbcluster state, split inplace class change test case into multiple test cases.
1 parent 355240a commit aacc37f

2 files changed

+122
-6
lines changed

alicloud/resource_alicloud_click_house_db_cluster.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ func resourceAlicloudClickHouseDbClusterUpdate(d *schema.ResourceData, meta inte
613613
}
614614
action := "ModifyDBCluster"
615615
var response map[string]interface{}
616-
wait := incrementalWait(3*time.Second, 3*time.Second)
616+
wait := incrementalWait(10*time.Second, 10*time.Second)
617617
err = resource.Retry(d.Timeout(schema.TimeoutUpdate), func() *resource.RetryError {
618-
response, err = client.RpcPost("clickhouse", "2019-11-11", action, nil, request, false)
618+
response, err = client.RpcPost("clickhouse", "2019-11-11", action, nil, request, true)
619619
if err != nil {
620-
if IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing"}) || NeedRetry(err) {
620+
if IsExpectedErrors(err, []string{"IncorrectDBInstanceState", "OperationDenied.OrderProcessing", "OperationDenied.DBClusterStatus"}) || NeedRetry(err) {
621621
wait()
622622
return resource.RetryableError(err)
623623
}

alicloud/resource_alicloud_click_house_db_cluster_test.go

+119-3
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func TestAccAliCloudClickHouseDBCluster_ClusterVersion(t *testing.T) {
562562
})
563563
}
564564

565-
func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace(t *testing.T) {
565+
func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace1(t *testing.T) {
566566
checkoutSupportedRegions(t, true, connectivity.VbrSupportRegions)
567567
var v map[string]interface{}
568568
resourceId := "alicloud_click_house_db_cluster.default"
@@ -621,13 +621,61 @@ func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace(t *testing.T) {
621621
}),
622622
),
623623
},
624+
{
625+
ResourceName: resourceId,
626+
ImportState: true,
627+
ImportStateVerify: true,
628+
},
629+
},
630+
})
631+
}
632+
633+
func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace2(t *testing.T) {
634+
checkoutSupportedRegions(t, true, connectivity.VodSupportRegions)
635+
var v map[string]interface{}
636+
resourceId := "alicloud_click_house_db_cluster.default"
637+
ra := resourceAttrInit(resourceId, AliCloudClickHouseDBClusterMap0)
638+
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
639+
return &ClickhouseService{testAccProvider.Meta().(*connectivity.AliyunClient)}
640+
}, "DescribeClickHouseDbCluster")
641+
rac := resourceAttrCheckInit(rc, ra)
642+
testAccCheck := rac.resourceAttrMapUpdateSet()
643+
rand := acctest.RandIntRange(10000, 99999)
644+
name := fmt.Sprintf("tf-testacc%sclickhousedbcluster%d", defaultRegionToTest, rand)
645+
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudClickHouseDBClusterBasicDependence0)
646+
resource.Test(t, resource.TestCase{
647+
PreCheck: func() {
648+
testAccPreCheck(t)
649+
},
650+
IDRefreshName: resourceId,
651+
Providers: testAccProviders,
652+
CheckDestroy: rac.checkResourceDestroy(),
653+
Steps: []resource.TestStep{
624654
{
625655
Config: testAccConfig(map[string]interface{}{
626-
"db_node_group_count": "2",
656+
"db_cluster_version": "22.8.5.29",
657+
"category": "Basic",
658+
"db_cluster_class": "S8",
659+
"db_cluster_network_type": "vpc",
660+
"db_node_group_count": "1",
661+
"payment_type": "PayAsYouGo",
662+
"db_node_storage": "100",
663+
"storage_type": "cloud_essd",
664+
"vpc_id": "${alicloud_vswitch.default.vpc_id}",
665+
"vswitch_id": "${alicloud_vswitch.default.id}",
627666
}),
628667
Check: resource.ComposeTestCheckFunc(
629668
testAccCheck(map[string]string{
630-
"db_node_group_count": "2",
669+
"db_cluster_version": "22.8.5.29",
670+
"category": "Basic",
671+
"db_cluster_class": "S8",
672+
"db_cluster_network_type": "vpc",
673+
"db_node_group_count": "1",
674+
"payment_type": "PayAsYouGo",
675+
"db_node_storage": "100",
676+
"storage_type": "cloud_essd",
677+
"vswitch_id": CHECKSET,
678+
"vpc_id": CHECKSET,
631679
}),
632680
),
633681
},
@@ -650,6 +698,74 @@ func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace(t *testing.T) {
650698
})
651699
}
652700

701+
func TestAccAliCloudClickHouseDBCluster_UpdateClusterInplace3(t *testing.T) {
702+
checkoutSupportedRegions(t, true, connectivity.VodSupportRegions)
703+
var v map[string]interface{}
704+
resourceId := "alicloud_click_house_db_cluster.default"
705+
ra := resourceAttrInit(resourceId, AliCloudClickHouseDBClusterMap0)
706+
rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} {
707+
return &ClickhouseService{testAccProvider.Meta().(*connectivity.AliyunClient)}
708+
}, "DescribeClickHouseDbCluster")
709+
rac := resourceAttrCheckInit(rc, ra)
710+
testAccCheck := rac.resourceAttrMapUpdateSet()
711+
rand := acctest.RandIntRange(10000, 99999)
712+
name := fmt.Sprintf("tf-testacc%sclickhousedbcluster%d", defaultRegionToTest, rand)
713+
testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudClickHouseDBClusterBasicDependence0)
714+
resource.Test(t, resource.TestCase{
715+
PreCheck: func() {
716+
testAccPreCheck(t)
717+
},
718+
IDRefreshName: resourceId,
719+
Providers: testAccProviders,
720+
CheckDestroy: rac.checkResourceDestroy(),
721+
Steps: []resource.TestStep{
722+
{
723+
Config: testAccConfig(map[string]interface{}{
724+
"db_cluster_version": "22.8.5.29",
725+
"category": "Basic",
726+
"db_cluster_class": "S8",
727+
"db_cluster_network_type": "vpc",
728+
"db_node_group_count": "1",
729+
"payment_type": "PayAsYouGo",
730+
"db_node_storage": "100",
731+
"storage_type": "cloud_essd",
732+
"vpc_id": "${alicloud_vswitch.default.vpc_id}",
733+
"vswitch_id": "${alicloud_vswitch.default.id}",
734+
}),
735+
Check: resource.ComposeTestCheckFunc(
736+
testAccCheck(map[string]string{
737+
"db_cluster_version": "22.8.5.29",
738+
"category": "Basic",
739+
"db_cluster_class": "S8",
740+
"db_cluster_network_type": "vpc",
741+
"db_node_group_count": "1",
742+
"payment_type": "PayAsYouGo",
743+
"db_node_storage": "100",
744+
"storage_type": "cloud_essd",
745+
"vswitch_id": CHECKSET,
746+
"vpc_id": CHECKSET,
747+
}),
748+
),
749+
},
750+
{
751+
Config: testAccConfig(map[string]interface{}{
752+
"db_node_group_count": "2",
753+
}),
754+
Check: resource.ComposeTestCheckFunc(
755+
testAccCheck(map[string]string{
756+
"db_node_group_count": "2",
757+
}),
758+
),
759+
},
760+
{
761+
ResourceName: resourceId,
762+
ImportState: true,
763+
ImportStateVerify: true,
764+
},
765+
},
766+
})
767+
}
768+
653769
func TestAccAliCloudClickHouseDBCluster_AutoRenew(t *testing.T) {
654770
checkoutSupportedRegions(t, true, connectivity.VbrSupportRegions)
655771
var v map[string]interface{}

0 commit comments

Comments
 (0)