Skip to content

Commit 0d27ee1

Browse files
gitmknanonymous
andauthored
fix: update test (#1596)
* fix: update test * fix: Reduce the frequency of ci retry requests * fix: modify test * fix: modify test * fix: modify test * fix: add note --------- Co-authored-by: anonymous <anonymous@mail.org>
1 parent faec4ee commit 0d27ee1

12 files changed

+195
-29
lines changed

tencentcloud/basic_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,6 @@ const (
789789

790790
const (
791791
defaultMeshClusterId = "cls-9ae9qo9k"
792-
defaultMeshId = "mesh-rofjmux7"
793792
defaultMeshVpcId = "vpc-pyyv5k3v"
794793
defaultMeshSubnetId = "subnet-06i8auk6"
795794
)

tencentcloud/resource_tc_ci_bucket_pic_style.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"fmt"
2727
"log"
2828
"strings"
29+
"time"
2930

3031
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
3132
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -99,6 +100,7 @@ func resourceTencentCloudCiBucketPicStyleCreate(d *schema.ResourceData, meta int
99100
StyleBody: styleBody,
100101
})
101102
if e != nil {
103+
time.Sleep(5 * time.Second)
102104
return retryError(e)
103105
} else {
104106
log.Printf("[DEBUG]%s api[%s] success, response status [%s]\n", logId, "AddStyle", result.Status)

tencentcloud/resource_tc_tcm_access_log_config_test.go

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAccTencentCloudTcmAccessLogConfigResource_basic(t *testing.T) {
2222
Check: resource.ComposeTestCheckFunc(
2323
testAccCheckTcmAccessLogConfigExists("tencentcloud_tcm_access_log_config.access_log_config"),
2424
resource.TestCheckResourceAttrSet("tencentcloud_tcm_access_log_config.access_log_config", "id"),
25-
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "mesh_name", defaultMeshId),
25+
resource.TestCheckResourceAttrSet("tencentcloud_tcm_access_log_config.access_log_config", "mesh_name"),
2626
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "address", "10.0.0.1"),
2727
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "enable", "true"),
2828
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "enable_server", "true"),
@@ -68,13 +68,47 @@ func testAccCheckTcmAccessLogConfigExists(r string) resource.TestCheckFunc {
6868
}
6969
}
7070

71-
const testAccTcmAccessLogConfigVar = `
72-
variable "mesh_id" {
73-
default = "` + defaultMeshId + `"
74-
}
75-
`
71+
const testAccTcmAccessLogConfig = `
7672
77-
const testAccTcmAccessLogConfig = testAccTcmAccessLogConfigVar + `
73+
resource "tencentcloud_tcm_mesh" "basic" {
74+
display_name = "test_mesh"
75+
mesh_version = "1.12.5"
76+
type = "HOSTED"
77+
config {
78+
istio {
79+
outbound_traffic_policy = "ALLOW_ANY"
80+
disable_policy_checks = true
81+
enable_pilot_http = true
82+
disable_http_retry = true
83+
smart_dns {
84+
istio_meta_dns_capture = true
85+
istio_meta_dns_auto_allocate = true
86+
}
87+
}
88+
tracing {
89+
enable = true
90+
sampling = 1
91+
apm {
92+
enable = false
93+
}
94+
zipkin {
95+
address = "10.0.0.1:1000"
96+
}
97+
}
98+
prometheus {
99+
custom_prom {
100+
url = "https://10.0.0.1:1000"
101+
auth_type = "none"
102+
vpc_id = "vpc-j9yhbzpn"
103+
}
104+
}
105+
}
106+
tag_list {
107+
key = "key"
108+
value = "value"
109+
passthrough = false
110+
}
111+
}
78112
79113
resource "tencentcloud_tcm_access_log_config" "access_log_config" {
80114
address = "10.0.0.1"
@@ -83,7 +117,7 @@ resource "tencentcloud_tcm_access_log_config" "access_log_config" {
83117
enable_stdout = true
84118
encoding = "JSON"
85119
format = "{\n\t\"authority\": \"%REQ(:AUTHORITY)%\",\n\t\"bytes_received\": \"%BYTES_RECEIVED%\",\n\t\"bytes_sent\": \"%BYTES_SENT%\",\n\t\"downstream_local_address\": \"%DOWNSTREAM_LOCAL_ADDRESS%\",\n\t\"downstream_remote_address\": \"%DOWNSTREAM_REMOTE_ADDRESS%\",\n\t\"duration\": \"%DURATION%\",\n\t\"istio_policy_status\": \"%DYNAMIC_METADATA(istio.mixer:status)%\",\n\t\"method\": \"%REQ(:METHOD)%\",\n\t\"path\": \"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%\",\n\t\"protocol\": \"%PROTOCOL%\",\n\t\"request_id\": \"%REQ(X-REQUEST-ID)%\",\n\t\"requested_server_name\": \"%REQUESTED_SERVER_NAME%\",\n\t\"response_code\": \"%RESPONSE_CODE%\",\n\t\"response_flags\": \"%RESPONSE_FLAGS%\",\n\t\"route_name\": \"%ROUTE_NAME%\",\n\t\"start_time\": \"%START_TIME%\",\n\t\"upstream_cluster\": \"%UPSTREAM_CLUSTER%\",\n\t\"upstream_host\": \"%UPSTREAM_HOST%\",\n\t\"upstream_local_address\": \"%UPSTREAM_LOCAL_ADDRESS%\",\n\t\"upstream_service_time\": \"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%\",\n\t\"upstream_transport_failure_reason\": \"%UPSTREAM_TRANSPORT_FAILURE_REASON%\",\n\t\"user_agent\": \"%REQ(USER-AGENT)%\",\n\t\"x_forwarded_for\": \"%REQ(X-FORWARDED-FOR)%\"\n}\n"
86-
mesh_name = var.mesh_id
120+
mesh_name = tencentcloud_tcm_mesh.basic.id
87121
template = "istio"
88122
89123
cls {

tencentcloud/resource_tc_tcm_cluster_attachment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func resourceTencentCloudTcmClusterAttachment() *schema.Resource {
5757
"cluster_list": {
5858
Type: schema.TypeList,
5959
Optional: true,
60+
Computed: true,
6061
ForceNew: true,
6162
Description: "Cluster list.",
6263
Elem: &schema.Resource{
@@ -84,6 +85,7 @@ func resourceTencentCloudTcmClusterAttachment() *schema.Resource {
8485
"subnet_id": {
8586
Type: schema.TypeString,
8687
Optional: true,
88+
Computed: true,
8789
Description: "Subnet id, only needed if it&#39;s standalone mesh.",
8890
},
8991
"type": {

tencentcloud/resource_tc_tcm_cluster_attachment_test.go

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
"github.com/hashicorp/terraform-plugin-sdk/terraform"
10+
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
1011

1112
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
1213
)
@@ -23,8 +24,14 @@ func TestAccTencentCloudTcmClusterAttachment_basic(t *testing.T) {
2324
Config: testAccTcmClusterAttachment,
2425
Check: resource.ComposeTestCheckFunc(
2526
testAccCheckClusterAttachmentExists("tencentcloud_tcm_cluster_attachment.basic"),
26-
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "mesh_id", defaultMeshId),
27+
// resource.TestCheckResourceAttrSet("tencentcloud_tcm_cluster_attachment.basic", "mesh_id"),
2728
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.#", "1"),
29+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.cluster_id", defaultMeshClusterId),
30+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.region", "ap-guangzhou"),
31+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.role", "REMOTE"),
32+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.vpc_id", defaultMeshVpcId),
33+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.subnet_id", defaultMeshSubnetId),
34+
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.type", "EKS"),
2835
),
2936
},
3037
{
@@ -56,6 +63,11 @@ func testAccCheckClusterAttachmentDestroy(s *terraform.State) error {
5663

5764
mesh, err := service.DescribeTcmMesh(ctx, meshId)
5865
if err != nil {
66+
if sdkErr, ok := err.(*errors.TencentCloudSDKError); ok {
67+
if sdkErr.Code == "ResourceNotFound" {
68+
return nil
69+
}
70+
}
5971
return err
6072
}
6173

@@ -118,9 +130,6 @@ const testAccTcmClusterAttachmentVar = `
118130
variable "cluster_id" {
119131
default = "` + defaultMeshClusterId + `"
120132
}
121-
variable "mesh_id" {
122-
default = "` + defaultMeshId + `"
123-
}
124133
variable "vpc_id" {
125134
default = "` + defaultMeshVpcId + `"
126135
}
@@ -131,15 +140,48 @@ variable "subnet_id" {
131140

132141
const testAccTcmClusterAttachment = testAccTcmClusterAttachmentVar + `
133142
143+
resource "tencentcloud_tcm_mesh" "basic" {
144+
display_name = "test_mesh"
145+
mesh_version = "1.12.5"
146+
type = "HOSTED"
147+
config {
148+
istio {
149+
outbound_traffic_policy = "ALLOW_ANY"
150+
disable_policy_checks = true
151+
enable_pilot_http = true
152+
disable_http_retry = true
153+
smart_dns {
154+
istio_meta_dns_capture = true
155+
istio_meta_dns_auto_allocate = true
156+
}
157+
}
158+
tracing {
159+
enable = true
160+
sampling = 1
161+
apm {
162+
enable = false
163+
}
164+
zipkin {
165+
address = "10.0.0.1:1000"
166+
}
167+
}
168+
}
169+
tag_list {
170+
key = "key"
171+
value = "value"
172+
passthrough = false
173+
}
174+
}
175+
134176
resource "tencentcloud_tcm_cluster_attachment" "basic" {
135-
mesh_id = var.mesh_id
177+
mesh_id = tencentcloud_tcm_mesh.basic.id
136178
cluster_list {
137179
cluster_id = var.cluster_id
138180
region = "ap-guangzhou"
139181
role = "REMOTE"
140182
vpc_id = var.vpc_id
141183
subnet_id = var.subnet_id
142-
type = "TKE"
184+
type = "EKS"
143185
}
144186
}
145187

tencentcloud/resource_tc_tcm_mesh.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,34 +94,40 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
9494
Type: schema.TypeList,
9595
MaxItems: 1,
9696
Optional: true,
97+
Computed: true,
9798
Description: "Tracing config.",
9899
Elem: &schema.Resource{
99100
Schema: map[string]*schema.Schema{
100101
"enable": {
101102
Type: schema.TypeBool,
102103
Optional: true,
104+
Computed: true,
103105
Description: "Whether enable tracing.",
104106
},
105107
"apm": {
106108
Type: schema.TypeList,
107109
MaxItems: 1,
108110
Optional: true,
111+
Computed: true,
109112
Description: "APM config.",
110113
Elem: &schema.Resource{
111114
Schema: map[string]*schema.Schema{
112115
"enable": {
113116
Type: schema.TypeBool,
114117
Optional: true,
118+
Computed: true,
115119
Description: "Whether enable APM.",
116120
},
117121
"region": {
118122
Type: schema.TypeString,
119123
Optional: true,
124+
Computed: true,
120125
Description: "Region.",
121126
},
122127
"instance_id": {
123128
Type: schema.TypeString,
124129
Optional: true,
130+
Computed: true,
125131
Description: "Instance id of the APM.",
126132
},
127133
},
@@ -130,12 +136,14 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
130136
"sampling": {
131137
Type: schema.TypeFloat,
132138
Optional: true,
139+
Computed: true,
133140
Description: "Tracing sampling, 0.0-1.0.",
134141
},
135142
"zipkin": {
136143
Type: schema.TypeList,
137144
MaxItems: 1,
138145
Optional: true,
146+
Computed: true,
139147
Description: "Third party zipkin config.",
140148
Elem: &schema.Resource{
141149
Schema: map[string]*schema.Schema{
@@ -154,44 +162,52 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
154162
Type: schema.TypeList,
155163
MaxItems: 1,
156164
Optional: true,
165+
Computed: true,
157166
Description: "Prometheus configuration.",
158167
Elem: &schema.Resource{
159168
Schema: map[string]*schema.Schema{
160169
"vpc_id": {
161170
Type: schema.TypeString,
162171
Optional: true,
172+
Computed: true,
163173
Description: "Vpc id.",
164174
},
165175
"subnet_id": {
166176
Type: schema.TypeString,
167177
Optional: true,
178+
Computed: true,
168179
Description: "Subnet id.",
169180
},
170181
"region": {
171182
Type: schema.TypeString,
172183
Optional: true,
184+
Computed: true,
173185
Description: "Region.",
174186
},
175187
"instance_id": {
176188
Type: schema.TypeString,
177189
Optional: true,
190+
Computed: true,
178191
Description: "Instance id.",
179192
},
180193
"custom_prom": {
181194
Type: schema.TypeList,
182195
MaxItems: 1,
183196
Optional: true,
197+
Computed: true,
184198
Description: "Custom prometheus.",
185199
Elem: &schema.Resource{
186200
Schema: map[string]*schema.Schema{
187201
"is_public_addr": {
188202
Type: schema.TypeBool,
189203
Optional: true,
204+
Computed: true,
190205
Description: "Whether it is public address, default false.",
191206
},
192207
"vpc_id": {
193208
Type: schema.TypeString,
194209
Optional: true,
210+
Computed: true,
195211
Description: "Vpc id.",
196212
},
197213
"url": {
@@ -207,11 +223,13 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
207223
"username": {
208224
Type: schema.TypeString,
209225
Optional: true,
226+
Computed: true,
210227
Description: "Username of the prometheus, used in basic authentication type.",
211228
},
212229
"password": {
213230
Type: schema.TypeString,
214231
Optional: true,
232+
Computed: true,
215233
Description: "Password of the prometheus, used in basic authentication type.",
216234
},
217235
},
@@ -470,7 +488,7 @@ func resourceTencentCloudTcmMeshCreate(d *schema.ResourceData, meta interface{})
470488
if errRet != nil {
471489
return retryError(errRet, InternalError)
472490
}
473-
if *mesh.Mesh.State == "PENDING" || *mesh.Mesh.State == "CREATING" {
491+
if *mesh.Mesh.State == "PENDING" || *mesh.Mesh.State == "CREATING" || *mesh.Mesh.State != "RUNNING" {
474492
return resource.RetryableError(fmt.Errorf("mesh status is %v, retry...", *mesh.Mesh.State))
475493
}
476494
return nil

0 commit comments

Comments
 (0)