Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 42 additions & 16 deletions tencentcloud/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ const (
defaultVpcCidr = "172.16.0.0/16"
defaultVpcCidrLess = "172.16.0.0/18"

defaultCvmAZone = "ap-guangzhou-7"
defaultCvmVpcId = "vpc-l0dw94uh"
defaultCvmSubnetId = "subnet-ccj2qg0m"
defaultCvmTestingAZone = "ap-guangzhou-2"
defaultCvmTestingVpcId = "vpc-701bm52d"
defaultCvmTestingSubnetId = "subnet-1q62lj3m"
defaultCvmTestingImgId = "img-eb30mz89"
defaultCvmAZone = "ap-guangzhou-7"
defaultCvmInternationalZone = "ap-guangzhou-3"
defaultCvmVpcId = "vpc-l0dw94uh"
defaultCvmSubnetId = "subnet-ccj2qg0m"
defaultCvmTestingAZone = "ap-guangzhou-2"
defaultCvmTestingVpcId = "vpc-701bm52d"
defaultCvmTestingSubnetId = "subnet-1q62lj3m"
defaultCvmTestingImgId = "img-eb30mz89"
defaultCvmInternationalVpcId = "vpc-m7ryq37p"
defaultCvmInternationalSubnetId = "subnet-lwrsb7a0"

defaultAZone = "ap-guangzhou-3"
defaultSubnetId = "subnet-enm92y0m"
Expand Down Expand Up @@ -183,9 +186,11 @@ data "tencentcloud_instance_types" "default" {

// ckafka
const (
defaultKafkaInstanceId = "ckafka-vv7wpvae"
defaultKafkaVpcId = "vpc-njbzmzyd"
defaultKafkaSubnetId = "subnet-2txtpql8"
defaultKafkaInstanceId = "ckafka-vv7wpvae"
defaultKafkaVpcId = "vpc-njbzmzyd"
defaultKafkaSubnetId = "subnet-2txtpql8"
defaultKafkaInternationalVpcId = "vpc-ereuklyj"
defaultKafkaInternationalSubnetId = "subnet-e7rvxfx2"
)

const defaultKafkaVariable = `
Expand All @@ -198,6 +203,12 @@ variable "vpc_id" {
variable "subnet_id" {
default = "` + defaultKafkaSubnetId + `"
}
variable "international_vpc_id" {
default = "` + defaultKafkaInternationalVpcId + `"
}
variable "international_subnet_id" {
default = "` + defaultKafkaInternationalSubnetId + `"
}
`

// Tke Exclusive Network Environment
Expand All @@ -216,12 +227,14 @@ const (

// Cloud monitoring grafana visualization
const (
defaultGrafanaVpcId = "vpc-391sv4w3"
defaultGrafanaSubnetId = "subnet-ljyn7h30"
defaultGrafanaInstanceId = "grafana-dp2hnnfa"
defaultGrafanaReceiver = "Consumer-nfyxuzmbmq"
defaultGrafanaPlugin = "grafana-clock-panel"
defaultGrafanaVersion = "1.2.0"
defaultGrafanaVpcId = "vpc-391sv4w3"
defaultGrafanaSubnetId = "subnet-ljyn7h30"
defaultInternationalGrafanaVpcId = "vpc-dg21ckzx"
defaultInternationalGrafanaSubnetId = "subnet-i5lq9vy4"
defaultGrafanaInstanceId = "grafana-dp2hnnfa"
defaultGrafanaReceiver = "Consumer-nfyxuzmbmq"
defaultGrafanaPlugin = "grafana-clock-panel"
defaultGrafanaVersion = "1.2.0"
)

/*
Expand Down Expand Up @@ -251,6 +264,10 @@ variable "availability_cvm_zone" {
default = "` + defaultCvmAZone + `"
}

variable "availability_cvm_international_zone" {
default = "` + defaultCvmInternationalZone + `"
}

variable "availability_cvm_testing_zone" {
default = "` + defaultCvmTestingAZone + `"
}
Expand All @@ -275,6 +292,15 @@ variable "cvm_subnet_id" {
default = "` + defaultCvmSubnetId + `"
}

variable "cvm_international_vpc_id" {
default = "` + defaultCvmInternationalVpcId + `"
}

variable "cvm_international_subnet_id" {
default = "` + defaultCvmInternationalSubnetId + `"
}


variable "vpc_id" {
default = "` + defaultVpcId + `"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package tencentcloud

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudInternationalGaapResource_listener4(t *testing.T) {
t.Parallel()
id := new(string)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccInternationalGaapLayer4ListenerBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "TCP"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "TCP"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "ci-test-gaap-4-listener"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9090"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "interval", "5"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "connect_timeout", "2"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"),
),
},
{
ResourceName: "tencentcloud_gaap_layer4_listener.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

var testAccInternationalGaapLayer4ListenerBasic = `
resource tencentcloud_gaap_layer4_listener "foo" {
protocol = "TCP"
name = "ci-test-gaap-4-listener"
port = 9090
realserver_type = "IP"
proxy_id = "link-092unjav"
health_check = true

realserver_bind_set {
id = "rs-5qfe73i1"
ip = "1.1.1.5"
port = 80
}

realserver_bind_set {
id = "rs-7smh4tmf"
ip = "119.29.29.35"
port = 80
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package tencentcloud

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudInternationalGaapResource_listener7(t *testing.T) {
t.Parallel()
id := new(string)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccInternationalGaapLayer7ListenerBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckGaapLayer7ListenerExists("tencentcloud_gaap_layer7_listener.foo", id, "HTTP"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer7_listener.foo", "protocol", "HTTP"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer7_listener.foo", "name", "ci-test-gaap-l7-listener"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer7_listener.foo", "port", "8080"),
resource.TestCheckResourceAttr("tencentcloud_gaap_layer7_listener.foo", "client_certificate_ids.#", "0"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer7_listener.foo", "status"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer7_listener.foo", "create_time"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer7_listener.foo", "proxy_id"),
),
},
{
ResourceName: "tencentcloud_gaap_layer7_listener.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

var testAccInternationalGaapLayer7ListenerBasic = `
resource tencentcloud_gaap_layer7_listener "foo" {
protocol = "HTTP"
name = "ci-test-gaap-l7-listener"
port = 8080
proxy_id = "link-092unjav"
}
`
57 changes: 57 additions & 0 deletions tencentcloud/resource_tc_gaap_proxy_international_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package tencentcloud

import (
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccTencentCloudInternationalGaapResource_proxy(t *testing.T) {
id := new(string)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckGaapProxyDestroy(id),
Steps: []resource.TestStep{
{
Config: testAccInternationalGaapProxyBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckGaapProxyExists("tencentcloud_gaap_proxy.foo", id),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "name", "ci-test-gaap-proxy"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "bandwidth", "10"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "concurrent", "2"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "project_id", "0"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "access_region", "Guangzhou"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "realserver_region", "Beijing"),
resource.TestCheckResourceAttr("tencentcloud_gaap_proxy.foo", "enable", "true"),
resource.TestCheckNoResourceAttr("tencentcloud_gaap_proxy.foo", "tags"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "create_time"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "status"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "domain"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "ip"),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "scalable"),
resource.TestMatchResourceAttr("tencentcloud_gaap_proxy.foo", "support_protocols.#", regexp.MustCompile(`^[1-9]\d*$`)),
resource.TestCheckResourceAttrSet("tencentcloud_gaap_proxy.foo", "forward_ip"),
),
},
{
ResourceName: "tencentcloud_gaap_proxy.foo",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

const testAccInternationalGaapProxyBasic = `
resource tencentcloud_gaap_proxy "foo" {
name = "ci-test-gaap-proxy"
bandwidth = 10
concurrent = 2
access_region = "Guangzhou"
realserver_region = "Beijing"
network_type = "normal"
}
`
117 changes: 117 additions & 0 deletions tencentcloud/resource_tc_kubernetes_cluster_international_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package tencentcloud

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

var testInternationalTkeClusterName = "tencentcloud_kubernetes_cluster"
var testInternationalTkeClusterResourceKey = testInternationalTkeClusterName + ".managed_cluster"

func TestAccInternationalTencentCloudKubernetesResource_cluster(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckTkeDestroy,
Steps: []resource.TestStep{
{
Config: testAccInternationalTkeCluster,
Check: resource.ComposeTestCheckFunc(
testAccCheckTkeExists(testTkeClusterResourceKey),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_cidr", "10.31.0.0/23"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_max_pod_num", "32"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_name", "test"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_desc", "test cluster desc"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_node_num", "1"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "worker_instances_list.#", "1"),
resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "worker_instances_list.0.instance_id"),
resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "certification_authority"),
resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "user_name"),
resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "password"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "tags.test", "test"),
//resource.TestCheckResourceAttr(testTkeClusterResourceKey, "security_policy.#", "2"),
//resource.TestCheckResourceAttrSet(testTkeClusterResourceKey, "cluster_external_endpoint"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_level", "L5"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "auto_upgrade_cluster_level", "true"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "labels.test1", "test1"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "labels.test2", "test2"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_internet_domain", "tf.cluster-internet.com"),
resource.TestCheckResourceAttr(testTkeClusterResourceKey, "cluster_intranet_domain", "tf.cluster-intranet.com"),
),
},
},
})
}

const InternationalTkeDeps = TkeExclusiveNetwork + TkeInstanceType + TkeCIDRs + defaultImages + defaultSecurityGroupData

const testAccInternationalTkeCluster = InternationalTkeDeps + `
variable "availability_zone" {
default = "ap-guangzhou-3"
}

resource "tencentcloud_kubernetes_cluster" "managed_cluster" {
vpc_id = local.vpc_id
cluster_cidr = var.tke_cidr_a.0
cluster_max_pod_num = 32
cluster_name = "test"
cluster_desc = "test cluster desc"
cluster_max_service_num = 32
cluster_internet = true
cluster_internet_domain = "tf.cluster-internet.com"
cluster_intranet = true
cluster_intranet_domain = "tf.cluster-intranet.com"
cluster_version = "1.22.5"
cluster_os = "tlinux2.2(tkernel3)x86_64"
cluster_level = "L5"
auto_upgrade_cluster_level = true
cluster_intranet_subnet_id = local.subnet_id
cluster_internet_security_group = local.sg_id
managed_cluster_internet_security_policies = ["3.3.3.3", "1.1.1.1"]
worker_config {
count = 1
availability_zone = var.availability_zone
instance_type = local.final_type
system_disk_type = "CLOUD_SSD"
system_disk_size = 60
internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR"
internet_max_bandwidth_out = 100
public_ip_assigned = true
subnet_id = local.subnet_id
img_id = var.default_img_id
security_group_ids = [local.sg_id]

data_disk {
disk_type = "CLOUD_PREMIUM"
disk_size = 50
file_system = "ext3"
auto_format_and_mount = "true"
mount_target = "/var/lib/docker"
disk_partition = "/dev/sdb1"
}

enhanced_security_service = false
enhanced_monitor_service = false
user_data = "dGVzdA=="
password = "ZZXXccvv1212"
}

cluster_deploy_type = "MANAGED_CLUSTER"

tags = {
"test" = "test"
}

unschedulable = 0

labels = {
"test1" = "test1",
"test2" = "test2",
}
extra_args = [
"root-dir=/var/lib/kubelet"
]
}
`
Loading