diff --git a/tencentcloud/resource_tc_kubernetes_addon_attachment_test.go b/tencentcloud/resource_tc_kubernetes_addon_attachment_test.go index 0192fc2a79..793acd43ca 100644 --- a/tencentcloud/resource_tc_kubernetes_addon_attachment_test.go +++ b/tencentcloud/resource_tc_kubernetes_addon_attachment_test.go @@ -3,9 +3,11 @@ package tencentcloud import ( "context" "fmt" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" ) const defaultAddonName = "cos" @@ -30,10 +32,17 @@ func init() { return fmt.Errorf("no persistent cluster") } - clusterId := cls[0].ClusterId - - if err = service.DeleteExtensionAddon(ctx, clusterId, defaultAddonName); err != nil { - return err + for _,c := range cls { + clusterId := c.ClusterId + if err = service.DeleteExtensionAddon(ctx, clusterId, defaultAddonName); err != nil { + if e, ok := err.(*errors.TencentCloudSDKError); ok { + // suppress the not found error when cos doesn't exist + if strings.Contains(e.GetMessage(), "application cos not found") { + continue + } + } + return err + } } return nil diff --git a/tencentcloud/resource_tc_kubernetes_backup_storage_location_test.go b/tencentcloud/resource_tc_kubernetes_backup_storage_location_test.go index 1745ca3f62..43d321a3f9 100644 --- a/tencentcloud/resource_tc_kubernetes_backup_storage_location_test.go +++ b/tencentcloud/resource_tc_kubernetes_backup_storage_location_test.go @@ -8,11 +8,8 @@ import ( "testing" "time" - "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525" ) const ( @@ -24,7 +21,7 @@ const ( func init() { // go test -v ./tencentcloud -sweep=ap-guangzhou -sweep-run=tencentcloud_backup_storage_location - resource.AddTestSweepers("testBackupStorageLocationSweep", &resource.Sweeper{ + resource.AddTestSweepers("tencentcloud_backup_storage_location", &resource.Sweeper{ Name: "tencentcloud_backup_storage_location", F: testBackupStorageLocationSweep, }) @@ -69,23 +66,19 @@ func testBackupStorageLocationSweep(region string) error { client := cli.(*TencentCloudClient).apiV3Conn service := TkeService{client: client} - randomNum := rand.Intn(100) - backupStorageLocationName := fmt.Sprintf(backupStorageLocationNameTemplate, randomNum) - backupLocationBucket := fmt.Sprintf(backupLocationBucketTemplate, randomNum) - - // create backup storage location - request := tke.NewCreateBackupStorageLocationRequest() - request.Name = helper.String(backupStorageLocationName) - request.StorageRegion = helper.String(region) - request.Bucket = helper.String(backupLocationBucket) - if err := service.createBackupStorageLocation(ctx, request); err != nil { - return fmt.Errorf("error creating backup storage location: %s", err) + // delete all backup storage location + locations, err := service.describeBackupStorageLocations(ctx, []string{}) + if err != nil { + return err } - // delete backup storage location - if err := service.deleteBackupStorageLocation(ctx, backupStorageLocationName); err != nil { - return fmt.Errorf("error deleting backup storage location: %s", err) + for _, l:= range locations{ + deleteLocation := l.Name + if err = service.deleteBackupStorageLocation(ctx, *deleteLocation); err != nil { + return fmt.Errorf("error deleting backup storage location: %s", err) + } } + return nil } diff --git a/tencentcloud/resource_tc_kubernetes_cluster_endpoint_test.go b/tencentcloud/resource_tc_kubernetes_cluster_endpoint_test.go index b1a2fb8768..b9abe149ac 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster_endpoint_test.go +++ b/tencentcloud/resource_tc_kubernetes_cluster_endpoint_test.go @@ -130,7 +130,7 @@ resource "tencentcloud_kubernetes_node_pool" "np_test" { instance_type = var.ins_type system_disk_type = "CLOUD_PREMIUM" system_disk_size = "50" - security_group_ids = [local.sg_id] + orderly_security_group_ids = [local.sg_id] cam_role_name = "TCB_QcsRole" data_disk { diff --git a/tencentcloud/resource_tc_kubernetes_node_pool_test.go b/tencentcloud/resource_tc_kubernetes_node_pool_test.go index 44f1729400..107101179c 100644 --- a/tencentcloud/resource_tc_kubernetes_node_pool_test.go +++ b/tencentcloud/resource_tc_kubernetes_node_pool_test.go @@ -27,7 +27,7 @@ func init() { }) } -var nodePoolNameReg = regexp.MustCompile("^(mynodepool|np)") +var nodePoolNameReg = regexp.MustCompile("^(mynodepool|np|gpu)") func testNodePoolSweep(region string) error { logId := getLogId(contextNil)