-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(GaussDB): add gaussdb opengauss slow logs data source (#6238)
- Loading branch information
Showing
4 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
subcategory: "GaussDB" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_gaussdb_opengauss_slow_logs" | ||
description: |- | ||
Use this data source to get the list of downloaded slow query log information. | ||
--- | ||
|
||
# huaweicloud_gaussdb_opengauss_slow_logs | ||
|
||
Use this data source to get the list of downloaded slow query log information. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "instance_id" {} | ||
data "huaweicloud_gaussdb_opengauss_slow_logs" "test" { | ||
instance_id = var.instance_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the resource. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `instance_id` - (Required, String) Specifies the ID of the GaussDB OpenGauss instance. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `list` - Indicates the list of downloaded slow query log information. | ||
|
||
The [list](#list_struct) structure is documented below. | ||
|
||
<a name="list_struct"></a> | ||
The `list` block supports: | ||
|
||
* `id` - Indicates the slow query log ID. | ||
|
||
* `instance_id` - Indicates the instance ID. | ||
|
||
* `node_id` - Indicates the node ID. | ||
|
||
* `workflow_id` - Indicates the workflow ID. | ||
|
||
* `file_name` - Indicates the file name. | ||
|
||
* `file_size` - Indicates the file size in bytes. | ||
|
||
* `file_link` - Indicates the link for downloading the file. | ||
|
||
* `bucket_name` - Indicates the bucket name. | ||
|
||
* `created_at` - Indicates the creation time. | ||
|
||
* `updated_at` - Indicates the update time. | ||
|
||
* `version` - Indicates the version. | ||
|
||
* `status` - Indicates the status. | ||
|
||
* `message` - Indicates the message. | ||
|
||
## Timeouts | ||
|
||
This resource provides the following timeouts configuration options: | ||
|
||
* `read` - Default is 10 minutes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...d/services/acceptance/gaussdb/data_source_huaweicloud_gaussdb_opengauss_slow_logs_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package gaussdb | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/common" | ||
) | ||
|
||
func TestAccDataSourceOpenGaussSlowLogs_basic(t *testing.T) { | ||
dataSource := "data.huaweicloud_gaussdb_opengauss_slow_logs.test" | ||
rName := acceptance.RandomAccResourceName() | ||
dc := acceptance.InitDataSourceCheck(dataSource) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckEpsID(t) | ||
acceptance.TestAccPreCheckHighCostAllow(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDataSourceOpenGaussSlowLogs_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.instance_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.node_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.workflow_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.file_name"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.file_size"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.file_link"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.created_at"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.updated_at"), | ||
resource.TestCheckResourceAttrSet(dataSource, "list.0.status"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDataSourceOpenGaussSlowLogs_base(rName string) string { | ||
return fmt.Sprintf(` | ||
%[1]s | ||
data "huaweicloud_availability_zones" "test" {} | ||
data "huaweicloud_gaussdb_opengauss_flavors" "test" { | ||
version = "8.201" | ||
ha_mode = "centralization_standard" | ||
} | ||
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss" { | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
ethertype = "IPv4" | ||
direction = "ingress" | ||
protocol = "tcp" | ||
remote_ip_prefix = "0.0.0.0/0" | ||
} | ||
resource "huaweicloud_networking_secgroup_rule" "in_v4_tcp_opengauss_egress" { | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
ethertype = "IPv4" | ||
direction = "egress" | ||
protocol = "tcp" | ||
remote_ip_prefix = "0.0.0.0/0" | ||
} | ||
resource "huaweicloud_gaussdb_opengauss_instance" "test" { | ||
depends_on = [ | ||
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss, | ||
huaweicloud_networking_secgroup_rule.in_v4_tcp_opengauss_egress | ||
] | ||
vpc_id = huaweicloud_vpc.test.id | ||
subnet_id = huaweicloud_vpc_subnet.test.id | ||
security_group_id = huaweicloud_networking_secgroup.test.id | ||
flavor = data.huaweicloud_gaussdb_opengauss_flavors.test.flavors[0].spec_code | ||
name = "%[2]s" | ||
password = "Huangwei!120521" | ||
enterprise_project_id = "%[3]s" | ||
availability_zone = join(",", [data.huaweicloud_availability_zones.test.names[0], | ||
data.huaweicloud_availability_zones.test.names[1], | ||
data.huaweicloud_availability_zones.test.names[2]]) | ||
ha { | ||
mode = "centralization_standard" | ||
replication_mode = "sync" | ||
consistency = "eventual" | ||
instance_mode = "basic" | ||
} | ||
volume { | ||
type = "ULTRAHIGH" | ||
size = 40 | ||
} | ||
} | ||
`, common.TestBaseNetwork(rName), rName, acceptance.HW_ENTERPRISE_PROJECT_ID_TEST) | ||
} | ||
|
||
func testDataSourceOpenGaussSlowLogs_basic(rName string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
data "huaweicloud_gaussdb_opengauss_slow_logs" "test" { | ||
instance_id = huaweicloud_gaussdb_opengauss_instance.test.id | ||
} | ||
`, testDataSourceOpenGaussSlowLogs_base(rName)) | ||
} |
Oops, something went wrong.