Skip to content

Commit 49a7e2c

Browse files
authored
fix sat testcases (#1036)
1 parent 2b112cf commit 49a7e2c

File tree

3 files changed

+41
-274
lines changed

3 files changed

+41
-274
lines changed

tencentcloud/data_source_tc_nat_gateway_snats_test.go

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,34 @@ func TestAccTencentCloudNatGatewaySnatsDataSource(t *testing.T) {
1616
Config: testAccTencentCloudNatGatewaySnatsDataSourceConfig_basic,
1717
Check: resource.ComposeTestCheckFunc(
1818
testAccCheckTencentCloudDataSourceID("data.tencentcloud_nat_gateway_snats.snat"),
19-
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "nats.#", "2"),
20-
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "nats.0.resource_type", "SUBNET"),
21-
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "nats.1.resource_type", "NETWORKINTERFACE"),
22-
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "nats.0.description", "terraform test"),
23-
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "nats.1.description", "terraform test"),
19+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "snat_list.#", "2"),
20+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "snat_list.0.resource_type", "SUBNET"),
21+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "snat_list.1.resource_type", "NETWORKINTERFACE"),
22+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "snat_list.0.description", "terraform test"),
23+
resource.TestCheckResourceAttr("data.tencentcloud_nat_gateway_snats.snat", "snat_list.1.description", "terraform test"),
2424
),
2525
},
2626
},
2727
})
2828
}
2929

3030
const testAccTencentCloudNatGatewaySnatsDataSourceConfig_basic = `
31-
data "tencentcloud_availability_zones" "my_zones" {}
32-
33-
data "tencentcloud_vpc" "my_vpc" {
31+
data "tencentcloud_vpc_instances" "my_vpc" {
3432
name = "Default-VPC"
3533
}
3634
35+
data "tencentcloud_vpc_subnets" "my_subnet" {
36+
vpc_id = data.tencentcloud_vpc_instances.my_vpc.instance_list.0.vpc_id
37+
subnet_id = "subnet-4o0zd840"
38+
}
39+
3740
data "tencentcloud_images" "my_image" {
3841
os_name = "centos"
3942
}
4043
4144
data "tencentcloud_instance_types" "my_instance_types" {
4245
cpu_core_count = 1
4346
memory_size = 1
44-
availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name
4547
}
4648
4749
# Create EIP
@@ -54,8 +56,8 @@ resource "tencentcloud_eip" "eip_test_dnat" {
5456
5557
# Create NAT Gateway
5658
resource "tencentcloud_nat_gateway" "my_nat" {
57-
vpc_id = data.tencentcloud_vpc.my_vpc.id
58-
name = "terraform test"
59+
vpc_id = data.tencentcloud_vpc_instances.my_vpc.instance_list.0.vpc_id
60+
name = "terraform datasource test"
5961
max_concurrent = 3000000
6062
bandwidth = 500
6163
@@ -65,67 +67,19 @@ resource "tencentcloud_nat_gateway" "my_nat" {
6567
]
6668
}
6769
68-
# Create route_table and entry
69-
resource "tencentcloud_route_table" "my_route_table" {
70-
vpc_id = data.tencentcloud_vpc.my_vpc.id
71-
name = "terraform test"
72-
}
73-
resource "tencentcloud_route_table_entry" "my_route_entry" {
74-
route_table_id = tencentcloud_route_table.my_route_table.id
75-
destination_cidr_block = "10.0.0.0/8"
76-
next_type = "NAT"
77-
next_hub = tencentcloud_nat_gateway.my_nat.id
78-
}
79-
80-
# Create Subnet
81-
resource "tencentcloud_subnet" "my_subnet" {
82-
vpc_id = data.tencentcloud_vpc.my_vpc.id
83-
name = "terraform test"
84-
cidr_block = "172.16.128.0/20"
85-
availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name
86-
route_table_id = tencentcloud_route_table.my_route_table.id
87-
}
88-
8970
# Subnet Nat gateway snat
9071
resource "tencentcloud_nat_gateway_snat" "my_subnet_snat" {
9172
nat_gateway_id = tencentcloud_nat_gateway.my_nat.id
9273
resource_type = "SUBNET"
93-
subnet_id = tencentcloud_subnet.my_subnet.id
94-
subnet_cidr_block = tencentcloud_subnet.my_subnet.cidr_block
74+
subnet_id = data.tencentcloud_vpc_subnets.my_subnet.instance_list.0.subnet_id
75+
subnet_cidr_block = data.tencentcloud_vpc_subnets.my_subnet.instance_list.0.cidr_block
9576
description = "terraform test"
9677
public_ip_addr = [
9778
tencentcloud_eip.eip_dev_dnat.public_ip,
9879
tencentcloud_eip.eip_test_dnat.public_ip,
9980
]
10081
}
10182
102-
# Create instance
103-
resource "tencentcloud_instance" "my_instance" {
104-
instance_name = "terraform test"
105-
availability_zone = data.tencentcloud_availability_zones.my_zones.zones.0.name
106-
image_id = data.tencentcloud_images.my_image.images.0.image_id
107-
instance_type = data.tencentcloud_instance_types.my_instance_types.instance_types.0.instance_type
108-
system_disk_type = "CLOUD_PREMIUM"
109-
system_disk_size = 50
110-
hostname = "user"
111-
project_id = 0
112-
vpc_id = data.tencentcloud_vpc.my_vpc.id
113-
subnet_id = tencentcloud_subnet.my_subnet.id
114-
//internet_max_bandwidth_out = 20
115-
}
116-
117-
# NetWorkInterface Nat gateway snat
118-
resource "tencentcloud_nat_gateway_snat" "my_instance_snat" {
119-
nat_gateway_id = tencentcloud_nat_gateway.my_nat.id
120-
resource_type = "NETWORKINTERFACE"
121-
instance_id = tencentcloud_instance.my_instance.id
122-
instance_private_ip_addr = tencentcloud_instance.my_instance.private_ip
123-
description = "terraform test"
124-
public_ip_addr = [
125-
tencentcloud_eip.eip_dev_dnat.public_ip,
126-
]
127-
}
128-
12983
data "tencentcloud_nat_gateway_snats" "snat" {
13084
nat_gateway_id = tencentcloud_nat_gateway.my_nat.id
13185
}

tencentcloud/resource_tc_monitor_binding_receiver_test.go

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)