Skip to content

Commit f937817

Browse files
authored
fix: es - node type example and sweeper (#922)
1 parent 1cadd27 commit f937817

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

examples/tencentcloud-elasticsearch/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ variable "instance_name" {
77
}
88

99
variable "instance_type" {
10-
default = "ES.S1.SMALL2"
10+
default = "ES.S1.MEDIUM4"
1111
}

tencentcloud/data_source_tc_elasticsearch_instances_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestAccTencentCloudElasticsearchInstancesDataSource(t *testing.T) {
3030
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.tags.test", "terraform"),
3131
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.node_info_list.#", "1"),
3232
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.node_info_list.0.node_num", "2"),
33-
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.node_info_list.0.node_type", "ES.S1.SMALL2"),
33+
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.node_info_list.0.node_type", "ES.S1.MEDIUM4"),
3434
resource.TestCheckResourceAttr("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.node_info_list.0.encrypt", "false"),
3535
resource.TestCheckResourceAttrSet("data.tencentcloud_elasticsearch_instances.foo", "instance_list.0.create_time"),
3636
),
@@ -51,7 +51,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
5151
5252
node_info_list {
5353
node_num = 2
54-
node_type = "ES.S1.SMALL2"
54+
node_type = "ES.S1.MEDIUM4"
5555
}
5656
5757
tags = {

tencentcloud/resource_tc_elasticsearch_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
2020
2121
node_info_list {
2222
node_num = 2
23-
node_type = "ES.S1.SMALL2"
23+
node_type = "ES.S1.MEDIUM4"
2424
encrypt = false
2525
}
2626

tencentcloud/resource_tc_elasticsearch_instance_test.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,46 @@ package tencentcloud
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"testing"
78

89
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
910
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1011
)
1112

13+
func init() {
14+
// go test -v ./tencentcloud -sweep=ap-guangzhou -sweep-run=tencentcloud_elasticsearch_instance
15+
resource.AddTestSweepers("tencentcloud_elasticsearch_instance", &resource.Sweeper{
16+
Name: "tencentcloud_elasticsearch_instance",
17+
F: func(r string) error {
18+
logId := getLogId(contextNil)
19+
ctx := context.WithValue(context.TODO(), logIdKey, logId)
20+
cli, _ := sharedClientForRegion(r)
21+
client := cli.(*TencentCloudClient).apiV3Conn
22+
23+
service := ElasticsearchService{client: client}
24+
25+
es, err := service.DescribeInstancesByFilter(ctx, "", "tf-ci-test", nil)
26+
if err != nil {
27+
return err
28+
}
29+
30+
for _, v := range es {
31+
id := *v.InstanceId
32+
name := *v.InstanceName
33+
if !strings.Contains(name, "tf-ci-test") {
34+
continue
35+
}
36+
if err := service.DeleteInstance(ctx, id); err != nil {
37+
continue
38+
}
39+
}
40+
41+
return nil
42+
},
43+
})
44+
}
45+
1246
func TestAccTencentCloudElasticsearchInstance_basic(t *testing.T) {
1347
t.Parallel()
1448

@@ -31,7 +65,7 @@ func TestAccTencentCloudElasticsearchInstance_basic(t *testing.T) {
3165
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "web_node_type_info.0.node_num", "1"),
3266
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "web_node_type_info.0.node_type", "ES.S1.MEDIUM4"),
3367
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "node_info_list.0.node_num", "2"),
34-
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "node_info_list.0.node_type", "ES.S1.SMALL2"),
68+
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "node_info_list.0.node_type", "ES.S1.MEDIUM4"),
3569
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "node_info_list.0.type", "hotData"),
3670
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "node_info_list.0.encrypt", "false"),
3771
resource.TestCheckResourceAttr("tencentcloud_elasticsearch_instance.foo", "tags.test", "terraform"),
@@ -144,7 +178,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
144178
145179
node_info_list {
146180
node_num = 2
147-
node_type = "ES.S1.SMALL2"
181+
node_type = "ES.S1.MEDIUM4"
148182
}
149183
150184
tags = {

website/docs/r/elasticsearch_instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tencentcloud_elasticsearch_instance" "foo" {
3030
3131
node_info_list {
3232
node_num = 2
33-
node_type = "ES.S1.SMALL2"
33+
node_type = "ES.S1.MEDIUM4"
3434
encrypt = false
3535
}
3636

0 commit comments

Comments
 (0)