Skip to content

Commit c0215c5

Browse files
authored
fix: cbs testcases (#965)
1 parent 16e754e commit c0215c5

11 files changed

+96
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resource "tencentcloud_instance" "cvm" {
2+
availability_zone = var.default_az
3+
image_id = var.image_id
4+
instance_name = var.cvm_name
5+
}

examples/tencentcloud-persistent-resource/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
variable "default_az" {
2+
default = "ap-guangzhou-3"
3+
}
4+
5+
variable "cvm_name" {
6+
default = "keep-cvm"
7+
}
8+
9+
# this persist exist and barely removed
10+
variable "image_id" {
11+
default = "img-2lr9q49h"
12+
}
13+
114
variable "vpn_gw" {
215
default = "kepp-vpn-gw"
316
}

tencentcloud/basic_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ resource "tencentcloud_instance" "default" {
204204
}
205205
`
206206

207+
const defaultCVMName = "keep-cvm"
208+
const presetCVM = `
209+
data "tencentcloud_instances" "instance" {
210+
instance_name = "` + defaultCVMName + `"
211+
}
212+
213+
locals {
214+
cvm_id = data.tencentcloud_instances.instance.instance_list.0.instance_id
215+
cvm_az = "` + defaultAZone + `"
216+
}
217+
`
218+
207219
const mysqlInstanceCommonTestCase = defaultVpcVariable + `
208220
resource "tencentcloud_mysql_instance" "default" {
209221
mem_size = 1000

tencentcloud/data_source_tc_cbs_snapshot_policies_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestAccTencentCloudCbsSnapshotPoliciesDataSource(t *testing.T) {
1010
t.Parallel()
1111

1212
resource.Test(t, resource.TestCase{
13-
PreCheck: func() { testAccPreCheck(t) },
13+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1414
Providers: testAccProviders,
1515
CheckDestroy: testAccCheckCbsSnapshotPolicyDestroy,
1616
Steps: []resource.TestStep{

tencentcloud/data_source_tc_cbs_snapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func TestAccTencentCloudCbsSnapshotsDataSource(t *testing.T) {
1010
t.Parallel()
1111

1212
resource.Test(t, resource.TestCase{
13-
PreCheck: func() { testAccPreCheck(t) },
13+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1414
Providers: testAccProviders,
1515
CheckDestroy: testAccCheckCbsSnapshotDestroy,
1616
Steps: []resource.TestStep{

tencentcloud/resource_tc_cbs_snapshot_policy_attachment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func TestAccTencentCloudCbsSnapshotPolicyAttachment(t *testing.T) {
1515
t.Parallel()
1616

1717
resource.Test(t, resource.TestCase{
18-
PreCheck: func() { testAccPreCheck(t) },
18+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1919
Providers: testAccProviders,
2020
CheckDestroy: testAccCheckCbsSnapshotPolicyAttachmentDestroy,
2121
Steps: []resource.TestStep{

tencentcloud/resource_tc_cbs_snapshot_policy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestAccTencentCloudCbsSnapshotPolicy(t *testing.T) {
1313
t.Parallel()
1414

1515
resource.Test(t, resource.TestCase{
16-
PreCheck: func() { testAccPreCheck(t) },
16+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1717
Providers: testAccProviders,
1818
CheckDestroy: testAccCheckCbsSnapshotPolicyDestroy,
1919
Steps: []resource.TestStep{

tencentcloud/resource_tc_cbs_snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestAccTencentCloudCbsSnapshot(t *testing.T) {
1313
t.Parallel()
1414

1515
resource.Test(t, resource.TestCase{
16-
PreCheck: func() { testAccPreCheck(t) },
16+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1717
Providers: testAccProviders,
1818
CheckDestroy: testAccCheckCbsSnapshotDestroy,
1919
Steps: []resource.TestStep{

tencentcloud/resource_tc_cbs_storage.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,13 @@ func resourceTencentCloudCbsStorageUpdate(d *schema.ResourceData, meta interface
386386
if e != nil {
387387
return retryError(e)
388388
}
389-
if storage != nil && *storage.DiskState == CBS_STORAGE_STATUS_EXPANDING {
389+
390+
if *storage.DiskState == CBS_STORAGE_STATUS_EXPANDING {
390391
return resource.RetryableError(fmt.Errorf("cbs storage status is %s", *storage.DiskState))
391392
}
393+
if *storage.DiskSize != uint64(newValue) {
394+
return resource.RetryableError(fmt.Errorf("waiting for cbs size changed to %d, now %d", newValue, *storage.DiskSize))
395+
}
392396
return nil
393397
})
394398
if err != nil {

tencentcloud/resource_tc_cbs_storage_attachment_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ func testAccCheckCbsStorageAttachmentExists(n string) resource.TestCheckFunc {
8787
}
8888
}
8989

90-
const testAccCbsStorageAttachmentConfig = instanceCommonTestCase + `
90+
const testAccCbsStorageAttachmentConfig = presetCVM + `
9191
resource "tencentcloud_cbs_storage" "foo" {
92-
availability_zone = var.availability_zone
92+
availability_zone = local.cvm_az
9393
storage_size = 100
9494
storage_type = "CLOUD_PREMIUM"
95-
storage_name = var.instance_name
95+
storage_name = "test-cbs-attachment"
96+
charge_type = "POSTPAID_BY_HOUR"
9697
}
9798
9899
resource "tencentcloud_cbs_storage_attachment" "foo" {
99100
storage_id = tencentcloud_cbs_storage.foo.id
100-
instance_id = tencentcloud_instance.default.id
101+
instance_id = local.cvm_id
101102
}
102103
`

0 commit comments

Comments
 (0)