Skip to content

Commit 726ef17

Browse files
authored
fix: mysql - retry npe err (#1460)
* fix: mysql - retry npe err * fix: mysql prepaid testcase import key * changelog 1460
1 parent d0e5bcb commit 726ef17

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

.changelog/1460.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
resource/tencentcloud_mysql_instance: fix: mysql - retry npe err
3+
```

tencentcloud/resource_tc_mysql_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ func mysqlCreateInstancePayByMonth(ctx context.Context, d *schema.ResourceData,
589589
return retryError(inErr)
590590
}
591591

592-
if response.Response.InstanceIds == nil && clientToken != "" {
592+
if r.Response.InstanceIds == nil && clientToken != "" {
593593
return resource.RetryableError(fmt.Errorf("%s returns nil instanceIds but client token provided, retrying", request.GetAction()))
594594
}
595595

tencentcloud/resource_tc_mysql_instance_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ func testSweepMySQLInstance(region string) error {
9595
return nil
9696
}
9797

98+
func TestAccTencentCloudMysqlInstanceResource_prepaid(t *testing.T) {
99+
resource.Test(t, resource.TestCase{
100+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
101+
Providers: testAccProviders,
102+
CheckDestroy: testAccCheckMysqlMasterInstanceDestroy,
103+
Steps: []resource.TestStep{
104+
{
105+
Config: testAccMySQLPrepaid,
106+
Check: resource.ComposeTestCheckFunc(
107+
testAccCheckMysqlMasterInstanceExists("tencentcloud_mysql_instance.prepaid"),
108+
resource.TestCheckResourceAttrSet("tencentcloud_mysql_instance.prepaid", "id"),
109+
resource.TestCheckResourceAttr("tencentcloud_mysql_instance.prepaid", "charge_type", "PREPAID"),
110+
),
111+
},
112+
{
113+
ResourceName: "tencentcloud_mysql_instance.prepaid",
114+
ImportState: true,
115+
ImportStateVerify: true,
116+
ImportStateVerifyIgnore: []string{"root_password", "prepaid_period", "first_slave_zone", "force_delete", "param_template_id", "fast_upgrade"},
117+
},
118+
},
119+
})
120+
}
121+
98122
func TestAccTencentCloudMysqlInstanceResource_DeviceType(t *testing.T) {
99123
resource.Test(t, resource.TestCase{
100124
PreCheck: func() { testAccPreCheck(t) },
@@ -306,6 +330,22 @@ func testAccCheckMysqlMasterInstanceExists(n string) resource.TestCheckFunc {
306330
}
307331
}
308332

333+
const testAccMySQLPrepaid = `
334+
resource "tencentcloud_mysql_instance" "prepaid" {
335+
charge_type = "PREPAID"
336+
prepaid_period = 1
337+
mem_size = 2000
338+
volume_size = 30
339+
instance_name = "testAccMysqlPrepaid"
340+
engine_version = "5.7"
341+
intranet_port = 3360
342+
root_password = "test1234"
343+
availability_zone = "ap-guangzhou-3"
344+
first_slave_zone = "ap-guangzhou-3"
345+
force_delete = true
346+
}
347+
`
348+
309349
const testAccMySQLDeviceType = `
310350
variable "temporary_param_tmpl_id" {
311351
default = 16954

0 commit comments

Comments
 (0)