diff --git a/acceptance/openstack/ddm/v1/helper.go b/acceptance/openstack/ddm/v1/helper.go index c8a699f44..5e49bd553 100644 --- a/acceptance/openstack/ddm/v1/helper.go +++ b/acceptance/openstack/ddm/v1/helper.go @@ -6,9 +6,11 @@ import ( golangsdk "github.com/opentelekomcloud/gophertelekomcloud" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" + "github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" - ddminstances "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v1/instances" + ddminstancesv1 "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v1/instances" + ddminstancesv2 "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v2/instances" rdsinstances "github.com/opentelekomcloud/gophertelekomcloud/openstack/rds/v3/instances" th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" @@ -27,9 +29,9 @@ func CreateRDS(t *testing.T, client *golangsdk.ServiceClient, region string) *rd vpcID := clients.EnvOS.GetEnv("VPC_ID") subnetID := clients.EnvOS.GetEnv("NETWORK_ID") kmsID := clients.EnvOS.GetEnv("KMS_ID") - secGroupId := clients.EnvOS.GetEnv("SECURITY_GROUP") - if vpcID == "" || subnetID == "" || secGroupId == "" { - t.Skip("One of OS_VPC_ID or OS_NETWORK_ID or OS_SECURITY_GROUP env vars is missing but RDS test requires using existing network") + secGroupId := openstack.DefaultSecurityGroup(t) + if vpcID == "" || subnetID == "" { + t.Skip("One of OS_VPC_ID or OS_NETWORK_ID env vars is missing but RDS test requires using existing network") } createRdsOpts := rdsinstances.CreateRdsOpts{ @@ -82,34 +84,52 @@ func DeleteRDS(t *testing.T, client *golangsdk.ServiceClient, rdsID string) { t.Logf("RDSv3 instance deleted: %s", rdsID) } -func CreateDDMInstance(t *testing.T, client *golangsdk.ServiceClient) *ddminstances.Instance { +func CreateDDMInstance(t *testing.T, client *golangsdk.ServiceClient) *ddminstancesv1.Instance { vpcID := clients.EnvOS.GetEnv("VPC_ID") subnetID := clients.EnvOS.GetEnv("NETWORK_ID") - secGroupId := clients.EnvOS.GetEnv("SECURITY_GROUP") - if subnetID == "" || vpcID == "" || secGroupId == "" { - t.Skip("OS_NETWORK_ID or OS_VPC_ID or OS_SECURITY_GROUP env vars are missing but are required for DDM instances") + if subnetID == "" || vpcID == "" { + t.Skip("OS_NETWORK_ID or OS_VPC_ID env vars are missing but are required for DDM instances") + } + secGroupId := openstack.DefaultSecurityGroup(t) + + engineId := "367b68a3-b48b-3d8a-b3a1-4c463a75a4b4" + clientV2, err := clients.NewDDMV2Client() + th.AssertNoErr(t, err) + engines, err := ddminstancesv2.QueryEngineInfo(clientV2, ddminstancesv2.QueryEngineOpts{}) + th.AssertNoErr(t, err) + if len(engines) != 0 { + engineId = engines[0].ID + } + + flavorId := "941b5a6d-3485-329e-902c-ffd49d352f16" + classes, err := ddminstancesv2.QueryNodeClasses(clientV2, ddminstancesv2.QueryNodeClassesOpts{ + EngineId: engineId, + }) + th.AssertNoErr(t, err) + if len(classes.ComputeFlavorGroups) != 0 { + flavorId = classes.ComputeFlavorGroups[0].ComputeFlavors[0].ID } instanceName := tools.RandomString("ddm-instance-", 3) - instanceDetails := ddminstances.CreateInstanceDetail{ + instanceDetails := ddminstancesv1.CreateInstanceDetail{ Name: instanceName, - FlavorId: "941b5a6d-3485-329e-902c-ffd49d352f16", + FlavorId: flavorId, NodeNum: 2, - EngineId: "367b68a3-b48b-3d8a-b3a1-4c463a75a4b4", + EngineId: engineId, AvailableZones: []string{"eu-de-01", "eu-de-02", "eu-de-03"}, VpcId: vpcID, SubnetId: subnetID, SecurityGroupId: secGroupId, } - createOpts := ddminstances.CreateOpts{ + createOpts := ddminstancesv1.CreateOpts{ Instance: instanceDetails, } t.Logf("Creating DDM Instance: %s", instanceName) - ddmInstance, err := ddminstances.Create(client, createOpts) + ddmInstance, err := ddminstancesv1.Create(client, createOpts) th.AssertNoErr(t, err) err = golangsdk.WaitFor(1200, func() (bool, error) { - instanceDetails, err := ddminstances.QueryInstanceDetails(client, ddmInstance.Id) + instanceDetails, err := ddminstancesv1.QueryInstanceDetails(client, ddmInstance.Id) if err != nil { return false, err } @@ -128,20 +148,16 @@ func CreateDDMInstance(t *testing.T, client *golangsdk.ServiceClient) *ddminstan func DeleteDDMInstance(t *testing.T, client *golangsdk.ServiceClient, instanceId string) { t.Logf("Attempting to delete DDM Instance with ID: %s", instanceId) - err := golangsdk.WaitFor(1000, func() (bool, error) { - _, err := ddminstances.Delete(client, instanceId, true) - if err != nil { - return false, nil - } - return true, nil - }) + _, err := ddminstancesv1.Delete(client, instanceId, true) + th.AssertNoErr(t, err) + err = waitForInstanceDeleted(client, 600, instanceId) th.AssertNoErr(t, err) t.Logf("Deleted DDM Instance with ID: %s", instanceId) } -func WaitForInstanceInRunningState(client *golangsdk.ServiceClient, ddmInstanceId string) error { +func WaitForInstanceInRunningState(client *golangsdk.ServiceClient, instanceID string) error { return golangsdk.WaitFor(1200, func() (bool, error) { - instanceDetails, err := ddminstances.QueryInstanceDetails(client, ddmInstanceId) + instanceDetails, err := ddminstancesv1.QueryInstanceDetails(client, instanceID) if err != nil { return false, err } @@ -152,3 +168,17 @@ func WaitForInstanceInRunningState(client *golangsdk.ServiceClient, ddmInstanceI return false, nil }) } + +func waitForInstanceDeleted(client *golangsdk.ServiceClient, secs int, instanceID string) error { + return golangsdk.WaitFor(secs, func() (bool, error) { + _, err := ddminstancesv1.QueryInstanceDetails(client, instanceID) + if err != nil { + if _, ok := err.(golangsdk.ErrDefault404); ok { + return true, nil + } + return false, err + } + + return false, nil + }) +} diff --git a/acceptance/openstack/ddm/v1/instances_test.go b/acceptance/openstack/ddm/v1/instances_test.go index 833befb85..f948fe582 100644 --- a/acceptance/openstack/ddm/v1/instances_test.go +++ b/acceptance/openstack/ddm/v1/instances_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" + "github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v1/instances" @@ -20,12 +21,10 @@ func TestDDMQueryInstances(t *testing.T) { } func TestDDMInstancesLifecycle(t *testing.T) { - vpcID := clients.EnvOS.GetEnv("VPC_ID") subnetID := clients.EnvOS.GetEnv("NETWORK_ID") - secGroupId := clients.EnvOS.GetEnv("SECURITY_GROUP") - if subnetID == "" || vpcID == "" || secGroupId == "" { - t.Skip("OS_NETWORK_ID or OS_VPC_ID or OS_SECURITY_GROUP env vars are missing but are required for DDM instances test") + if subnetID == "" || vpcID == "" { + t.Skip("OS_NETWORK_ID or OS_VPC_ID env vars are missing but are required for DDM instances test") } // CREATE CLIENT @@ -34,7 +33,13 @@ func TestDDMInstancesLifecycle(t *testing.T) { // CREATE DDM INSTANCE ddmInstance := CreateDDMInstance(t, client) - + t.Logf("Creating Second Security Group") + newSecGroupId := openstack.CreateSecurityGroup(t) + t.Cleanup(func() { + t.Logf("Deleting DDM Instance: %s", ddmInstance.Id) + DeleteDDMInstance(t, client, ddmInstance.Id) + openstack.DeleteSecurityGroup(t, newSecGroupId) + }) // RENAME DDM INSTANCE newInstanceName := tools.RandomString("ddm-instance-renamed-", 3) t.Logf("Renaming DDM Instance '%s' to '%s'", ddmInstance.Id, newInstanceName) @@ -44,27 +49,23 @@ func TestDDMInstancesLifecycle(t *testing.T) { t.Logf("Renamed DDM Instance '%s' to '%s'", ddmInstance.Id, newInstanceName) // MODIFY SECURITY GROUP - newSecGroupId := clients.EnvOS.GetEnv("SECURITY_GROUP_2") - if newSecGroupId != "" { - modifySecGroupOpts := instances.ModifySecurityGroupOpts{ - SecurityGroupId: newSecGroupId, - } - modifiedSecGroupID, err := instances.ModifySecurityGroup(client, ddmInstance.Id, modifySecGroupOpts) - th.AssertNoErr(t, err) - th.AssertEquals(t, newSecGroupId, *modifiedSecGroupID) + modifySecGroupOpts := instances.ModifySecurityGroupOpts{ + SecurityGroupId: newSecGroupId, } + modifiedSecGroupID, err := instances.ModifySecurityGroup(client, ddmInstance.Id, modifySecGroupOpts) + th.AssertNoErr(t, err) + th.AssertEquals(t, newSecGroupId, *modifiedSecGroupID) // QUERY NODES + t.Logf("Quering DDM Nodes") queryNodeOpts := instances.QueryNodesOpts{} nodeList, err := instances.QueryNodes(client, ddmInstance.Id, queryNodeOpts) th.AssertEquals(t, len(nodeList), 2) th.AssertNoErr(t, err) // QUERY NODE DETAILS + t.Logf("Quering DDM Node details: %s", nodeList[0].NodeID) nodeDetails, err := instances.QueryNodeDetails(client, ddmInstance.Id, nodeList[0].NodeID) th.AssertNoErr(t, err) th.AssertEquals(t, nodeDetails.NodeID, nodeList[0].NodeID) - - // DELETE DDM INSTANCE - DeleteDDMInstance(t, client, ddmInstance.Id) } diff --git a/acceptance/openstack/ddm/v1/schemas_test.go b/acceptance/openstack/ddm/v1/schemas_test.go index 1ea08a9c5..70aab4ab4 100644 --- a/acceptance/openstack/ddm/v1/schemas_test.go +++ b/acceptance/openstack/ddm/v1/schemas_test.go @@ -14,9 +14,8 @@ import ( func TestDDMSchemasLifecycle(t *testing.T) { vpcID := clients.EnvOS.GetEnv("VPC_ID") subnetID := clients.EnvOS.GetEnv("NETWORK_ID") - secGroupId := clients.EnvOS.GetEnv("SECURITY_GROUP") - if subnetID == "" || vpcID == "" || secGroupId == "" { - t.Skip("OS_NETWORK_ID or OS_VPC_ID or OS_SECURITY_GROUP env vars are missing but are required for DDM instances test") + if subnetID == "" || vpcID == "" { + t.Skip("OS_NETWORK_ID or OS_VPC_ID env vars are missing but are required for DDM instances test") } // CREATE DDM CLIENT @@ -26,14 +25,11 @@ func TestDDMSchemasLifecycle(t *testing.T) { rdsclient, err := clients.NewRdsV3() th.AssertNoErr(t, err) - cc, err := clients.CloudAndClient() - th.AssertNoErr(t, err) - // CREATE DDM INSTANCE ddmInstance := CreateDDMInstance(t, client) // CREATE RDS INSTANCE // RDS INSTANCE MUST BE MYSQL 5.7, 8.0 WITH LowerCaseTableNames SET TO 1 - rdsInstance := CreateRDS(t, rdsclient, cc.RegionName) + rdsInstance := CreateRDS(t, rdsclient, client.RegionID) // CLEANUP t.Cleanup(func() { diff --git a/acceptance/openstack/ddm/v2/instances_test.go b/acceptance/openstack/ddm/v2/instances_test.go index c045858b4..c636ce952 100644 --- a/acceptance/openstack/ddm/v2/instances_test.go +++ b/acceptance/openstack/ddm/v2/instances_test.go @@ -10,7 +10,7 @@ import ( ) func TestQueryEngineInfoAndNodeClasses(t *testing.T) { - // CREATE V2 ClIENT + // CREATE V2 CLIENT client, err := clients.NewDDMV2Client() th.AssertNoErr(t, err) @@ -25,28 +25,45 @@ func TestQueryEngineInfoAndNodeClasses(t *testing.T) { } func TestDDMInstancesV2Scaling(t *testing.T) { - //CREATE V1 CLIENT - ddmv1client, err := clients.NewDDMV1Client() + // CREATE V1 CLIENT + ddmV1Client, err := clients.NewDDMV1Client() th.AssertNoErr(t, err) - // CREATE V2 ClIENT - ddmv2client, err := clients.NewDDMV2Client() + // CREATE V2 CLIENT + ddmV2Client, err := clients.NewDDMV2Client() th.AssertNoErr(t, err) // CREATE DDM INSTANCE - ddmInstance := ddmhelper.CreateDDMInstance(t, ddmv1client) + ddmInstance := ddmhelper.CreateDDMInstance(t, ddmV1Client) t.Cleanup(func() { - ddmhelper.DeleteDDMInstance(t, ddmv1client, ddmInstance.Id) + ddmhelper.DeleteDDMInstance(t, ddmV1Client, ddmInstance.Id) }) // SCALE OUT + engineId := "367b68a3-b48b-3d8a-b3a1-4c463a75a4b4" + clientV2, err := clients.NewDDMV2Client() + th.AssertNoErr(t, err) + engines, err := instances.QueryEngineInfo(clientV2, instances.QueryEngineOpts{}) + th.AssertNoErr(t, err) + if len(engines) != 0 { + engineId = engines[0].ID + } + + flavorId := "941b5a6d-3485-329e-902c-ffd49d352f16" + classes, err := instances.QueryNodeClasses(clientV2, instances.QueryNodeClassesOpts{ + EngineId: engineId, + }) + th.AssertNoErr(t, err) + if len(classes.ComputeFlavorGroups) != 0 { + flavorId = classes.ComputeFlavorGroups[0].ComputeFlavors[0].ID + } t.Logf("Scaling out DDM Instance %s", ddmInstance.Id) scaleOutOpts := instances.ScaleOutOpts{ - FlavorId: "941b5a6d-3485-329e-902c-ffd49d352f16", + FlavorId: flavorId, NodeNumber: 1, } - _, err = instances.ScaleOut(ddmv2client, ddmInstance.Id, scaleOutOpts) + _, err = instances.ScaleOut(ddmV2Client, ddmInstance.Id, scaleOutOpts) th.AssertNoErr(t, err) - err = ddmhelper.WaitForInstanceInRunningState(ddmv1client, ddmInstance.Id) + err = ddmhelper.WaitForInstanceInRunningState(ddmV1Client, ddmInstance.Id) th.AssertNoErr(t, err) t.Logf("Scaled out DDM Instance %s to n+1 nodes", ddmInstance.Id) @@ -55,9 +72,9 @@ func TestDDMInstancesV2Scaling(t *testing.T) { scaleInOpts := instances.ScaleInOpts{ NodeNumber: 1, } - _, err = instances.ScaleIn(ddmv2client, ddmInstance.Id, scaleInOpts) + _, err = instances.ScaleIn(ddmV2Client, ddmInstance.Id, scaleInOpts) th.AssertNoErr(t, err) - err = ddmhelper.WaitForInstanceInRunningState(ddmv1client, ddmInstance.Id) + err = ddmhelper.WaitForInstanceInRunningState(ddmV1Client, ddmInstance.Id) th.AssertNoErr(t, err) t.Logf("Scaled in DDM Instance %s to n-1 nodes", ddmInstance.Id) diff --git a/acceptance/openstack/ddm/v3/accounts_test.go b/acceptance/openstack/ddm/v3/accounts_test.go index 50312c949..3e0dbb169 100644 --- a/acceptance/openstack/ddm/v3/accounts_test.go +++ b/acceptance/openstack/ddm/v3/accounts_test.go @@ -2,25 +2,28 @@ package v3 import ( "testing" + "time" + golangsdk "github.com/opentelekomcloud/gophertelekomcloud" "github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" ddmhelper "github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack/ddm/v1" + ddminstancesv1 "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v1/instances" "github.com/opentelekomcloud/gophertelekomcloud/openstack/ddm/v3/accounts" th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" ) func TestDDMAccountsTestV3(t *testing.T) { - //CREATE V1 CLIENT - ddmv1client, err := clients.NewDDMV1Client() + // CREATE V1 CLIENT + ddmV1Client, err := clients.NewDDMV1Client() th.AssertNoErr(t, err) - // CREATE V3 ClIENT - ddmv3client, err := clients.NewDDMV3Client() + // CREATE V3 CLIENT + ddmV3Client, err := clients.NewDDMV3Client() th.AssertNoErr(t, err) // CREATE DDM INSTANCE - ddmInstance := ddmhelper.CreateDDMInstance(t, ddmv1client) + ddmInstance := ddmhelper.CreateDDMInstance(t, ddmV1Client) t.Cleanup(func() { - ddmhelper.DeleteDDMInstance(t, ddmv1client, ddmInstance.Id) + ddmhelper.DeleteDDMInstance(t, ddmV1Client, ddmInstance.Id) }) // RESET DDM ACCOUNT PASSWORD @@ -29,7 +32,18 @@ func TestDDMAccountsTestV3(t *testing.T) { Name: "root", Password: "acc-test-password1!", } - _, err = accounts.ManageAdminPass(ddmv3client, ddmInstance.Id, manageAdminOpts) + _, err = accounts.ManageAdminPass(ddmV3Client, ddmInstance.Id, manageAdminOpts) th.AssertNoErr(t, err) + err = golangsdk.WaitFor(600, func() (bool, error) { + instanceDetails, err := ddminstancesv1.QueryInstanceDetails(ddmV1Client, ddmInstance.Id) + if err != nil { + return false, err + } + time.Sleep(5 * time.Second) + if instanceDetails.Status == "RUNNING" { + return true, nil + } + return false, nil + }) } diff --git a/acceptance/openstack/ddm/v3/instances_test.go b/acceptance/openstack/ddm/v3/instances_test.go index 4bb1251c6..55e3dd58e 100644 --- a/acceptance/openstack/ddm/v3/instances_test.go +++ b/acceptance/openstack/ddm/v3/instances_test.go @@ -10,22 +10,22 @@ import ( ) func TestDDMInstancesTestV3(t *testing.T) { - //CREATE V1 CLIENT - ddmv1client, err := clients.NewDDMV1Client() + // CREATE V1 CLIENT + ddmV1Client, err := clients.NewDDMV1Client() th.AssertNoErr(t, err) - // CREATE V3 ClIENT - ddmv3client, err := clients.NewDDMV3Client() + // CREATE V3 CLIENT + ddmV3Client, err := clients.NewDDMV3Client() th.AssertNoErr(t, err) // CREATE DDM INSTANCE - ddmInstance := ddmhelper.CreateDDMInstance(t, ddmv1client) + ddmInstance := ddmhelper.CreateDDMInstance(t, ddmV1Client) t.Cleanup(func() { - ddmhelper.DeleteDDMInstance(t, ddmv1client, ddmInstance.Id) + ddmhelper.DeleteDDMInstance(t, ddmV1Client, ddmInstance.Id) }) // QUERY PARAMETERS t.Logf("Listing parameters for DDM instance %s", ddmInstance.Id) - _, err = instances.QueryParameters(ddmv3client, ddmInstance.Id, instances.QueryParametersOpts{}) + _, err = instances.QueryParameters(ddmV3Client, ddmInstance.Id, instances.QueryParametersOpts{}) th.AssertNoErr(t, err) // MODIFY PARAMETERS @@ -35,7 +35,7 @@ func TestDDMInstancesTestV3(t *testing.T) { MaxConnections: "30000", }, } - _, err = instances.ModifyParameters(ddmv3client, ddmInstance.Id, modifyParametersOpts) + _, err = instances.ModifyParameters(ddmV3Client, ddmInstance.Id, modifyParametersOpts) th.AssertNoErr(t, err) // CHANGING NODE CLASS @@ -43,9 +43,9 @@ func TestDDMInstancesTestV3(t *testing.T) { changeNodeClassOpts := instances.ChangeNodeClassOpts{ SpecCode: "ddm.8xlarge.2", } - _, err = instances.ChangeNodeClass(ddmv3client, ddmInstance.Id, changeNodeClassOpts) + _, err = instances.ChangeNodeClass(ddmV3Client, ddmInstance.Id, changeNodeClassOpts) th.AssertNoErr(t, err) - err = ddmhelper.WaitForInstanceInRunningState(ddmv1client, ddmInstance.Id) + err = ddmhelper.WaitForInstanceInRunningState(ddmV1Client, ddmInstance.Id) th.AssertNoErr(t, err) t.Logf("Modified node class for DDM instance %s", ddmInstance.Id) } diff --git a/openstack/ddm/v1/instances/Create.go b/openstack/ddm/v1/instances/Create.go index 31b8841cb..3267c14cd 100644 --- a/openstack/ddm/v1/instances/Create.go +++ b/openstack/ddm/v1/instances/Create.go @@ -43,7 +43,7 @@ type CreateInstanceDetail struct { AdminUserPassword string `json:"admin_user_password,omitempty"` } -// This function is used to create a DDM instance +// Create function is used to create a DDM instance func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*Instance, error) { b, err := build.RequestBody(opts, "") if err != nil { diff --git a/openstack/ddm/v1/instances/Delete.go b/openstack/ddm/v1/instances/Delete.go index af7784ac5..85ff809c2 100644 --- a/openstack/ddm/v1/instances/Delete.go +++ b/openstack/ddm/v1/instances/Delete.go @@ -13,7 +13,7 @@ type DeleteQueryParams struct { DeleteRdsData string `q:"delete_rds_data"` } -// This function is used to delete a DDM instance to release all its resources. +// Delete function is used to delete a DDM instance to release all its resources. func Delete(client *golangsdk.ServiceClient, instanceId string, deleteRdsData bool) (*string, error) { deleteData := "false" diff --git a/openstack/ddm/v1/instances/ModifyName.go b/openstack/ddm/v1/instances/ModifyName.go index 7ef706aaa..0df6f5507 100644 --- a/openstack/ddm/v1/instances/ModifyName.go +++ b/openstack/ddm/v1/instances/ModifyName.go @@ -6,7 +6,7 @@ import ( "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" ) -// This function is used to modify the name of a DDM instance. +// Rename function is used to modify the name of a DDM instance. // name is the name of a DDM instance, which: // Can include 4 to 64 characters. // Must start with a letter. diff --git a/openstack/ddm/v1/instances/ModifySecurityGroup.go b/openstack/ddm/v1/instances/ModifySecurityGroup.go index f7dbcc8f4..156a98f8e 100644 --- a/openstack/ddm/v1/instances/ModifySecurityGroup.go +++ b/openstack/ddm/v1/instances/ModifySecurityGroup.go @@ -11,7 +11,7 @@ type ModifySecurityGroupOpts struct { SecurityGroupId string `json:"security_group_id" required:"true"` } -// This function is used to modify the security group of a DDM instance. +// ModifySecurityGroup function is used to modify the security group of a DDM instance. func ModifySecurityGroup(client *golangsdk.ServiceClient, instanceId string, opts ModifySecurityGroupOpts) (*string, error) { b, err := build.RequestBody(opts, "") if err != nil { diff --git a/openstack/ddm/v1/instances/QueryInstanceDetails.go b/openstack/ddm/v1/instances/QueryInstanceDetails.go index 9f1fb6b77..470e55400 100644 --- a/openstack/ddm/v1/instances/QueryInstanceDetails.go +++ b/openstack/ddm/v1/instances/QueryInstanceDetails.go @@ -5,7 +5,7 @@ import ( "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" ) -// This API is used to query details about a DDM instance. +// QueryInstanceDetails is used to query details about a DDM instance. func QueryInstanceDetails(client *golangsdk.ServiceClient, instanceId string) (*QueryInstanceDetailsResponse, error) { // GET /v1/{project_id}/instances/{instance_id} @@ -60,12 +60,12 @@ type QueryInstanceDetailsResponse struct { // Engine version (core instance version) EngineVersion string `json:"engine_version"` // Node information - Nodes []GetDetailfNodesInfo `json:"nodes"` + Nodes []GetDetailNodesInfo `json:"nodes"` // Username of the administrator. The username: Can include 1 to 32 characters. Must start with a letter. Can contain only letters, digits, and underscores (_). AdminUserName string `json:"admin_user_name"` } -type GetDetailfNodesInfo struct { +type GetDetailNodesInfo struct { // Status of the DDM instance node. For details, see Status Description at // https://docs.otc.t-systems.com/distributed-database-middleware/api-ref/appendix/status_description.html Status string `json:"status"` diff --git a/openstack/ddm/v1/instances/QueryInstances.go b/openstack/ddm/v1/instances/QueryInstances.go index 9c125d939..b78fd830b 100644 --- a/openstack/ddm/v1/instances/QueryInstances.go +++ b/openstack/ddm/v1/instances/QueryInstances.go @@ -19,7 +19,7 @@ type QueryInstancesOpts struct { Limit int `q:"limit"` } -// This function is used to query DDM instances. +// QueryInstances function is used to query DDM instances. func QueryInstances(client *golangsdk.ServiceClient, opts QueryInstancesOpts) ([]ShowInstanceBeanResponse, error) { // GET /v1/{project_id}/instances?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("instances").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v1/instances/QueryNodeDetails.go b/openstack/ddm/v1/instances/QueryNodeDetails.go index 4e6aed468..fd0f9a4a7 100644 --- a/openstack/ddm/v1/instances/QueryNodeDetails.go +++ b/openstack/ddm/v1/instances/QueryNodeDetails.go @@ -5,7 +5,7 @@ import ( "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" ) -// This API is used to query details of a DDM instance node. +// QueryNodeDetails is used to query details of a DDM instance node. func QueryNodeDetails(client *golangsdk.ServiceClient, instanceId string, nodeId string) (*QueryNodeDetailsResponse, error) { // GET /v1/{project_id}/instances/{instance_id}/nodes/{node_id} diff --git a/openstack/ddm/v1/instances/QueryNodes.go b/openstack/ddm/v1/instances/QueryNodes.go index 184f83ed7..880722708 100644 --- a/openstack/ddm/v1/instances/QueryNodes.go +++ b/openstack/ddm/v1/instances/QueryNodes.go @@ -19,7 +19,7 @@ type QueryNodesOpts struct { Limit int `q:"limit"` } -// This function is used to query nodes of a DDM instance. +// QueryNodes function is used to query nodes of a DDM instance. func QueryNodes(client *golangsdk.ServiceClient, instanceId string, opts QueryNodesOpts) ([]NodeList, error) { // GET /v1/{project_id}/instances/{instance_id}/nodes?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", instanceId, "nodes").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v1/instances/ReloadTableData.go b/openstack/ddm/v1/instances/ReloadTableData.go index 0b32d9e92..d9d071b28 100644 --- a/openstack/ddm/v1/instances/ReloadTableData.go +++ b/openstack/ddm/v1/instances/ReloadTableData.go @@ -4,7 +4,7 @@ import ( golangsdk "github.com/opentelekomcloud/gophertelekomcloud" ) -// This function is used to reload table data of the destination DDM instance for cross-region DR. +// ReloadTableData function is used to reload table data of the destination DDM instance for cross-region DR. func ReloadTableData(client *golangsdk.ServiceClient, instanceId string) error { // POST /v1/{project_id}/instances/{instance_id}/reload-config _, err := client.Post(client.ServiceURL("instances", instanceId, "reload-config"), nil, nil, &golangsdk.RequestOpts{ diff --git a/openstack/ddm/v1/instances/RestartInstance.go b/openstack/ddm/v1/instances/RestartInstance.go index 01bb87f97..5d2fbc82f 100644 --- a/openstack/ddm/v1/instances/RestartInstance.go +++ b/openstack/ddm/v1/instances/RestartInstance.go @@ -21,7 +21,7 @@ type RestartInstanceInfo struct { Type string `json:"type,omitempty"` } -// This function is used to restart a DDM instance. +// RestartInstance function is used to restart a DDM instance. // Specify Restart in the RestartOpts for proper result. func RestartInstance(client *golangsdk.ServiceClient, instanceId string, opts RestartOpts) (*ResponseInstance, error) { b, err := build.RequestBody(opts, "") diff --git a/openstack/ddm/v1/instances/SyncDataNode.go b/openstack/ddm/v1/instances/SyncDataNode.go index 22b6430cf..2d4768dea 100644 --- a/openstack/ddm/v1/instances/SyncDataNode.go +++ b/openstack/ddm/v1/instances/SyncDataNode.go @@ -5,7 +5,7 @@ import ( "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" ) -// This API is used to synchronize configuration information of all data nodes that are associated with a DDM instance. +// SyncDataNodesInfo is used to synchronize configuration information of all data nodes that are associated with a DDM instance. func SyncDataNodesInfo(client *golangsdk.ServiceClient, instanceId string) (*SyncDataNodesInfoResponse, error) { // POST /v1/{project_id}/instances/{instance_id}/rds/sync diff --git a/openstack/ddm/v1/schemas/Create.go b/openstack/ddm/v1/schemas/Create.go index 0e693c216..f2b892e86 100644 --- a/openstack/ddm/v1/schemas/Create.go +++ b/openstack/ddm/v1/schemas/Create.go @@ -44,7 +44,7 @@ type DatabaseInstancesParam struct { AdminPassword string `json:"adminPassword" required:"true"` } -// This function is used to create a schema. +// CreateSchema function is used to create a schema. // Before creating a schema, ensure that you have associated RDS instances with your DDM instance and that the RDS instances are not associated with other DDM instances. func CreateSchema(client *golangsdk.ServiceClient, instanceId string, opts CreateSchemaOpts) (*CreateSchemaResponse, error) { b, err := build.RequestBody(opts, "") diff --git a/openstack/ddm/v1/schemas/Delete.go b/openstack/ddm/v1/schemas/Delete.go index 2f5c8e472..439c5d47f 100644 --- a/openstack/ddm/v1/schemas/Delete.go +++ b/openstack/ddm/v1/schemas/Delete.go @@ -14,7 +14,7 @@ type DeleteQueryParams struct { DeleteRdsData string `q:"delete_rds_data"` } -// This function is used to delete a schema to release all its resources. +// DeleteSchema is used to delete a schema to release all its resources. // schemaName is the name of the schema to be queried, which is case-insensitive func DeleteSchema(client *golangsdk.ServiceClient, instanceId string, schemaName string, deleteRdsData bool) (*string, error) { diff --git a/openstack/ddm/v1/schemas/QueryAvailableDBInstances.go b/openstack/ddm/v1/schemas/QueryAvailableDBInstances.go index 531dbcdbc..9b25f02d9 100644 --- a/openstack/ddm/v1/schemas/QueryAvailableDBInstances.go +++ b/openstack/ddm/v1/schemas/QueryAvailableDBInstances.go @@ -19,7 +19,7 @@ type QueryAvailableDbOpts struct { Limit int `q:"limit"` } -// This function is used to query DB instances that can be used for creating a schema. +// QueryAvailableDb is used to query DB instances that can be used for creating a schema. func QueryAvailableDb(client *golangsdk.ServiceClient, instanceId string, opts QueryAvailableDbOpts) ([]QueryAvailableRdsList, error) { // GET /v1/{project_id}/instances/{instance_id}/rds?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", instanceId, "rds").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v1/schemas/QuerySchemaDetails.go b/openstack/ddm/v1/schemas/QuerySchemaDetails.go index 3365a0203..c90018943 100644 --- a/openstack/ddm/v1/schemas/QuerySchemaDetails.go +++ b/openstack/ddm/v1/schemas/QuerySchemaDetails.go @@ -5,7 +5,7 @@ import ( "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" ) -// This API is used to query details about a schema. +// QuerySchemaDetails is used to query details about a schema. // schemaName is the name of the schema to be queried, which is case-insensitive func QuerySchemaDetails(client *golangsdk.ServiceClient, instanceId string, schemaName string) (*QuerySchemaDetailsResponse, error) { diff --git a/openstack/ddm/v1/schemas/QuerySchemas.go b/openstack/ddm/v1/schemas/QuerySchemas.go index 008c71bba..f24932f85 100644 --- a/openstack/ddm/v1/schemas/QuerySchemas.go +++ b/openstack/ddm/v1/schemas/QuerySchemas.go @@ -19,7 +19,7 @@ type QuerySchemasOpts struct { Limit int `q:"limit"` } -// This function is used to query schemas of a DDM instance. +// QuerySchemas is used to query schemas of a DDM instance. func QuerySchemas(client *golangsdk.ServiceClient, instanceId string, opts QuerySchemasOpts) ([]GetDatabaseInfo, error) { // GET /v1/{project_id}/instances/{instance_id}/databases?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", instanceId, "databases").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v2/instances/ModifyDBReadPolicy.go b/openstack/ddm/v2/instances/ModifyDBReadPolicy.go index 89bd484ce..7471a5c4a 100644 --- a/openstack/ddm/v2/instances/ModifyDBReadPolicy.go +++ b/openstack/ddm/v2/instances/ModifyDBReadPolicy.go @@ -12,7 +12,7 @@ type ModifyDbReadPolicyOpts struct { ReadWeight map[string]int `json:"read_weight" required:"true"` } -// This function is used to modify the read policy of the DB instance associated with a DDM instance. +// ModifyDbReadPolicy is used to modify the read policy of the DB instance associated with a DDM instance. func ModifyDbReadPolicy(client *golangsdk.ServiceClient, instanceId string, opts ModifyDbReadPolicyOpts) (*ModifyDbReadPolicyResponse, error) { b, err := build.RequestBody(opts, "") if err != nil { diff --git a/openstack/ddm/v2/instances/QueryEngineInfo.go b/openstack/ddm/v2/instances/QueryEngineInfo.go index 34516c173..d5f5e802e 100644 --- a/openstack/ddm/v2/instances/QueryEngineInfo.go +++ b/openstack/ddm/v2/instances/QueryEngineInfo.go @@ -19,7 +19,7 @@ type QueryEngineOpts struct { Limit int `q:"limit"` } -// This function is used to query DDM instances. +// QueryEngineInfo is used to query DDM instances. func QueryEngineInfo(client *golangsdk.ServiceClient, opts QueryEngineOpts) ([]EngineGroupsInfo, error) { // GET /v2/{project_id}/engines?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("engines").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v2/instances/QueryNodeClasses.go b/openstack/ddm/v2/instances/QueryNodeClasses.go index 3bfae883d..d1ccae6fd 100644 --- a/openstack/ddm/v2/instances/QueryNodeClasses.go +++ b/openstack/ddm/v2/instances/QueryNodeClasses.go @@ -18,7 +18,7 @@ type QueryNodeClassesOpts struct { Limit int `q:"limit"` } -// This function is used to query DDM node classes available in an AZ. +// QueryNodeClasses is used to query DDM node classes available in an AZ. func QueryNodeClasses(client *golangsdk.ServiceClient, opts QueryNodeClassesOpts) (*QueryNodeClassesResponse, error) { // GET /v2/{project_id}/flavors?engine_id={engine_id}?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("flavors").WithQueryParams(&opts).Build() diff --git a/openstack/ddm/v2/instances/ScaleIn.go b/openstack/ddm/v2/instances/ScaleIn.go index b96811def..708bb4aee 100644 --- a/openstack/ddm/v2/instances/ScaleIn.go +++ b/openstack/ddm/v2/instances/ScaleIn.go @@ -13,7 +13,7 @@ type ScaleInOpts struct { GroupId string `json:"group_id,omitempty"` } -// This function is used to remove nodes from a specified DDM instance. +// ScaleIn is used to remove nodes from a specified DDM instance. func ScaleIn(client *golangsdk.ServiceClient, instanceId string, opts ScaleInOpts) (*ScaleInResponse, error) { b, err := build.RequestBody(opts, "") if err != nil { diff --git a/openstack/ddm/v2/instances/ScaleOut.go b/openstack/ddm/v2/instances/ScaleOut.go index 6e68bae5c..671244172 100644 --- a/openstack/ddm/v2/instances/ScaleOut.go +++ b/openstack/ddm/v2/instances/ScaleOut.go @@ -17,7 +17,7 @@ type ScaleOutOpts struct { IsAutoPay bool `json:"is_auto_pay,omitempty"` } -// This function is used to scale out a specified DDM instance. +// ScaleOut is used to scale out a specified DDM instance. func ScaleOut(client *golangsdk.ServiceClient, instanceId string, opts ScaleOutOpts) (*ScaleOutResponse, error) { b, err := build.RequestBody(opts, "") if err != nil { diff --git a/openstack/ddm/v3/accounts/ManageAdminPassword.go b/openstack/ddm/v3/accounts/ManageAdminPassword.go index 0dbdc41cd..fe3048425 100644 --- a/openstack/ddm/v3/accounts/ManageAdminPassword.go +++ b/openstack/ddm/v3/accounts/ManageAdminPassword.go @@ -19,7 +19,7 @@ type ManageAdminPassOpts struct { Password string `json:"password" required:"true"` } -// This function is used to manage the password of the DDM instance administrator. +// ManageAdminPass is used to manage the password of the DDM instance administrator. // If it is the first time to call this API, it is used to create an administrator and reset its password for a DDM instance. // Then this API can only be used to update the administrator password. func ManageAdminPass(client *golangsdk.ServiceClient, instanceId string, opts ManageAdminPassOpts) (*ManageAdminPassResponse, error) { diff --git a/openstack/ddm/v3/instances/ModifyParameters.go b/openstack/ddm/v3/instances/ModifyParameters.go index 9557acf9a..a9a69a840 100644 --- a/openstack/ddm/v3/instances/ModifyParameters.go +++ b/openstack/ddm/v3/instances/ModifyParameters.go @@ -15,84 +15,65 @@ type Values struct { // Data association among multiple sharded tables. The optimizer processes JOIN operations at the MySQL layer based on these associations. // The format is [{tb.col1,tb2.col2},{tb.col2,tb3.col1},...]. (Optional) BindTable string `json:"bind_table,omitempty"` - // DDM server's character set. To store emoticons, set both this parameter and the character set on RDS to utf8mb4. // Enumerated values: gbk, utf8, utf8mb4 (Optional) CharacterSetServer string `json:"character_set_server,omitempty"` - // Collation on the DDM server. // Enumerated values: utf8_unicode_ci, utf8_bin, gbk_chinese_ci, gbk_bin, utf8mb4_unicode_ci, utf8mb4_bin (Optional) CollationServer string `json:"collation_server,omitempty"` - // Concurrency level of scanning table shards in a logical table. // Enumerated values: RDS_INSTANCE, DATA_NODE, PHY_TABLE (Optional) ConcurrentExecutionLevel string `json:"concurrent_execution_level,omitempty"` - // Number of seconds the server waits for activity on a connection before closing it. // Range: 60-28800. Default: 28800 (Optional) ConnectionIdleTimeout string `json:"connection_idle_timeout,omitempty"` - // Whether the table recycle bin is enabled. // Enumerated values: OFF, ON (Optional) EnableTableRecycle string `json:"enable_table_recycle,omitempty"` - // Whether constant values can be inserted by executing the LOAD DATA statement. // Enumerated values: OFF, ON (Optional) InsertToLoadData string `json:"insert_to_load_data,omitempty"` - // Timeout limit of an in-transit transaction, in seconds. // Range: 0-100. Default: 1 (Optional) LiveTransactionTimeoutOnShutdown string `json:"live_transaction_timeout_on_shutdown,omitempty"` - // Minimum duration of a query to be logged as slow, in seconds. // Range: 0.01-10. Default: 1 (Optional) LongQueryTime string `json:"long_query_time,omitempty"` - // Maximum size of a packet or any generated intermediate string. // Range: 1024-1073741824. Default: 16777216 (Optional) MaxAllowedPacket string `json:"max_allowed_packet,omitempty"` - // Maximum of concurrent RDS client connections allowed per DDM instance. Default: 0 (Optional) MaxBackendConnections string `json:"max_backend_connections,omitempty"` - // Concurrent connections allowed per DDM instance, depending on the class and quantity of associated RDS instances. // Range: 10-40000. Default: 20000 (Optional) MaxConnections string `json:"max_connections,omitempty"` - // Minimum concurrent connections from a DDM node to an RDS instance. // Range: 0-10000000. Default: 10 (Optional) MinBackendConnections string `json:"min_backend_connections,omitempty"` - // Whether the SELECT statements that do not contain any FROM clauses are pushed down. // Enumerated values: OFF, ON (Optional) NotFromPushdown string `json:"not_from_pushdown,omitempty"` - // Threshold in seconds of the replication lag between a primary RDS instance to its read replica. // Range: 0-7200. Default: 30 (Optional) SecondsBehindMaster string `json:"seconds_behind_master,omitempty"` - // Whether SQL audit is enabled. // Enumerated values: OFF, ON (Optional) SQLAudit string `json:"sql_audit,omitempty"` - // Number of seconds to wait for a SQL statement to execute before it times out. // Range: 100-28800. Default: 28800 (Optional) SQLExecuteTimeout string `json:"sql_execute_timeout,omitempty"` - // Whether a binlog hint is added to each DDL statement. // Enumerated values: OFF, ON (Optional) SupportDDLBinlogHint string `json:"support_ddl_binlog_hint,omitempty"` - // Transactions supported by DDM. // Enumerated values: XA, FREE, NO_DTX (Optional) TransactionPolicy string `json:"transaction_policy,omitempty"` - // Whether the SQL execution plan is optimized based on parameter values. // Enumerated values: OFF, ON (Optional) UltimateOptimize string `json:"ultimate_optimize,omitempty"` } -// This function is used to modify parameters of a DDM instance. +// ModifyParameters is used to modify parameters of a DDM instance. func ModifyParameters(client *golangsdk.ServiceClient, instanceId string, opts ModifyParametersOpts) (*ModifyParametersResponse, error) { b, err := build.RequestBody(opts, "") if err != nil { @@ -114,16 +95,12 @@ func ModifyParameters(client *golangsdk.ServiceClient, instanceId string, opts M type ModifyParametersResponse struct { // DDM instance nodes NodeList string `json:"nodeList"` - // Whether the instance needs to be restarted NeedRestart bool `json:"needRestart"` - // Task ID JobID string `json:"jobId"` - // Parameter group ID ConfigID string `json:"configId"` - // Parameter group name ConfigName string `json:"configName"` } diff --git a/openstack/ddm/v3/instances/QueryParameters.go b/openstack/ddm/v3/instances/QueryParameters.go index 024336783..f64902d4b 100644 --- a/openstack/ddm/v3/instances/QueryParameters.go +++ b/openstack/ddm/v3/instances/QueryParameters.go @@ -19,7 +19,7 @@ type QueryParametersOpts struct { Limit int `q:"limit"` } -// This function is used to query parameters of a specified DDM instance. +// QueryParameters is used to query parameters of a specified DDM instance. func QueryParameters(client *golangsdk.ServiceClient, instanceId string, opts QueryParametersOpts) ([]ConfigurationParameterList, error) { // GET /v3/{project_id}/instances/{instance_id}/configurations?offset={offset}&limit={limit} url, err := golangsdk.NewURLBuilder().WithEndpoints("instances", instanceId, "configurations").WithQueryParams(&opts).Build()