Skip to content

feat(cvm): [117301871]update cvm e2e test #2664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 4, 2024
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
4 changes: 1 addition & 3 deletions tencentcloud/services/cvm/resource_tc_cvm_sync_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ func ResourceTencentCloudCvmSyncImage() *schema.Resource {
Create: resourceTencentCloudCvmSyncImageCreate,
Read: resourceTencentCloudCvmSyncImageRead,
Delete: resourceTencentCloudCvmSyncImageDelete,
Importer: &schema.ResourceImporter{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不支持导入吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的 没有read方法

State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"image_id": {
Required: true,
Expand Down
11 changes: 8 additions & 3 deletions tencentcloud/services/cvm/resource_tc_cvm_sync_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ Provides a resource to create a cvm sync_image
Example Usage

```hcl
resource "tencentcloud_cvm_sync_image" "sync_image" {
image_id = "img-xxxxxx"
destination_regions =["ap-guangzhou", "ap-shanghai"]
data "tencentcloud_images" "example" {
image_type = ["PRIVATE_IMAGE"]
image_name_regex = "MyImage"
}

resource "tencentcloud_cvm_sync_image" "example" {
image_id = data.tencentcloud_images.example.images.0.image_id
destination_regions = ["ap-guangzhou", "ap-shanghai"]
}
```
21 changes: 15 additions & 6 deletions tencentcloud/services/cvm/resource_tc_cvm_sync_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,32 @@ func init() {
})
}

func TestAccTencentCloudCvmSyncImageResource_basic(t *testing.T) {
// go test -i; go test -test.run TestAccTencentCloudNeedFixCvmSyncImageResource_basic -v
func TestAccTencentCloudNeedFixCvmSyncImageResource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) },
PreCheck: func() { tcacctest.AccPreCheck(t) },
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{
{
Config: testAccCvmSyncImage,
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.sync_image", "id")),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "id"),
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "image_id"),
resource.TestCheckResourceAttrSet("tencentcloud_cvm_sync_image.example", "destination_regions.#"),
),
},
},
})
}

const testAccCvmSyncImage = `
resource "tencentcloud_cvm_sync_image" "sync_image" {
image_id = "img-k4h0m5la"
destination_regions = ["ap-shanghai"]
data "tencentcloud_images" "example" {
image_type = ["PRIVATE_IMAGE"]
}

resource "tencentcloud_cvm_sync_image" "example" {
image_id = data.tencentcloud_images.example.images.0.image_id
destination_regions = ["ap-shanghai"]
}
`
7 changes: 5 additions & 2 deletions tencentcloud/services/cvm/resource_tc_eip.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Provides an EIP resource.
Example Usage

Paid by the bandwidth package

```hcl
resource "tencentcloud_eip" "foo" {
name = "awesome_gateway_ip"
Expand All @@ -13,7 +14,8 @@ resource "tencentcloud_eip" "foo" {
```

AntiDDos Eip
```

```hcl
resource "tencentcloud_eip" "foo" {
name = "awesome_gateway_ip"
bandwidth_package_id = "bwp-4ocyia9s"
Expand All @@ -28,7 +30,8 @@ resource "tencentcloud_eip" "foo" {
```

Eip With Network Egress
```

```hcl
resource "tencentcloud_eip" "foo" {
name = "egress_eip"
egress = "center_egress2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ func ResourceTencentCloudEipAddressTransform() *schema.Resource {
Create: resourceTencentCloudEipAddressTransformCreate,
Read: resourceTencentCloudEipAddressTransformRead,
Delete: resourceTencentCloudEipAddressTransformDelete,
Importer: &schema.ResourceImporter{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我看也去掉了导入的用例

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的 没有read方法 这里要去掉import

State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"instance_id": {
Required: true,
Expand Down
47 changes: 40 additions & 7 deletions tencentcloud/services/cvm/resource_tc_eip_address_transform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,48 @@ Provides a resource to create a eip address_transform
Example Usage

```hcl
resource "tencentcloud_eip_address_transform" "address_transform" {
instance_id = ""
# create vpc
resource "tencentcloud_vpc" "vpc" {
name = "vpc"
cidr_block = "10.0.0.0/16"
}

# create vpc subnet
resource "tencentcloud_subnet" "subnet" {
name = "subnet"
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = "ap-guangzhou-6"
cidr_block = "10.0.20.0/28"
is_multicast = false
}
```

Import
# create cvm
resource "tencentcloud_instance" "example" {
instance_name = "tf_example"
availability_zone = "ap-guangzhou-6"
image_id = "img-9qrfy1xt"
instance_type = "SA3.MEDIUM4"
system_disk_type = "CLOUD_HSSD"
system_disk_size = 100
hostname = "example"
project_id = 0
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
allocate_public_ip = true
internet_max_bandwidth_out = 10

eip address_transform can be imported using the id, e.g.
data_disks {
data_disk_type = "CLOUD_HSSD"
data_disk_size = 50
encrypt = false
}

tags = {
tagKey = "tagValue"
}
}

resource "tencentcloud_eip_address_transform" "example" {
instance_id = tencentcloud_instance.example.id
}
```
terraform import tencentcloud_eip_address_transform.address_transform address_transform_id
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

// go test -i; go test -test.run TestAccTencentCloudNeedFixEipAddressTransformResource_basic -v
func TestAccTencentCloudNeedFixEipAddressTransformResource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
Expand All @@ -18,21 +19,58 @@ func TestAccTencentCloudNeedFixEipAddressTransformResource_basic(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccEipAddressTransform,
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.address_transform", "id")),
},
{
ResourceName: "tencentcloud_eip_address_transform.address_transform",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个导入也不支持吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的 没有read方法

ImportState: true,
ImportStateVerify: true,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.example", "id"),
resource.TestCheckResourceAttrSet("tencentcloud_eip_address_transform.example", "instance_id"),
),
},
},
})
}

const testAccEipAddressTransform = `
# create vpc
resource "tencentcloud_vpc" "vpc" {
name = "vpc"
cidr_block = "10.0.0.0/16"
}

# create vpc subnet
resource "tencentcloud_subnet" "subnet" {
name = "subnet"
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = "ap-guangzhou-6"
cidr_block = "10.0.20.0/28"
is_multicast = false
}

# create cvm
resource "tencentcloud_instance" "example" {
instance_name = "tf_example"
availability_zone = "ap-guangzhou-6"
image_id = "img-9qrfy1xt"
instance_type = "SA3.MEDIUM4"
system_disk_type = "CLOUD_HSSD"
system_disk_size = 100
hostname = "example"
project_id = 0
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
allocate_public_ip = true
internet_max_bandwidth_out = 10

resource "tencentcloud_eip_address_transform" "address_transform" {
instance_id = "ins-2kcdugsq"
data_disks {
data_disk_type = "CLOUD_HSSD"
data_disk_size = 50
encrypt = false
}

tags = {
tagKey = "tagValue"
}
}

resource "tencentcloud_eip_address_transform" "example" {
instance_id = tencentcloud_instance.example.id
}
`
Loading
Loading