Skip to content

Commit d1889b9

Browse files
tongyimingmikatong
andauthored
fix: support extend_fs_field && fix unit test (#940)
Co-authored-by: mikatong <mikatong@tencent.com>
1 parent 22d6e19 commit d1889b9

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

tencentcloud/basic_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const (
6666

6767
defaultTkeOSImageId = "img-2lr9q49h"
6868
defaultTkeOSImageName = "tlinux2.2(tkernel3)x86_64"
69+
defaultEMRSgId = "sg-qyy7jd2b"
6970
)
7071

7172
// Tke Exclusive Network Environment

tencentcloud/resource_tc_emr_cluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ func resourceTencentCloudEmrCluster() *schema.Resource {
171171
ForceNew: true,
172172
Description: "Instance login settings.",
173173
},
174+
"extend_fs_field": {
175+
Type: schema.TypeString,
176+
Optional: true,
177+
Description: "Access the external file system.",
178+
},
174179
"instance_id": {
175180
Type: schema.TypeString,
176181
Computed: true,
@@ -229,6 +234,9 @@ func resourceTencentCloudEmrClusterUpdate(d *schema.ResourceData, meta interface
229234
if d.HasChange("resource_spec.0.core_count") {
230235
request.CoreCount = common.Uint64Ptr((uint64)(resourceSpec["core_count"].(int)))
231236
}
237+
if d.HasChange("extend_fs_field") {
238+
return innerErr.New("extend_fs_field not support update.")
239+
}
232240
_, err := emrService.UpdateInstance(ctx, request)
233241
if err != nil {
234242
return err

tencentcloud/resource_tc_emr_cluster_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ func TestAccTencentCloudEmrClusterResource(t *testing.T) {
1919
Providers: testAccProviders,
2020
Steps: []resource.TestStep{
2121
{
22-
Config: testEmrBasic,
22+
Config: testEmrBasic(),
2323
Check: resource.ComposeTestCheckFunc(
2424
testAccCheckEmrExists(testEmrClusterResourceKey),
2525
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "product_id", "4"),
2626
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "display_strategy", "clusterList"),
27-
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "vpc_settings.vpc_id", "vpc-i9zty99n"),
28-
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "vpc_settings.subnet_id", "subnet-opwnh0sw"),
27+
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "vpc_settings.vpc_id", defaultVpcId),
28+
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "vpc_settings.subnet_id", defaultSubnetId),
2929
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "softwares.0", "zookeeper-3.6.1"),
3030
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "support_ha", "0"),
3131
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "instance_name", "emr-test-demo"),
@@ -37,7 +37,7 @@ func TestAccTencentCloudEmrClusterResource(t *testing.T) {
3737
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "placement.zone", "ap-guangzhou-3"),
3838
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "placement.project_id", "0"),
3939
resource.TestCheckResourceAttrSet(testEmrClusterResourceKey, "instance_id"),
40-
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "sg_id", "sg-qyy7jd2b"),
40+
resource.TestCheckResourceAttr(testEmrClusterResourceKey, "sg_id", defaultEMRSgId),
4141
),
4242
},
4343
},
@@ -88,13 +88,14 @@ func testAccCheckEmrExists(n string) resource.TestCheckFunc {
8888
}
8989
}
9090

91-
const testEmrBasic = `
91+
func testEmrBasic() string {
92+
return fmt.Sprintf(`
9293
resource "tencentcloud_emr_cluster" "emrrrr" {
9394
product_id=4
9495
display_strategy="clusterList"
9596
vpc_settings={
96-
vpc_id="vpc-i9zty99n"
97-
subnet_id:"subnet-opwnh0sw"
97+
vpc_id="%s"
98+
subnet_id:"%s"
9899
}
99100
softwares=[
100101
"zookeeper-3.6.1",
@@ -133,6 +134,7 @@ resource "tencentcloud_emr_cluster" "emrrrr" {
133134
zone="ap-guangzhou-3"
134135
project_id=0
135136
}
136-
sg_id="sg-qyy7jd2b"
137+
sg_id="%s"
137138
}
138-
`
139+
`, defaultVpcId, defaultSubnetId, defaultEMRSgId)
140+
}

tencentcloud/service_tencentcloud_emr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func (me *EMRService) CreateInstance(ctx context.Context, d *schema.ResourceData
160160
request.SgId = common.StringPtr(v.(string))
161161
}
162162

163+
if v, ok := d.GetOk("extend_fs_field"); ok {
164+
request.ExtendFsField = common.StringPtr(v.(string))
165+
}
166+
163167
ratelimit.Check(request.GetAction())
164168
//API: https://cloud.tencent.com/document/api/589/34261
165169
response, err := me.client.UseEmrClient().CreateInstance(request)

website/docs/r/emr_cluster.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The following arguments are supported:
7373
When TimeUnit is m, the number filled in by this parameter indicates the length of purchase of the monthly instance of the package year, such as 1 for one month of purchase.
7474
* `time_unit` - (Required) The unit of time in which the instance was purchased. When PayMode is 0, TimeUnit can only take values of s(second). When PayMode is 1, TimeUnit can only take the value m(month).
7575
* `vpc_settings` - (Required, ForceNew) The private net config of EMR instance.
76+
* `extend_fs_field` - (Optional) Access the external file system.
7677
* `need_master_wan` - (Optional, ForceNew) Whether to enable the cluster Master node public network. Value range:
7778
- NEED_MASTER_WAN: Indicates that the cluster Master node public network is enabled.
7879
- NOT_NEED_MASTER_WAN: Indicates that it is not turned on.

0 commit comments

Comments
 (0)