Skip to content

Commit 734d02f

Browse files
committed
feat(mongodb): add cpu parameter to tencentcloud_mongodb_instance resource
1 parent 2b761cc commit 734d02f

20 files changed

Lines changed: 1455 additions & 57 deletions

File tree

.changelog/4325.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_mongodb_instance: support `cpu` parameter to manage the CPU core count during instance configuration changes
3+
```

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require (
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.3.105
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.3.131
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.132
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.133
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/config v1.3.80
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.3.130
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.3.30
@@ -69,7 +69,7 @@ require (
6969
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lighthouse v1.3.108
7070
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.3.95
7171
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.3.102
72-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.103
72+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.133
7373
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.3.101
7474
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.3.45
7575
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/organization v1.3.110

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,6 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.93/go.mod h
986986
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.95/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
987987
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.101/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
988988
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.102/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
989-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.103/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
990989
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.104/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
991990
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.105/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
992991
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.107/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
@@ -1004,8 +1003,9 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.125/go.mod
10041003
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.127/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10051004
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.130/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10061005
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.131/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
1007-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.132 h1:42RfJnwzMprfKEJrM9fyhHu1jXyg8xvSJ1A1qb9Qun8=
10081006
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.132/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
1007+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.133 h1:EKJsaGHbifEKqWCdJ4tJNLxbJ5h/Pm3CaLKzcCS/pkw=
1008+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.3.133/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
10091009
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/config v1.3.80 h1:chnsNBeJn3MieFLki4hpbzoml5NiTvLVzOTqYRVxQho=
10101010
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/config v1.3.80/go.mod h1:B/ezGtlvDhZlleNM+2QdvZccrUi+J+fN6vMnDDsZnuM=
10111011
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.1.51 h1:pGwrfCBBCt1u+EDHwfNj9NLQpvk5MVKVMcsE7SvwqM4=
@@ -1065,8 +1065,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.3.95 h1:rWiKud6
10651065
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/live v1.3.95/go.mod h1:uDGk0Bi0diOd1VaQPnfZO0MLKPKjqIT4Hi0sdanwD9s=
10661066
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.3.102 h1:I4QaWjVMOfuEsmxjTS8BxYgLcgdATWIAGutcHDnIvB4=
10671067
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mariadb v1.3.102/go.mod h1:Thfxer0Xf7Oq//ceL5i5nObFEXyQkUxzLHVNFh3p7jw=
1068-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.103 h1:EQTALkZayL6KrXCcx0yjJ3ksl75dFNFJWhTnSUxaYds=
1069-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.103/go.mod h1:0CcAKrx6oYC/WfuN04wsNtQ77dLgMv74in3kY5nwqgE=
1068+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.133 h1:J/x518dKdFwHa7KatmCWNw7/daJuf7yw+1bov8Du3d0=
1069+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mongodb v1.3.133/go.mod h1:MloftTaY0U0CNcDc2PkbNw7pGwE089AadY4tJ1bc5hM=
10701070
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.3.101 h1:r8PjkCuXrztjLyBROWTww0RJUq+a+l5ybPLl6GGlov8=
10711071
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor v1.3.101/go.mod h1:+cX4PEEehIIbyHy9plpXOTShlFWtc9OC1AWcmOrOMT8=
10721072
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/mps v1.3.45 h1:35PD/GXaOl3QhL1fI5a3Q+jcenzR1PqfuGxltOeO48w=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-07-21
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Context
2+
3+
`tencentcloud_mongodb_instance` 是腾讯云 MongoDB 实例的通用资源(RESOURCE_KIND_GENERAL),管理实例整个生命周期。当前资源通过 `MongodbService.UpgradeInstance` 方法(封装 `ModifyDBInstanceSpec` 接口)支持 `memory``volume``node_num``add_node_list``remove_node_list``in_maintenance` 等参数的变配,但未暴露 `cpu` 参数。
4+
5+
腾讯云 MongoDB `ModifyDBInstanceSpec` 接口已支持 `Cpu` 入参(`*int64`,单位:C),允许在变更实例规格时指定变更后的 CPU 大小;`DescribeDBInstances` 返回的 `InstanceDetail.CpuNum``*uint64`)字段记录实例当前 CPU 核数。本次变更将 `cpu` 参数接入 Terraform 资源,补全实例规格变更能力。
6+
7+
约束:
8+
- 资源 schema 已存在且已发布,必须保持向后兼容,只能新增 `Optional` + `Computed` 字段。
9+
- `ModifyDBInstanceSpecRequest.Cpu``*int64` 类型;`InstanceDetail.CpuNum``*uint64` 类型,需注意类型转换。
10+
- 变配操作可能返回订单 ID,需通过 `DescribeDBInstanceDeal` 轮询订单状态确认完成(现有逻辑已实现,本次复用)。
11+
12+
## Goals / Non-Goals
13+
14+
**Goals:**
15+
-`tencentcloud_mongodb_instance` 资源新增 `cpu` 参数(`Optional` + `Computed``TypeInt`)。
16+
- 在 Update 流程中,当 `cpu` 发生变化时,将 `cpu` 传递给 `ModifyDBInstanceSpec` 接口的 `Cpu` 字段完成变配。
17+
- 在 Read 流程中,从 `DescribeDBInstances` 返回的 `InstanceDetail.CpuNum` 回填 `cpu` 到 state。
18+
- 补充基于 gomonkey 的单元测试,覆盖 `cpu` 变更触发变配与回填逻辑。
19+
20+
**Non-Goals:**
21+
- 不修改 Create 流程:`CreateDBInstanceHour`/`CreateDBInstance` 创建时使用的是 `CpuCore` 字段(非本次需求范围内的 `Cpu`),且本次需求仅针对 `ModifyDBInstanceSpec``Cpu` 入参,不扩展到创建参数。
22+
- 不修改 `mongos_cpu` 等已有分片集群相关 CPU 参数。
23+
- 不修改已发布字段的 schema 行为(不新增 `ForceNew`,不改变 `Required`/`Optional` 语义)。
24+
- 不执行 `make doc``gofmt``.changelog` 等收尾操作(由 tfpacer-finalize 阶段统一处理)。
25+
26+
## Decisions
27+
28+
### 决策 1:`cpu` 字段定义为 `Optional` + `Computed`,不设置 `ForceNew`
29+
30+
**理由**`cpu` 变化通过 in-place update(调用 `ModifyDBInstanceSpec`)完成,无需重建实例。设为 `Computed` 使 Read 能从云上回填实际 CPU 值,避免用户未指定时 state 与云上不一致。与已有 `memory``Required`)、`volume``Required`)不同,`cpu` 为可选参数(云 API 注释说明为空值时默认取实例当前 CPU 大小),因此设为 `Optional` + `Computed` 更贴合 API 语义且向后兼容。
31+
32+
**备选方案**:将 `cpu` 设为 `Required`。否决,因为会破坏向后兼容(已有配置未设置 `cpu`)且与 API 语义不符。
33+
34+
### 决策 2:Update 触发条件扩展为包含 `cpu`
35+
36+
**理由**:现有触发条件为 `d.HasChange("memory") || d.HasChange("volume") || d.HasChange("node_num")`,新增 `d.HasChange("cpu")`。当用户单独修改 `cpu` 时也应触发变配。`cpu` 通过现有 `params map[string]interface{}` 传递到 `UpgradeInstance`,复用现有 `in_maintenance`/`node_num` 的传参模式,最小改动。
37+
38+
**备选方案**:为 `cpu` 单独创建一个 `ModifyDBInstanceSpec` 调用分支。否决,会引入重复的订单轮询与错误处理逻辑,违背 DRY,且云 API `ModifyDBInstanceSpec` 本身支持同时变更多个规格参数。
39+
40+
### 决策 3:服务层 `UpgradeInstance` 新增 `params["cpu"]` 映射到 `request.Cpu`
41+
42+
**理由**`ModifyDBInstanceSpecRequest.Cpu``*int64`,使用 `helper.Int64(v.(int))` 构造指针。与现有 `params["in_maintenance"]` 等使用 `helper.IntUint64` 不同,需按字段实际类型 `int64` 使用 `helper.Int64`,避免类型不匹配。
43+
44+
### 决策 4:Read 回填使用 `instance.CpuNum``*uint64`)转为 `int`
45+
46+
**理由**`DescribeDBInstances` 返回的 `InstanceDetail.CpuNum` 即实例 CPU 核数。在 Read 中先判断 `instance.CpuNum != nil``d.Set("cpu", int(*instance.CpuNum))`,遵循项目规范「调用 setXX 前先判断字段是否为 nil」。不将 `CpuNum` 加入 `CheckNil` 强校验列表,避免对未返回该字段的存量实例造成 Read 失败。
47+
48+
## Risks / Trade-offs
49+
50+
- **[风险] `CpuNum``*uint64``Cpu``*int64`,类型转换溢出** → 实际 CPU 核数为正小整数,不会溢出;转换使用 `int()` 显式转换,安全。
51+
- **[风险] 用户单独修改 `cpu` 而不修改 `memory`/`volume` 时,云 API 是否允许** → 云 API 注释明确支持单独变更 CPU("变更 mongod 或 mongos 的 CPU 与内存规格时,NodeNum 可以不配置"),且 `Cpu` 注释说明为空时取当前值,语义允许单独变更。具体可用规格由 `DescribeSpecInfo` 约束,由云 API 校验,Provider 不做额外校验。
52+
- **[权衡] 未将 `CpuNum` 加入 `CheckNil` 强校验** → 避免对未返回该字段的存量实例造成 Read 失败;回填前单独判 nil,安全且向后兼容。
53+
- **[风险] 既有 `UpgradeInstance` 复用同一订单轮询逻辑** → 不新增轮询逻辑,沿用现有 `DescribeDBInstanceDeal` 轮询,行为一致。
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Why
2+
3+
`tencentcloud_mongodb_instance` 资源当前支持通过 `memory``volume``node_num` 等参数调整实例配置(调用 `ModifyDBInstanceSpec` 接口),但缺少对 CPU 核数的管理。腾讯云 MongoDB `ModifyDBInstanceSpec` 接口已支持 `Cpu` 入参,允许在变更实例规格时指定变更后的 CPU 大小(单位:C)。本次变更新增 `cpu` 参数,使用户能够通过 Terraform 管理 MongoDB 实例的 CPU 规格,补全实例配置变更能力。
4+
5+
## What Changes
6+
7+
-`tencentcloud_mongodb_instance` 资源 schema 中新增 `cpu` 参数(`Optional` + `Computed``TypeInt`),用于指定实例变更后的 CPU 核数。
8+
- 在资源 Update 流程中,将 `cpu` 加入 `ModifyDBInstanceSpec` 的触发条件,当 `cpu` 发生变化时(与 `memory``volume``node_num` 等一起或单独)调用 `ModifyDBInstanceSpec` 接口完成变配。
9+
-`MongodbService.UpgradeInstance` 服务方法中,将 `params["cpu"]` 映射到 `ModifyDBInstanceSpecRequest.Cpu` 字段(`*int64`)。
10+
- 在资源 Read 流程中,通过 `DescribeDBInstances` 返回的 `InstanceDetail.CpuNum` 字段回填 `cpu` 参数到 state。
11+
- 补充 `resource_tc_mongodb_instance_test.go` 的单元测试用例(使用 gomonkey mock 云 API)。
12+
- 更新 `resource_tc_mongodb_instance.md` 资源文档。
13+
14+
## Capabilities
15+
16+
### New Capabilities
17+
- `mongodb-instance-cpu`: 为 `tencentcloud_mongodb_instance` 资源新增 `cpu` 参数,支持在实例配置变更时设置 CPU 核数,并通过查询接口回填 CPU 状态。
18+
19+
### Modified Capabilities
20+
<!-- 无需修改现有 spec 级别的需求 -->
21+
22+
## Impact
23+
24+
### 受影响的代码
25+
- `tencentcloud/services/mongodb/resource_tc_mongodb_instance.go` - schema 新增 `cpu` 字段、Read 回填、Update 触发与传参
26+
- `tencentcloud/services/mongodb/service_tencentcloud_mongodb.go` - `UpgradeInstance` 方法新增 `cpu` 参数映射到 `ModifyDBInstanceSpecRequest.Cpu`
27+
- `tencentcloud/services/mongodb/resource_tc_mongodb_instance_test.go` - 新增/补充单元测试
28+
- `tencentcloud/services/mongodb/resource_tc_mongodb_instance.md` - 文档更新
29+
30+
### 受影响的 API
31+
- `ModifyDBInstanceSpec`(变配时设置 `Cpu` 入参,`*int64`
32+
- `DescribeDBInstances`(读取时从 `InstanceDetail.CpuNum` 回填,`*uint64`
33+
34+
### 向后兼容性
35+
- ✅ 完全向后兼容:仅新增 `Optional` + `Computed` 字段,不修改已有 schema,不影响现有 TF 配置和 state。
36+
- ✅ 不设置 `ForceNew``cpu` 变化通过 in-place update 处理。
37+
38+
### 依赖关系
39+
- 无新增依赖,复用现有 `ModifyDBInstanceSpec``DescribeDBInstances` 接口及现有 `UpgradeInstance` 服务方法。
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
## ADDED Requirements
2+
3+
### Requirement: MongoDB Instance CPU Parameter
4+
The `tencentcloud_mongodb_instance` resource SHALL provide a `cpu` schema field to manage the instance CPU core count, allowing users to change the CPU specification of a running MongoDB instance through in-place update via the `ModifyDBInstanceSpec` API.
5+
6+
#### Scenario: Schema defines optional and computed cpu field
7+
- **GIVEN** the `tencentcloud_mongodb_instance` resource schema definition
8+
- **THEN** `cpu` SHALL be a field of type `schema.TypeInt`
9+
- **AND** `cpu` SHALL have `Optional: true` and `Computed: true`
10+
- **AND** `cpu` SHALL NOT have `ForceNew` set (changes are applied via in-place update)
11+
- **AND** the field description SHALL document that the unit is C and that the supported CPU specifications can be obtained via the `DescribeSpecInfo` API
12+
13+
#### Scenario: Update triggers ModifyDBInstanceSpec when cpu changes
14+
- **GIVEN** an existing `tencentcloud_mongodb_instance` resource
15+
- **WHEN** the user updates only the `cpu` field (without changing `memory`, `volume`, or `node_num`)
16+
- **THEN** the system SHALL detect `d.HasChange("cpu")` and enter the spec-modification branch
17+
- **AND** the system SHALL read the current `cpu` value from the schema
18+
- **AND** the system SHALL pass `cpu` into the params map of `MongodbService.UpgradeInstance`
19+
- **AND** the system SHALL call the `ModifyDBInstanceSpec` API with the `Cpu` request field set to the new CPU value
20+
- **AND** the system SHALL poll the returned deal id via `DescribeDBInstanceDeal` until the deal succeeds (when `in_maintenance == 0`)
21+
- **AND** the resource state SHALL be updated after a successful modification
22+
23+
#### Scenario: Update triggers ModifyDBInstanceSpec when cpu changes together with other spec params
24+
- **GIVEN** an existing `tencentcloud_mongodb_instance` resource
25+
- **WHEN** the user updates `cpu` together with `memory`, `volume`, or `node_num`
26+
- **THEN** the system SHALL include the `cpu` value alongside the other changed spec parameters in a single `ModifyDBInstanceSpec` call
27+
- **AND** the `Cpu` request field SHALL be set from the user-specified `cpu` value
28+
29+
#### Scenario: cpu omitted in update keeps existing behavior
30+
- **GIVEN** an existing `tencentcloud_mongodb_instance` resource where `cpu` was not configured
31+
- **WHEN** the user updates fields unrelated to spec modification (e.g., tags, project_id)
32+
- **THEN** the system SHALL NOT call `ModifyDBInstanceSpec`
33+
- **AND** the `cpu` field SHALL remain unset in the schema (populated only via Read)
34+
35+
#### Scenario: Service layer maps cpu to ModifyDBInstanceSpecRequest.Cpu
36+
- **GIVEN** the `MongodbService.UpgradeInstance` service method
37+
- **WHEN** `params["cpu"]` is present with an integer value
38+
- **THEN** the system SHALL set `request.Cpu` to a `*int64` pointer constructed from the integer value
39+
- **AND** the type conversion SHALL use the `int64` helper matching the `ModifyDBInstanceSpecRequest.Cpu` field type
40+
- **WHEN** `params["cpu"]` is not present
41+
- **THEN** the system SHALL leave `request.Cpu` unset (nil) so the cloud API defaults to the current CPU size
42+
43+
### Requirement: MongoDB Instance CPU Read Backfill
44+
The resource Read operation SHALL populate the `cpu` field from the cloud API response so that Terraform state reflects the actual CPU core count of the instance.
45+
46+
#### Scenario: Read populates cpu from DescribeDBInstances
47+
- **GIVEN** an existing `tencentcloud_mongodb_instance` resource
48+
- **WHEN** the Read operation queries the instance via `DescribeDBInstances` (through `DescribeInstanceById`)
49+
- **AND** the returned `InstanceDetail.CpuNum` is not nil
50+
- **THEN** the system SHALL set the `cpu` field in state to `int(*instance.CpuNum)`
51+
52+
#### Scenario: Read handles nil CpuNum gracefully
53+
- **GIVEN** an existing `tencentcloud_mongodb_instance` resource
54+
- **WHEN** the Read operation queries the instance
55+
- **AND** the returned `InstanceDetail.CpuNum` is nil
56+
- **THEN** the system SHALL NOT call `d.Set("cpu", ...)` (skip setting the field)
57+
- **AND** the Read operation SHALL NOT fail solely because `CpuNum` is nil
58+
59+
#### Scenario: CpuNum not added to mandatory nil check
60+
- **GIVEN** the Read operation's `CheckNil` validation list
61+
- **THEN** `CpuNum` SHALL NOT be added to the mandatory nil-check map
62+
- **AND** existing instances that do not return `CpuNum` SHALL still be readable without error
63+
64+
### Requirement: CPU Parameter Testing
65+
The resource SHALL have unit tests using gomonkey mocks (not Terraform test suites) covering the new `cpu` parameter behavior, runnable via `go test` with `-gcflags=all=-l`.
66+
67+
#### Scenario: Unit test for cpu change triggering spec modification
68+
- **GIVEN** the `tencentcloud_mongodb_instance` resource update function
69+
- **WHEN** a unit test simulates a `cpu` change in the schema
70+
- **THEN** the test SHALL mock the `ModifyDBInstanceSpec` and `DescribeDBInstanceDeal` cloud APIs using gomonkey
71+
- **AND** verify that the update flow calls `ModifyDBInstanceSpec` with the expected `Cpu` value
72+
- **AND** verify the update completes without error
73+
74+
#### Scenario: Unit test for cpu read backfill
75+
- **GIVEN** the `tencentcloud_mongodb_instance` resource read function
76+
- **WHEN** a unit test mocks `DescribeDBInstances` to return an instance with `CpuNum` set
77+
- **THEN** the test SHALL verify that `d.Set("cpu", ...)` is called with the correct CPU value
78+
- **AND** verify the read completes without error
79+
80+
#### Scenario: Unit test for nil CpuNum read
81+
- **GIVEN** the `tencentcloud_mongodb_instance` resource read function
82+
- **WHEN** a unit test mocks `DescribeDBInstances` to return an instance with `CpuNum` nil
83+
- **THEN** the test SHALL verify the read operation does not fail
84+
- **AND** verify the `cpu` field is not set
85+
86+
### Requirement: CPU Parameter Documentation
87+
The resource documentation SHALL be updated to describe the new `cpu` parameter, generated via the `make doc` command during the finalize phase.
88+
89+
#### Scenario: cpu field documented
90+
- **GIVEN** the resource documentation file `resource_tc_mongodb_instance.md`
91+
- **THEN** the documentation SHALL include the `cpu` parameter description
92+
- **AND** the description SHALL state the unit is C and that supported specifications can be obtained via the `DescribeSpecInfo` API
93+
- **AND** the documentation SHALL NOT include manual `Argument Reference` or `Attribute Reference` sections (auto-generated)
94+
95+
#### Scenario: Example usage includes cpu
96+
- **GIVEN** the resource documentation
97+
- **THEN** the example usage SHALL demonstrate specifying the `cpu` parameter in an update scenario

0 commit comments

Comments
 (0)