@@ -62,53 +62,65 @@ func TestAccTencentCloudDtsSyncConfigResource_basic(t *testing.T) {
6262 })
6363}
6464
65+ func TestAccTencentCloudDtsSyncConfigResource_ccn (t * testing.T ) {
66+ t .Parallel ()
67+ resource .Test (t , resource.TestCase {
68+ PreCheck : func () {
69+ testAccPreCheck (t )
70+ },
71+ Providers : testAccProviders ,
72+ Steps : []resource.TestStep {
73+ {
74+ Config : testAccDtsSyncConfig_ccn ,
75+ Check : resource .ComposeTestCheckFunc (
76+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "id" ),
77+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "src_access_type" , "ccn" ),
78+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "dst_access_type" , "cdb" ),
79+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "job_name" ),
80+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "job_mode" , "liteMode" ),
81+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "run_mode" , "Immediate" ),
82+ // objects
83+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.#" , "1" ),
84+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.mode" , "Partial" ),
85+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.#" , "1" ),
86+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.db_name" , "tf_ci_test" ),
87+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.new_db_name" , "tf_ci_test_new" ),
88+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.db_mode" , "Partial" ),
89+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.table_mode" , "All" ),
90+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.tables.#" , "1" ),
91+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.tables.0.table_name" , "test" ),
92+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "objects.0.databases.0.tables.0.new_table_name" , "test_new" ),
93+ // src_info dest_info
94+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "src_info.#" , "1" ),
95+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.region" , "ap-shanghai" ),
96+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.user" ),
97+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.password" ),
98+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.ip" ),
99+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.port" ),
100+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.vpc_id" ),
101+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.subnet_id" ),
102+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.ccn_id" ),
103+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "src_info.0.database_net_env" , "TencentVPC" ),
104+
105+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "dst_info.#" , "1" ),
106+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "dst_info.0.region" , "ap-guangzhou" ),
107+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "dst_info.0.instance_id" ),
108+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "dst_info.0.user" ),
109+ resource .TestCheckResourceAttrSet ("tencentcloud_dts_sync_config.sync_config" , "dst_info.0.password" ),
110+
111+ resource .TestCheckResourceAttr ("tencentcloud_dts_sync_config.sync_config" , "auto_retry_time_range_minutes" , "0" ),
112+ ),
113+ },
114+ {
115+ ResourceName : "tencentcloud_dts_sync_config.sync_config" ,
116+ ImportState : true ,
117+ },
118+ },
119+ })
120+ }
121+
65122const testAccDtsSyncConfig = testAccDtsMigrateJob_vpc_config + `
66- resource "tencentcloud_cynosdb_cluster" "foo" {
67- available_zone = var.availability_zone
68- vpc_id = local.vpc_id
69- subnet_id = local.subnet_id
70- db_type = "MYSQL"
71- db_version = "5.7"
72- storage_limit = 1000
73- cluster_name = "tf-cynosdb-mysql-sync-dst"
74- password = "cynos@123"
75- instance_maintain_duration = 3600
76- instance_maintain_start_time = 10800
77- instance_maintain_weekdays = [
78- "Fri",
79- "Mon",
80- "Sat",
81- "Sun",
82- "Thu",
83- "Wed",
84- "Tue",
85- ]
86-
87- instance_cpu_core = 1
88- instance_memory_size = 2
89- param_items {
90- name = "character_set_server"
91- current_value = "utf8"
92- }
93- param_items {
94- name = "time_zone"
95- current_value = "+09:00"
96- }
97- param_items {
98- name = "lower_case_table_names"
99- current_value = "1"
100- }
101-
102- force_delete = true
103-
104- rw_group_sg = [
105- local.sg_id
106- ]
107- ro_group_sg = [
108- local.sg_id
109- ]
110- prarm_template_id = var.my_param_template
111- }
123+
112124
113125resource "tencentcloud_dts_sync_job" "sync_job" {
114126 pay_mode = "PostPay"
@@ -157,14 +169,93 @@ resource "tencentcloud_dts_sync_config" "sync_config" {
157169 }
158170 dst_info {
159171 region = "ap-guangzhou"
160- instance_id = tencentcloud_cynosdb_cluster.foo.id
161- user = "root "
162- password = "cynos@123 "
172+ instance_id = "cynosdbmysql-bws8h88b"
173+ user = "keep_dts "
174+ password = "Letmein123 "
163175 db_name = "tf_ci_test_new"
164- vpc_id = local.vpc_id
165- subnet_id = local.subnet_id
176+ vpc_id = "vpc-pewdpc0d"
177+ subnet_id = "subnet-driddx4g"
178+ }
179+ auto_retry_time_range_minutes = 0
180+ }
181+
182+ `
183+
184+ const testAccDtsSyncConfig_ccn = `
185+
186+ locals {
187+ vpc_id_sh = "vpc-evtcyb3g"
188+ subnet_id_sh = "subnet-1t83cxkp"
189+ src_ip = data.tencentcloud_mysql_instance.src_mysql.instance_list.0.intranet_ip
190+ src_port = data.tencentcloud_mysql_instance.src_mysql.instance_list.0.intranet_port
191+ ccn_id = data.tencentcloud_ccn_instances.ccns.instance_list.0.ccn_id
192+ dst_mysql_id = data.tencentcloud_mysql_instance.dst_mysql.instance_list.0.mysql_id
193+ }
194+
195+ variable "src_az_sh" {
196+ default = "ap-shanghai"
197+ }
198+
199+ variable "dst_az_gz" {
200+ default = "ap-guangzhou"
201+ }
202+
203+ data "tencentcloud_dts_sync_jobs" "sync_jobs" {
204+ job_name = "keep_sync_config_ccn_2_cdb"
205+ }
206+
207+ data "tencentcloud_ccn_instances" "ccns" {
208+ name = "keep-ccn-dts-sh"
209+ }
210+
211+ data "tencentcloud_mysql_instance" "src_mysql" {
212+ instance_name = "keep_dts_mysql_src"
213+ }
214+
215+ data "tencentcloud_mysql_instance" "dst_mysql" {
216+ instance_name = "keep_dts_mysql_src"
217+ }
218+
219+ resource "tencentcloud_dts_sync_config" "sync_config" {
220+ job_id = data.tencentcloud_dts_sync_jobs.sync_jobs.list.0.job_id
221+ src_access_type = "ccn"
222+ dst_access_type = "cdb"
223+
224+ job_mode = "liteMode"
225+ run_mode = "Immediate"
226+
227+ objects {
228+ mode = "Partial"
229+ databases {
230+ db_name = "tf_ci_test"
231+ new_db_name = "tf_ci_test_new"
232+ db_mode = "Partial"
233+ table_mode = "All"
234+ tables {
235+ table_name = "test"
236+ new_table_name = "test_new"
237+ }
238+ }
239+ }
240+ src_info { // shanghai to guangzhou via ccn
241+ region = var.src_az_sh
242+ user = "keep_dts"
243+ password = "Letmein123"
244+ ip = local.src_ip
245+ port = local.src_port
246+ vpc_id = local.vpc_id_sh
247+ subnet_id = local.subnet_id_sh
248+ ccn_id = local.ccn_id
249+ database_net_env = "TencentVPC"
250+ }
251+ dst_info {
252+ region = var.dst_az_gz
253+ instance_id = local.dst_mysql_id
254+ user = "keep_dts"
255+ password = "Letmein123"
166256 }
167257 auto_retry_time_range_minutes = 0
168258}
169259
260+
170261`
0 commit comments