Skip to content
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

Feature dli new #1321

Merged
merged 6 commits into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
73 changes: 53 additions & 20 deletions docs/resources/dli_queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
subcategory: "Data Lake Insight (DLI)"
---

# huaweicloud\_dli\_queue
# huaweicloud_dli_queue

DLI Queue management
Allows you to create a queue. The queue will be bound to specified compute resources.

This is an alternative to `huaweicloud_dli_queue`
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved

## Example Usage
Expand All @@ -13,32 +15,63 @@ This is an alternative to `huaweicloud_dli_queue`

```hcl
resource "huaweicloud_dli_queue" "queue" {
name = "terraform_dli_queue_test"
cu_count = 4
name = "terraform_dli_queue_test"
cu_count = 16
resource_mode = 0
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved

tags = {
k1 = "1"
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

## Argument Reference

The following arguments are supported:

* `region` - (Optional, String, ForceNew) The region in which to create the DLI queue resource. If omitted, the provider-level region will be used. Changing this creates a new DLI Queue resource.

* `cu_count` - (Required, Int, ForceNew) Minimum number of CUs that are bound to a queue. The value can be 4,
16, or 64. Changing this parameter will create a new resource.

* `name` - (Required, String, ForceNew) Name of a queue. The name can contain only digits, letters, and
underscores (_), but cannot contain only digits or start with an
underscore (_). Changing this parameter will create a new resource.

* `description` - (Optional, String, ForceNew) Description of a queue. Changing this parameter will create a new resource.

* `management_subnet_cidr` - (Optional, String, ForceNew) CIDR of the management subnet. Changing this parameter will create a new resource.

* `subnet_cidr` - (Optional, String, ForceNew) Subnet CIDR. Changing this parameter will create a new resource.

* `vpc_cidr` - (Optional, String, ForceNew) VPC CIDR. Changing this parameter will create a new resource.

* `region` - (Optional, String, ForceNew) Specifies the region in which to create the dli queue resource.
If omitted, the provider-level region will be used.
Changing this will create a new VPC channel resource.

* `name` - (Required, String, ForceNew) Name of a queue. Name of a newly created resource queue.
The name can contain only digits, letters, and underscores (_),
but cannot contain only digits or start with an underscore (_).
Length range: 1 to 128 characters. Changing this parameter will create a new resource.

* `queue_type` - (Optional, String, ForceNew) Indicates the queue type.
Changing this parameter will create a new resource. The options are as follows:
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved
- sql,
- general
> NOTE: If the type is not specified, the default value sql is used.

* `description` - (Optional, String, ForceNew) Description of a queue.
Changing this parameter will create a new resource.

* `cu_count` - (Required, Int, ForceNew) Minimum number of CUs that are bound to a queue. The value can be 16,
64, or 256. Changing this parameter will create a new resource.

* `enterprise_project_id` - (Optional, String, ForceNew) Enterprise project ID.
The value 0 indicates the default enterprise project. Changing this parameter will create a new resource.

* `platform` - (Optional, String, ForceNew) CPU architecture of queue compute resources.
Changing this parameter will create a new resource.
The options are as follows:
- x86_64 : default value
- aarch64

* `resource_mode` - (Optional, String, ForceNew) Queue resource mode.
Changing this parameter will create a new resource.
The options are as follows:
- 0: indicates the shared resource mode.
- 1: indicates the exclusive resource mode.

* `feature` - (Optional, String, ForceNew)Indicates the queue feature.
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved
Changing this parameter will create a new resource.
The options are as follows:
- basic: basic type (default value)
- ai: AI-enhanced (Only the SQL x86_64 dedicated queue supports this option.)

* `tags` - (Optional, Map, ForceNew) Label of a queue. Changing this parameter will create a new resource.
## Attributes Reference

In addition to all arguments above, the following attributes are exported:
Expand Down
5 changes: 3 additions & 2 deletions huaweicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/apig"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/deprecated"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/dli"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/elb"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/lb"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/waf"
Expand Down Expand Up @@ -412,7 +413,7 @@ func Provider() terraform.ResourceProvider {
"huaweicloud_dcs_instance": ResourceDcsInstanceV1(),
"huaweicloud_dds_instance": ResourceDdsInstanceV3(),
"huaweicloud_dis_stream": ResourceDisStreamV2(),
"huaweicloud_dli_queue": ResourceDliQueueV1(),
"huaweicloud_dli_queue": dli.ResourceDliQueueV1(),
"huaweicloud_dms_group": ResourceDmsGroupsV1(),
"huaweicloud_dms_instance": ResourceDmsInstancesV1(),
"huaweicloud_dms_queue": ResourceDmsQueuesV1(),
Expand Down Expand Up @@ -602,7 +603,7 @@ func Provider() terraform.ResourceProvider {
"huaweicloud_vpnaas_ike_policy_v2": ResourceVpnIKEPolicyV2(),
"huaweicloud_vpnaas_endpoint_group_v2": ResourceVpnEndpointGroupV2(),
"huaweicloud_vpnaas_site_connection_v2": ResourceVpnSiteConnectionV2(),
"huaweicloud_dli_queue_v1": ResourceDliQueueV1(),
"huaweicloud_dli_queue_v1": dli.ResourceDliQueueV1(),
"huaweicloud_cs_route_v1": resourceCsRouteV1(),
"huaweicloud_networking_vip_v2": resourceNetworkingVIPV2(),
"huaweicloud_networking_vip_associate_v2": resourceNetworkingVIPAssociateV2(),
Expand Down
2 changes: 1 addition & 1 deletion huaweicloud/resource_huaweicloud_dli_queue_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func testAccDliQueueV1_basic(val string) string {
return fmt.Sprintf(`
resource "huaweicloud_dli_queue_v1" "queue" {
name = "terraform_dli_queue_v1_test%s"
cu_count = 4
cu_count = 16
}
`, val)
}
Expand Down
6 changes: 6 additions & 0 deletions huaweicloud/services/acceptance/acceptance.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package acceptance

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud"
Expand Down Expand Up @@ -71,3 +73,7 @@ func TestAccPreCheckEpsID(t *testing.T) {
t.Fatal("HW_ENTERPRISE_PROJECT_ID must be set for acceptance tests")
}
}

func RandomAccResourceName() string {
return fmt.Sprintf("tf_acc_test_%s", acctest.RandString(5))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package dli

import (
"fmt"
"strings"
"testing"

"github.com/huaweicloud/golangsdk/openstack/dli/v1/queues"
act "github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils/fmtp"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config"
)

func TestAccDliQueueV1_basic(t *testing.T) {
rName := fmt.Sprintf("tf_acc_test_dli_queue_%s", acctest.RandString(5))
resourceName := "huaweicloud_dli_queue_v1.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { act.TestAccPreCheck(t) },
Providers: act.TestAccProviders,
CheckDestroy: testAccCheckDliQueueV1Destroy,
Steps: []resource.TestStep{
{
Config: testAccDliQueueV1_basic(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckDliQueueV1Exists(resourceName),
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved
),
},
},
})
}

func testAccDliQueueV1_basic(rName string) string {
return fmt.Sprintf(`
resource "huaweicloud_dli_queue_v1" "test" {
name = "%s"
cu_count = 16
resource_mode = 0

tags = {
k1 = "1"
}
}`, rName)
hmbig2 marked this conversation as resolved.
Show resolved Hide resolved
}

func testAccCheckDliQueueV1Destroy(s *terraform.State) error {
config := act.TestAccProvider.Meta().(*config.Config)
client, err := config.DliV1Client(act.HW_REGION_NAME)
if err != nil {
return fmtp.Errorf("error creating Dli client, err=%s", err)
}

for _, rs := range s.RootModule().Resources {
if rs.Type != "huaweicloud_dli_queue_v1" {
continue
}

res, err := fetchDliQueueV1ByQueueNameOnTest(rs.Primary.ID, client)
if err == nil && res != nil {
return fmtp.Errorf("huaweicloud_dli_queue_v1 still exists:%s,%+v,%+v", rs.Primary.ID, err, res)
}
}

return nil
}

func testAccCheckDliQueueV1Exists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
config := act.TestAccProvider.Meta().(*config.Config)
client, err := config.DliV1Client(act.HW_REGION_NAME)
if err != nil {
return fmtp.Errorf("error creating Dli client, err=%s", err)
}

rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmtp.Errorf("Error checking huaweicloud_dli_queue_v1.queue exist, err=not found this resource")
}
_, err = fetchDliQueueV1ByQueueNameOnTest(rs.Primary.ID, client)
if err != nil {
if strings.Contains(err.Error(), "Error finding the resource by list api") {
return fmtp.Errorf("huaweicloud_dli_queue_v1 is not exist")
}
return fmtp.Errorf("Error checking huaweicloud_dli_queue_v1.queue exist, err=%s", err)
}
return nil
}
}

func fetchDliQueueV1ByQueueNameOnTest(primaryID string,
client *golangsdk.ServiceClient) (interface{}, error) {
result := queues.Get(client, primaryID)
return result.Body, result.Err
}
Loading