From 021a1cbe7fe619178511db3671179995c50980e0 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 9826a358f3a4cd70c3df8bc981b42aa29567e90a 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 775f133865ab0babc45ea58d5dacdfe1fafed701 Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Tue, 21 Nov 2023 11:14:48 +0800 Subject: [PATCH 3/4] feat: cbs testing --- .../resource_tc_cbs_storage_testing_test.go | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tencentcloud/resource_tc_cbs_storage_testing_test.go b/tencentcloud/resource_tc_cbs_storage_testing_test.go index f871c21c47..813178a671 100644 --- a/tencentcloud/resource_tc_cbs_storage_testing_test.go +++ b/tencentcloud/resource_tc_cbs_storage_testing_test.go @@ -20,7 +20,17 @@ func TestAccTencentCloudTestingCbsStorageResource_basic(t *testing.T) { resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_name", "tf-storage-basic"), resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_type", "CLOUD_PREMIUM"), resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_size", "50"), - resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "availability_zone", "ap-guangzhou-3"), + resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "availability_zone", "ap-guangzhou-2"), + ), + }, + { + Config: testAccTestingCbsStorageUp_basic, + Check: resource.ComposeTestCheckFunc( + testAccCheckStorageExists("tencentcloud_cbs_storage.storage_basic"), + resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_name", "tf-storage-basic"), + resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_type", "CLOUD_PREMIUM"), + resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "storage_size", "100"), + resource.TestCheckResourceAttr("tencentcloud_cbs_storage.storage_basic", "availability_zone", "ap-guangzhou-2"), ), }, { @@ -38,6 +48,14 @@ resource "tencentcloud_cbs_storage" "storage_basic" { storage_type = "CLOUD_PREMIUM" storage_name = "tf-storage-basic" storage_size = 50 - availability_zone = "ap-guangzhou-3" + availability_zone = "ap-guangzhou-2" +} +` +const testAccTestingCbsStorageUp_basic = ` +resource "tencentcloud_cbs_storage" "storage_basic" { + storage_type = "CLOUD_PREMIUM" + storage_name = "tf-storage-basic" + storage_size = 100 + availability_zone = "ap-guangzhou-2" } ` From 4db5e43131f5da69ed05f75dde41bc76d56488e3 Mon Sep 17 00:00:00 2001 From: WeiMengXS Date: Tue, 21 Nov 2023 15:02:10 +0800 Subject: [PATCH 4/4] feat: teo testing --- tencentcloud/connectivity/transport.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tencentcloud/connectivity/transport.go b/tencentcloud/connectivity/transport.go index dc91c1b419..02c2a4c1f2 100644 --- a/tencentcloud/connectivity/transport.go +++ b/tencentcloud/connectivity/transport.go @@ -12,6 +12,8 @@ import ( ) const REQUEST_CLIENT = "TENCENTCLOUD_API_REQUEST_CLIENT" +const ENV_TESTING_ROUTE_USER_ID = "TENCENTCLOUD_ENV_TESTING_USER_ID" +const ENV_TESTING_ROUTE_HEADER_KEY = "x-qcloud-user-id" var ReqClient = "Terraform-latest" @@ -42,7 +44,9 @@ func (me *LogRoundTripper) RoundTrip(request *http.Request) (response *http.Resp if envReqClient := os.Getenv(REQUEST_CLIENT); envReqClient != "" { ReqClient = envReqClient } - + if routeUserID := os.Getenv(ENV_TESTING_ROUTE_USER_ID); routeUserID != "" { + request.Header.Set(ENV_TESTING_ROUTE_HEADER_KEY, routeUserID) + } request.Header.Set("X-TC-RequestClient", ReqClient) inBytes = []byte(fmt.Sprintf("%s, request: ", request.Header[headName])) requestBody, errRet := ioutil.ReadAll(bodyReader)