From c45eaaa0b5aaed4e50f9e690d49b681af17ff839 Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Thu, 16 Nov 2023 19:24:51 +0800 Subject: [PATCH 1/4] feat: add operation --- .../resource_tc_vpc_acl_move_left_test.go | 76 +++++++++++++++++++ .../resource_tc_vpc_dhcp_ip_move_left_test.go | 50 ++++++++++++ ...resource_tc_vpc_flow_log_move_left_test.go | 70 +++++++++++++++++ .../resource_tc_vpc_move_left_test.go | 58 ++++++++++++++ ...source_tc_vpc_net_detect_move_left_test.go | 64 ++++++++++++++++ 5 files changed, 318 insertions(+) create mode 100644 tencentcloud/resource_tc_vpc_acl_move_left_test.go create mode 100644 tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go create mode 100644 tencentcloud/resource_tc_vpc_flow_log_move_left_test.go create mode 100644 tencentcloud/resource_tc_vpc_move_left_test.go create mode 100644 tencentcloud/resource_tc_vpc_net_detect_move_left_test.go diff --git a/tencentcloud/resource_tc_vpc_acl_move_left_test.go b/tencentcloud/resource_tc_vpc_acl_move_left_test.go new file mode 100644 index 0000000000..b1d48da0e5 --- /dev/null +++ b/tencentcloud/resource_tc_vpc_acl_move_left_test.go @@ -0,0 +1,76 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudMoveLeftVpcAclRulesResource_Update(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMoveLeftVpcACLConfig, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#80#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#80#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), + ), + }, + { + Config: testAccMoveLeftVpcACLConfigUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#800#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#800#TCP"), + resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), + ), + }, + }, + }) +} + +const testAccMoveLeftVpcACLConfig = defaultVpcVariable + ` +resource "tencentcloud_vpc" "foo" { + name = var.instance_name + cidr_block = var.vpc_cidr +} +resource "tencentcloud_vpc_acl" "foo" { + vpc_id = tencentcloud_vpc.foo.id + name = "test_acl" + ingress = [ + "ACCEPT#192.168.1.0/24#80#TCP", + "ACCEPT#192.168.1.0/24#80-90#TCP", + ] + egress = [ + "ACCEPT#192.168.1.0/24#80#TCP", + "ACCEPT#192.168.1.0/24#80-90#TCP", + ] +} +` + +const testAccMoveLeftVpcACLConfigUpdate = defaultVpcVariable + ` +resource "tencentcloud_vpc" "foo" { + name = var.instance_name + cidr_block = var.vpc_cidr +} + +resource "tencentcloud_vpc_acl" "foo" { + vpc_id = tencentcloud_vpc.foo.id + name = "test_acl" + ingress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] + egress = [ + "ACCEPT#192.168.1.0/24#800#TCP", + "ACCEPT#192.168.1.0/24#800-900#TCP", + ] +} +` diff --git a/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go b/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go new file mode 100644 index 0000000000..8306ec25c2 --- /dev/null +++ b/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go @@ -0,0 +1,50 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudMoveLeftVpcDhcpIpResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMoveLeftVpcDhcpIp, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_vpc_dhcp_ip.example", "id")), + }, + { + ResourceName: "tencentcloud_vpc_dhcp_ip.example", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccMoveLeftVpcDhcpIp = ` + +resource "tencentcloud_vpc" "vpc" { + name = "vpc-example" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = "ap-guangzhou-2" + name = "subnet-example" + vpc_id = tencentcloud_vpc.vpc.id + cidr_block = "10.0.0.0/16" + is_multicast = false +} + +resource "tencentcloud_vpc_dhcp_ip" "example" { + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + dhcp_ip_name = "tf-example" +} +` diff --git a/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go b/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go new file mode 100644 index 0000000000..b9821c40db --- /dev/null +++ b/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go @@ -0,0 +1,70 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudMoveLeftVpcFlowLogResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMoveLeftVpcFlowLog, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_vpc_flow_log.flow_log", "id"), + resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_name", "iac-test-1"), + resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_description", "this is a testing flow log"), + ), + }, + { + ResourceName: "tencentcloud_vpc_flow_log.flow_log", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "cloud_log_region", + "flow_log_storage", + }, + }, + { + Config: testAccMoveLeftVpcFlowLogUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("tencentcloud_vpc_flow_log.flow_log", "id"), + resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_name", "iac-test-2"), + resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_description", "updated"), + ), + }, + }, + }) +} + +const testAccMoveLeftVpcFlowLog = ` + +resource "tencentcloud_vpc_flow_log" "flow_log" { + flow_log_name = "iac-test-1" + resource_type = "NETWORKINTERFACE" + resource_id = "eni-qz9wxgmd" + traffic_type = "ACCEPT" + vpc_id = "vpc-humgpppd" + flow_log_description = "this is a testing flow log" + cloud_log_id = "e6acd27c-365c-4959-8257-751d86657439" # FIXME use data.logsets (not supported) instead + storage_type = "cls" +} +` + +const testAccMoveLeftVpcFlowLogUpdate = ` +resource "tencentcloud_vpc_flow_log" "flow_log" { + flow_log_name = "iac-test-2" + resource_type = "NETWORKINTERFACE" + resource_id = "eni-qz9wxgmd" + traffic_type = "ACCEPT" + vpc_id = "vpc-humgpppd" + flow_log_description = "updated" + cloud_log_id = "e6acd27c-365c-4959-8257-751d86657439" # FIXME use data.logsets (not supported) instead + storage_type = "cls" +} +` diff --git a/tencentcloud/resource_tc_vpc_move_left_test.go b/tencentcloud/resource_tc_vpc_move_left_test.go new file mode 100644 index 0000000000..6d87cb4304 --- /dev/null +++ b/tencentcloud/resource_tc_vpc_move_left_test.go @@ -0,0 +1,58 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudMoveLeftVpcV3Update(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMoveLeftVpcConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("tencentcloud_vpc.foo"), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "cidr_block", defaultVpcCidr), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "name", defaultInsName), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "is_multicast", "true"), + + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "is_default"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "dns_servers.#"), + ), + }, + { + Config: testAccMoveLeftVpcConfigUpdate, + Check: resource.ComposeTestCheckFunc( + testAccCheckVpcExists("tencentcloud_vpc.foo"), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "cidr_block", defaultVpcCidrLess), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "name", defaultInsNameUpdate), + resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "is_multicast", "false"), + + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "is_default"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "dns_servers.#"), + ), + }, + }, + }) +} + +const testAccMoveLeftVpcConfig = defaultVpcVariable + ` +resource "tencentcloud_vpc" "foo" { + name = var.instance_name + cidr_block = var.vpc_cidr +} +` + +const testAccMoveLeftVpcConfigUpdate = defaultVpcVariable + ` +resource "tencentcloud_vpc" "foo" { + name = var.instance_name_update + cidr_block = var.vpc_cidr_less + + is_multicast = false +} +` diff --git a/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go b/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go new file mode 100644 index 0000000000..2155d7e6d1 --- /dev/null +++ b/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go @@ -0,0 +1,64 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudMoveLeftVpcNetDetectResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccMoveLeftVpcNetDetect, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_vpc_net_detect.net_detect", "id")), + }, + { + Config: testAccMoveLeftVpcNetDetectUpdate, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("tencentcloud_vpc_net_detect.net_detect", "net_detect_name", "terraform-for-test"), + ), + }, + { + ResourceName: "tencentcloud_vpc_net_detect.net_detect", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccMoveLeftVpcNetDetect = ` + +resource "tencentcloud_vpc_net_detect" "net_detect" { + net_detect_name = "terraform-test" + vpc_id = "vpc-jxnxbc07" + subnet_id = "subnet-ev908x0w" + next_hop_destination = "nat-bfnnl8wg" + next_hop_type = "NAT" + detect_destination_ip = [ + "172.16.128.110" + ] +} + +` + +const testAccMoveLeftVpcNetDetectUpdate = ` + +resource "tencentcloud_vpc_net_detect" "net_detect" { + net_detect_name = "terraform-for-test" + vpc_id = "vpc-jxnxbc07" + subnet_id = "subnet-ev908x0w" + next_hop_destination = "nat-bfnnl8wg" + next_hop_type = "NAT" + detect_destination_ip = [ + "172.16.128.110" + ] +} + +` From 88a731bd8cac0713186f29a99ed99f565c8bd6db Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Mon, 20 Nov 2023 16:02:16 +0800 Subject: [PATCH 2/4] feat: cdb testing --- .../resource_tc_vpc_acl_move_left_test.go | 76 ------------------- .../resource_tc_vpc_dhcp_ip_move_left_test.go | 50 ------------ ...resource_tc_vpc_flow_log_move_left_test.go | 70 ----------------- .../resource_tc_vpc_move_left_test.go | 58 -------------- ...source_tc_vpc_net_detect_move_left_test.go | 64 ---------------- 5 files changed, 318 deletions(-) delete mode 100644 tencentcloud/resource_tc_vpc_acl_move_left_test.go delete mode 100644 tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go delete mode 100644 tencentcloud/resource_tc_vpc_flow_log_move_left_test.go delete mode 100644 tencentcloud/resource_tc_vpc_move_left_test.go delete mode 100644 tencentcloud/resource_tc_vpc_net_detect_move_left_test.go diff --git a/tencentcloud/resource_tc_vpc_acl_move_left_test.go b/tencentcloud/resource_tc_vpc_acl_move_left_test.go deleted file mode 100644 index b1d48da0e5..0000000000 --- a/tencentcloud/resource_tc_vpc_acl_move_left_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package tencentcloud - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccTencentCloudMoveLeftVpcAclRulesResource_Update(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMoveLeftVpcACLConfig, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#80#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#80#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#80-90#TCP"), - ), - }, - { - Config: testAccMoveLeftVpcACLConfigUpdate, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "name", "test_acl"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.0", "ACCEPT#192.168.1.0/24#800#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "ingress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.0", "ACCEPT#192.168.1.0/24#800#TCP"), - resource.TestCheckResourceAttr("tencentcloud_vpc_acl.foo", "egress.1", "ACCEPT#192.168.1.0/24#800-900#TCP"), - ), - }, - }, - }) -} - -const testAccMoveLeftVpcACLConfig = defaultVpcVariable + ` -resource "tencentcloud_vpc" "foo" { - name = var.instance_name - cidr_block = var.vpc_cidr -} -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = tencentcloud_vpc.foo.id - name = "test_acl" - ingress = [ - "ACCEPT#192.168.1.0/24#80#TCP", - "ACCEPT#192.168.1.0/24#80-90#TCP", - ] - egress = [ - "ACCEPT#192.168.1.0/24#80#TCP", - "ACCEPT#192.168.1.0/24#80-90#TCP", - ] -} -` - -const testAccMoveLeftVpcACLConfigUpdate = defaultVpcVariable + ` -resource "tencentcloud_vpc" "foo" { - name = var.instance_name - cidr_block = var.vpc_cidr -} - -resource "tencentcloud_vpc_acl" "foo" { - vpc_id = tencentcloud_vpc.foo.id - name = "test_acl" - ingress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] - egress = [ - "ACCEPT#192.168.1.0/24#800#TCP", - "ACCEPT#192.168.1.0/24#800-900#TCP", - ] -} -` diff --git a/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go b/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go deleted file mode 100644 index 8306ec25c2..0000000000 --- a/tencentcloud/resource_tc_vpc_dhcp_ip_move_left_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package tencentcloud - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccTencentCloudMoveLeftVpcDhcpIpResource_basic(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMoveLeftVpcDhcpIp, - Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_vpc_dhcp_ip.example", "id")), - }, - { - ResourceName: "tencentcloud_vpc_dhcp_ip.example", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -const testAccMoveLeftVpcDhcpIp = ` - -resource "tencentcloud_vpc" "vpc" { - name = "vpc-example" - cidr_block = "10.0.0.0/16" -} - -resource "tencentcloud_subnet" "subnet" { - availability_zone = "ap-guangzhou-2" - name = "subnet-example" - vpc_id = tencentcloud_vpc.vpc.id - cidr_block = "10.0.0.0/16" - is_multicast = false -} - -resource "tencentcloud_vpc_dhcp_ip" "example" { - vpc_id = tencentcloud_vpc.vpc.id - subnet_id = tencentcloud_subnet.subnet.id - dhcp_ip_name = "tf-example" -} -` diff --git a/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go b/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go deleted file mode 100644 index b9821c40db..0000000000 --- a/tencentcloud/resource_tc_vpc_flow_log_move_left_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package tencentcloud - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "testing" -) - -func TestAccTencentCloudMoveLeftVpcFlowLogResource_basic(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMoveLeftVpcFlowLog, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("tencentcloud_vpc_flow_log.flow_log", "id"), - resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_name", "iac-test-1"), - resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_description", "this is a testing flow log"), - ), - }, - { - ResourceName: "tencentcloud_vpc_flow_log.flow_log", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{ - "cloud_log_region", - "flow_log_storage", - }, - }, - { - Config: testAccMoveLeftVpcFlowLogUpdate, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("tencentcloud_vpc_flow_log.flow_log", "id"), - resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_name", "iac-test-2"), - resource.TestCheckResourceAttr("tencentcloud_vpc_flow_log.flow_log", "flow_log_description", "updated"), - ), - }, - }, - }) -} - -const testAccMoveLeftVpcFlowLog = ` - -resource "tencentcloud_vpc_flow_log" "flow_log" { - flow_log_name = "iac-test-1" - resource_type = "NETWORKINTERFACE" - resource_id = "eni-qz9wxgmd" - traffic_type = "ACCEPT" - vpc_id = "vpc-humgpppd" - flow_log_description = "this is a testing flow log" - cloud_log_id = "e6acd27c-365c-4959-8257-751d86657439" # FIXME use data.logsets (not supported) instead - storage_type = "cls" -} -` - -const testAccMoveLeftVpcFlowLogUpdate = ` -resource "tencentcloud_vpc_flow_log" "flow_log" { - flow_log_name = "iac-test-2" - resource_type = "NETWORKINTERFACE" - resource_id = "eni-qz9wxgmd" - traffic_type = "ACCEPT" - vpc_id = "vpc-humgpppd" - flow_log_description = "updated" - cloud_log_id = "e6acd27c-365c-4959-8257-751d86657439" # FIXME use data.logsets (not supported) instead - storage_type = "cls" -} -` diff --git a/tencentcloud/resource_tc_vpc_move_left_test.go b/tencentcloud/resource_tc_vpc_move_left_test.go deleted file mode 100644 index 6d87cb4304..0000000000 --- a/tencentcloud/resource_tc_vpc_move_left_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package tencentcloud - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "testing" -) - -func TestAccTencentCloudMoveLeftVpcV3Update(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMoveLeftVpcConfig, - Check: resource.ComposeTestCheckFunc( - testAccCheckVpcExists("tencentcloud_vpc.foo"), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "cidr_block", defaultVpcCidr), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "name", defaultInsName), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "is_multicast", "true"), - - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "is_default"), - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "create_time"), - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "dns_servers.#"), - ), - }, - { - Config: testAccMoveLeftVpcConfigUpdate, - Check: resource.ComposeTestCheckFunc( - testAccCheckVpcExists("tencentcloud_vpc.foo"), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "cidr_block", defaultVpcCidrLess), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "name", defaultInsNameUpdate), - resource.TestCheckResourceAttr("tencentcloud_vpc.foo", "is_multicast", "false"), - - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "is_default"), - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "create_time"), - resource.TestCheckResourceAttrSet("tencentcloud_vpc.foo", "dns_servers.#"), - ), - }, - }, - }) -} - -const testAccMoveLeftVpcConfig = defaultVpcVariable + ` -resource "tencentcloud_vpc" "foo" { - name = var.instance_name - cidr_block = var.vpc_cidr -} -` - -const testAccMoveLeftVpcConfigUpdate = defaultVpcVariable + ` -resource "tencentcloud_vpc" "foo" { - name = var.instance_name_update - cidr_block = var.vpc_cidr_less - - is_multicast = false -} -` diff --git a/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go b/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go deleted file mode 100644 index 2155d7e6d1..0000000000 --- a/tencentcloud/resource_tc_vpc_net_detect_move_left_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package tencentcloud - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccTencentCloudMoveLeftVpcNetDetectResource_basic(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccMoveLeftVpcNetDetect, - Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_vpc_net_detect.net_detect", "id")), - }, - { - Config: testAccMoveLeftVpcNetDetectUpdate, - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("tencentcloud_vpc_net_detect.net_detect", "net_detect_name", "terraform-for-test"), - ), - }, - { - ResourceName: "tencentcloud_vpc_net_detect.net_detect", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -const testAccMoveLeftVpcNetDetect = ` - -resource "tencentcloud_vpc_net_detect" "net_detect" { - net_detect_name = "terraform-test" - vpc_id = "vpc-jxnxbc07" - subnet_id = "subnet-ev908x0w" - next_hop_destination = "nat-bfnnl8wg" - next_hop_type = "NAT" - detect_destination_ip = [ - "172.16.128.110" - ] -} - -` - -const testAccMoveLeftVpcNetDetectUpdate = ` - -resource "tencentcloud_vpc_net_detect" "net_detect" { - net_detect_name = "terraform-for-test" - vpc_id = "vpc-jxnxbc07" - subnet_id = "subnet-ev908x0w" - next_hop_destination = "nat-bfnnl8wg" - next_hop_type = "NAT" - detect_destination_ip = [ - "172.16.128.110" - ] -} - -` From 82b6da2bf36d2a0e9001d9e71fc72bebcea6fd74 Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Tue, 21 Nov 2023 20:14:09 +0800 Subject: [PATCH 3/4] feat: clb testing --- .../resource_tc_clb_instance_testing_test.go | 168 ++++++++++++++++++ .../resource_tc_clb_listener_testing_test.go | 79 ++++++++ ..._security_group_attachment_testing_test.go | 37 ++++ ..._group_instance_attachment_testing_test.go | 67 +++++++ ...source_tc_clb_target_group_testing_test.go | 85 +++++++++ 5 files changed, 436 insertions(+) create mode 100644 tencentcloud/resource_tc_clb_instance_testing_test.go create mode 100644 tencentcloud/resource_tc_clb_listener_testing_test.go create mode 100644 tencentcloud/resource_tc_clb_security_group_attachment_testing_test.go create mode 100644 tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go create mode 100644 tencentcloud/resource_tc_clb_target_group_testing_test.go diff --git a/tencentcloud/resource_tc_clb_instance_testing_test.go b/tencentcloud/resource_tc_clb_instance_testing_test.go new file mode 100644 index 0000000000..57fd98d6ee --- /dev/null +++ b/tencentcloud/resource_tc_clb_instance_testing_test.go @@ -0,0 +1,168 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudTestingClbInstanceResource_basic(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbInstance_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.clb_basic"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_basic", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_basic", "clb_name", BasicClbName), + ), + }, + { + ResourceName: "tencentcloud_clb_instance.clb_basic", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"dynamic_vip"}, + }, + }, + }) +} + +func TestAccTencentCloudTestingClbInstanceResource_open(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbInstance_open, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.clb_open"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "clb_name", OpenClbName), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "project_id", "0"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "security_groups.#", "1"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.clb_open", "security_groups.0"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "target_region_info_region", "ap-guangzhou"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.clb_open", "target_region_info_vpc_id"), + ), + }, + { + Config: testAccTestingClbInstance_update_open, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.clb_open"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "clb_name", OpenClbNameUpdate), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "project_id", "0"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.clb_open", "vpc_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "security_groups.#", "1"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.clb_open", "security_groups.0"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.clb_open", "target_region_info_region", "ap-guangzhou"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.clb_open", "target_region_info_vpc_id"), + ), + }, + }, + }) +} + +func TestAccTencentCloudClbTestingInstanceResource_multiple_instance(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbInstance_Multi_Instance, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.multiple_instance"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "clb_name", MultiClbName), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "master_zone_id", "100004"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "slave_zone_id", "100003"), + ), + }, + { + Config: testAccTestingClbInstance_Multi_Instance_Update, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.multiple_instance"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "clb_name", MultiClbName), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "master_zone_id", "100004"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "slave_zone_id", "100003"), + ), + }, + }, + }) +} + +const testAccTestingClbInstance_basic = ` +resource "tencentcloud_clb_instance" "clb_basic" { + network_type = "OPEN" + clb_name = "` + BasicClbName + `" +} +` + +const testAccTestingClbInstance_open = ` +resource "tencentcloud_security_group" "foo" { + name = "keep-ci-temp-test-sg" +} + +resource "tencentcloud_vpc" "foo" { + name = "clb-instance-open-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_clb_instance" "clb_open" { + network_type = "OPEN" + clb_name = "` + OpenClbName + `" + project_id = 0 + vpc_id = tencentcloud_vpc.foo.id + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + security_groups = [tencentcloud_security_group.foo.id] +} +` +const testAccTestingClbInstance_update_open = ` +resource "tencentcloud_security_group" "foo" { + name = "clb-instance-sg" +} + +resource "tencentcloud_vpc" "foo" { + name = "clb-instance-open-vpc" + cidr_block = "10.0.0.0/16" +} + +resource "tencentcloud_clb_instance" "clb_open" { + network_type = "OPEN" + clb_name = "` + OpenClbNameUpdate + `" + vpc_id = tencentcloud_vpc.foo.id + project_id = 0 + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + security_groups = [tencentcloud_security_group.foo.id] +} +` +const testAccTestingClbInstance_Multi_Instance = ` +resource "tencentcloud_clb_instance" "multiple_instance" { + network_type = "OPEN" + clb_name = "` + MultiClbName + `" + master_zone_id = "100004" + slave_zone_id = "100003" +} +` + +const testAccTestingClbInstance_Multi_Instance_Update = ` +resource "tencentcloud_clb_instance" "multiple_instance" { + network_type = "OPEN" + clb_name = "` + MultiClbName + `" + master_zone_id = "100004" + slave_zone_id = "100003" +} +` diff --git a/tencentcloud/resource_tc_clb_listener_testing_test.go b/tencentcloud/resource_tc_clb_listener_testing_test.go new file mode 100644 index 0000000000..5c8fd97f5d --- /dev/null +++ b/tencentcloud/resource_tc_clb_listener_testing_test.go @@ -0,0 +1,79 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudTestingClbListener_basic(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbListenerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccClbTestingListener_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbListenerExists("tencentcloud_clb_listener.listener_basic"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_listener.listener_basic", "clb_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "protocol", "TCP"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "listener_name", "listener_basic"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "session_expire_time", "30"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "port", "1"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "scheduler", "WRR"), + ), + }, + { + Config: testAccClbTestingListenerUpdate_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbListenerExists("tencentcloud_clb_listener.listener_basic"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_listener.listener_basic", "clb_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "protocol", "TCP"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "listener_name", "listener_basic_update"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "session_expire_time", "30"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "port", "1"), + resource.TestCheckResourceAttr("tencentcloud_clb_listener.listener_basic", "scheduler", "WRR"), + ), + }, + { + ResourceName: "tencentcloud_clb_listener.listener_basic", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccClbTestingListener_basic = ` +resource "tencentcloud_clb_instance" "clb_basic" { + network_type = "OPEN" + clb_name = "tf-clb-listener-basic" +} + +resource "tencentcloud_clb_listener" "listener_basic" { + clb_id = tencentcloud_clb_instance.clb_basic.id + port = 1 + protocol = "TCP" + listener_name = "listener_basic" + session_expire_time = 30 + scheduler = "WRR" + target_type = "TARGETGROUP" +} +` +const testAccClbTestingListenerUpdate_basic = ` +resource "tencentcloud_clb_instance" "clb_basic" { + network_type = "OPEN" + clb_name = "tf-clb-listener-basic" +} +resource "tencentcloud_clb_listener" "listener_basic" { + clb_id = tencentcloud_clb_instance.clb_basic.id + port = 1 + protocol = "TCP" + listener_name = "listener_basic_update" + session_expire_time = 30 + scheduler = "WRR" + target_type = "TARGETGROUP" +} +` diff --git a/tencentcloud/resource_tc_clb_security_group_attachment_testing_test.go b/tencentcloud/resource_tc_clb_security_group_attachment_testing_test.go new file mode 100644 index 0000000000..37c77bb604 --- /dev/null +++ b/tencentcloud/resource_tc_clb_security_group_attachment_testing_test.go @@ -0,0 +1,37 @@ +package tencentcloud + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccTencentCloudTestingClbSecurityGroupAttachmentResource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbSecurityGroupAttachment, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_clb_security_group_attachment.security_group_attachment", "id")), + }, + { + ResourceName: "tencentcloud_clb_security_group_attachment.security_group_attachment", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +const testAccTestingClbSecurityGroupAttachment = ` + +resource "tencentcloud_clb_security_group_attachment" "security_group_attachment" { + security_group = "sg-46x20487" + load_balancer_ids = ["lb-d72hklcc"] +} + +` diff --git a/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go b/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go new file mode 100644 index 0000000000..b3df132cab --- /dev/null +++ b/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go @@ -0,0 +1,67 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudTestingClbTGAttachmentInstance_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbTGAttachmentInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbTGAttachmentInstance_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbTGAttachmentInstanceExists("tencentcloud_clb_target_group_instance_attachment.test"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "target_group_id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "port"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "weight"), + ), + }, + { + Config: testAccTestingClbTGAttachmentInstance_update, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbTGAttachmentInstanceExists("tencentcloud_clb_target_group_instance_attachment.test"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "target_group_id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "port"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "weight"), + ), + }, + }, + }) +} + +const testAccTestingClbTGAttachmentInstance_basic = ` + +resource "tencentcloud_clb_target_group" "test"{ + target_group_name = "test" + vpc_id = "vpc-humgpppd" +} + +resource "tencentcloud_clb_target_group_instance_attachment" "test"{ + target_group_id = tencentcloud_clb_target_group.test.id + bind_ip = "172.16.0.17" + port = 99 + weight = 3 +} +` + +const testAccTestingClbTGAttachmentInstance_update = ` + +resource "tencentcloud_clb_target_group" "test"{ + target_group_name = "test" + vpc_id = "vpc-humgpppd" +} + +resource "tencentcloud_clb_target_group_instance_attachment" "test"{ + target_group_id = tencentcloud_clb_target_group.test.id + bind_ip = "172.16.0.17" + port = 99 + weight = 5 +} +` diff --git a/tencentcloud/resource_tc_clb_target_group_testing_test.go b/tencentcloud/resource_tc_clb_target_group_testing_test.go new file mode 100644 index 0000000000..3f50a80873 --- /dev/null +++ b/tencentcloud/resource_tc_clb_target_group_testing_test.go @@ -0,0 +1,85 @@ +package tencentcloud + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "testing" +) + +func TestAccTencentCloudTestingClbTargetGroup_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbTargetGroupDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbTargetGroup_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbTargetGroupExists("tencentcloud_clb_target_group.test"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group.test", "target_group_name"), + ), + }, + }, + }) +} + +func TestAccTencentCloudTestingClbInstanceTargetGroup(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccTestingClbInstanceTargetGroup, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbTargetGroupExists("tencentcloud_clb_target_group.target_group"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "target_group_name", "tgt_grp_test"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "port", "33"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "vpc_id", "vpc-humgpppd"), + ), + }, + { + Config: testAccTestingClbInstanceTargetGroupUpdate, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbTargetGroupExists("tencentcloud_clb_target_group.target_group"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "target_group_name", "tgt_grp_test"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "port", "44"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group.target_group", "vpc_id", "vpc-humgpppd"), + ), + }, + }, + }) +} + +const testAccTestingClbTargetGroup_basic = ` +resource "tencentcloud_clb_target_group" "test"{ + target_group_name = "qwe" +} +` + +const testAccTestingClbInstanceTargetGroup = ` + +resource "tencentcloud_clb_target_group" "target_group" { + target_group_name = "tgt_grp_test" + port = 33 + vpc_id = "vpc-humgpppd" + target_group_instances { + bind_ip = "172.16.0.17" + port = 18800 + } +} +` + +const testAccTestingClbInstanceTargetGroupUpdate = ` +resource "tencentcloud_clb_target_group" "target_group" { + target_group_name = "tgt_grp_test" + port = 44 + vpc_id = "vpc-humgpppd" + target_group_instances { + bind_ip = "172.16.0.17" + port = 18800 + } +} +` From cf23929863919c3f8a877d6abd9c05ef70d1c46a Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Tue, 21 Nov 2023 20:16:04 +0800 Subject: [PATCH 4/4] feat: clb testing --- ..._target_group_instance_attachment_testing_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go b/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go index b3df132cab..8297dbe0d7 100644 --- a/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go +++ b/tencentcloud/resource_tc_clb_target_group_instance_attachment_testing_test.go @@ -17,9 +17,9 @@ func TestAccTencentCloudTestingClbTGAttachmentInstance_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckClbTGAttachmentInstanceExists("tencentcloud_clb_target_group_instance_attachment.test"), resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "target_group_id"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "port"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "weight"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip", "172.16.0.17"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "port", "99"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "weight", "3"), ), }, { @@ -27,9 +27,9 @@ func TestAccTencentCloudTestingClbTGAttachmentInstance_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckClbTGAttachmentInstanceExists("tencentcloud_clb_target_group_instance_attachment.test"), resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "target_group_id"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "port"), - resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_instance_attachment.test", "weight"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "bind_ip", "172.16.0.17"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "port", "99"), + resource.TestCheckResourceAttr("tencentcloud_clb_target_group_instance_attachment.test", "weight", "5"), ), }, },