@@ -14,6 +14,7 @@ import (
1414)
1515
1616const TestAccTencentCloudMysqlMasterInstance_availability_zone = "ap-guangzhou-3"
17+ const TestAccTencentCloudMysqlMasterInstance_availability_zone_4 = "ap-guangzhou-4"
1718const TestAccTencentCloudMysqlInstanceName = "testAccMysql"
1819
1920func init () {
@@ -110,18 +111,20 @@ func TestAccTencentCloudMysqlInstanceResource_prepaid(t *testing.T) {
110111 resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.prepaid" , "charge_type" , "PREPAID" ),
111112 resource .TestCheckResourceAttrSet ("tencentcloud_mysql_instance.prepaid" , "vpc_id" ),
112113 resource .TestCheckResourceAttrSet ("tencentcloud_mysql_instance.prepaid" , "subnet_id" ),
114+ resource .TestCheckResourceAttrSet ("tencentcloud_mysql_instance.prepaid" , "first_slave_zone" ),
113115 ),
114116 },
115117 {
116118 ResourceName : "tencentcloud_mysql_instance.prepaid" ,
117119 ImportState : true ,
118120 ImportStateVerify : true ,
119- ImportStateVerifyIgnore : []string {"root_password" , "prepaid_period" , "first_slave_zone" , " force_delete" , "param_template_id" , "fast_upgrade" },
121+ ImportStateVerifyIgnore : []string {"root_password" , "prepaid_period" , "force_delete" , "param_template_id" , "fast_upgrade" },
120122 },
121123 },
122124 })
123125}
124126
127+ // go test -i; go test -test.run TestAccTencentCloudMysqlInstanceResource_DeviceType -v
125128func TestAccTencentCloudMysqlInstanceResource_DeviceType (t * testing.T ) {
126129 resource .Test (t , resource.TestCase {
127130 PreCheck : func () { testAccPreCheck (t ) },
@@ -133,13 +136,14 @@ func TestAccTencentCloudMysqlInstanceResource_DeviceType(t *testing.T) {
133136 Check : resource .ComposeAggregateTestCheckFunc (
134137 testAccCheckMysqlMasterInstanceExists ("tencentcloud_mysql_instance.mysql_exclusive" ),
135138 resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_exclusive" , "device_type" , "EXCLUSIVE" ),
139+ resource .TestCheckResourceAttrSet ("tencentcloud_mysql_instance.mysql_exclusive" , "first_slave_zone" ),
136140 ),
137141 },
138142 {
139143 ResourceName : "tencentcloud_mysql_instance.mysql_exclusive" ,
140144 ImportState : true ,
141145 ImportStateVerify : true ,
142- ImportStateVerifyIgnore : []string {"root_password" , "prepaid_period" , "first_slave_zone" , " force_delete" , "param_template_id" , "fast_upgrade" },
146+ ImportStateVerifyIgnore : []string {"root_password" , "prepaid_period" , "force_delete" , "param_template_id" , "fast_upgrade" },
143147 },
144148 {
145149 Config : testAccMySQLDeviceTypeUpdate ,
@@ -152,6 +156,7 @@ func TestAccTencentCloudMysqlInstanceResource_DeviceType(t *testing.T) {
152156 })
153157}
154158
159+ // go test -i; go test -test.run TestAccTencentCloudMysqlInstanceResource_MasterInstance_fullslave -v
155160func TestAccTencentCloudMysqlInstanceResource_MasterInstance_fullslave (t * testing.T ) {
156161 resource .Test (t , resource.TestCase {
157162 PreCheck : func () { testAccPreCheck (t ) },
@@ -170,6 +175,18 @@ func TestAccTencentCloudMysqlInstanceResource_MasterInstance_fullslave(t *testin
170175 resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "second_slave_zone" , TestAccTencentCloudMysqlMasterInstance_availability_zone ),
171176 ),
172177 },
178+ {
179+ Config : testAccMysqlMasterInstanceUp_fullslave (),
180+ Check : resource .ComposeAggregateTestCheckFunc (
181+ testAccCheckMysqlMasterInstanceExists ("tencentcloud_mysql_instance.mysql_master" ),
182+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "instance_name" , TestAccTencentCloudMysqlInstanceName ),
183+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "slave_deploy_mode" , "1" ),
184+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "slave_sync_mode" , "1" ),
185+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "availability_zone" , TestAccTencentCloudMysqlMasterInstance_availability_zone ),
186+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "first_slave_zone" , TestAccTencentCloudMysqlMasterInstance_availability_zone_4 ),
187+ resource .TestCheckResourceAttr ("tencentcloud_mysql_instance.mysql_master" , "second_slave_zone" , TestAccTencentCloudMysqlMasterInstance_availability_zone_4 ),
188+ ),
189+ },
173190 },
174191 })
175192}
@@ -408,7 +425,7 @@ resource "tencentcloud_mysql_instance" "prepaid" {
408425
409426const testAccMySQLDeviceType = `
410427variable "temporary_param_tmpl_id" {
411- default = 16954
428+ default = 19656
412429}
413430
414431resource "tencentcloud_mysql_instance" "mysql_exclusive" {
@@ -430,7 +447,7 @@ resource "tencentcloud_mysql_instance" "mysql_exclusive" {
430447
431448const testAccMySQLDeviceTypeUpdate = `
432449variable "temporary_param_tmpl_id" {
433- default = 16954
450+ default = 19656
434451}
435452
436453resource "tencentcloud_mysql_instance" "mysql_exclusive" {
@@ -486,6 +503,25 @@ resource "tencentcloud_mysql_instance" "mysql_master" {
486503}`
487504}
488505
506+ func testAccMysqlMasterInstanceUp_fullslave () string {
507+ return `
508+ resource "tencentcloud_mysql_instance" "mysql_master" {
509+ charge_type = "POSTPAID"
510+ mem_size = 1000
511+ volume_size = 50
512+ instance_name = "testAccMysql"
513+ engine_version = "5.7"
514+ root_password = "test1234"
515+ intranet_port = 3360
516+ availability_zone = "ap-guangzhou-3"
517+ slave_deploy_mode = 1
518+ first_slave_zone = "ap-guangzhou-4"
519+ second_slave_zone = "ap-guangzhou-4"
520+ slave_sync_mode = 1
521+ force_delete = true
522+ }`
523+ }
524+
489525func testAccMysqlMasterInstance_internet_service (open bool ) string {
490526 tag := "0"
491527 if open {
0 commit comments