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

Css updates #754

Merged
merged 12 commits into from
Dec 20, 2024
25 changes: 25 additions & 0 deletions acceptance/openstack/css/v1/change_cluser_name_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestChangeClusterNameWorkflow(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

opts := clusters.ChangeClusterNameOpts{
DisplayName: tools.RandomString("changed-css-", 4),
}
err = clusters.ChangeClusterName(client, clusterID, opts)
th.AssertNoErr(t, err)
}
27 changes: 27 additions & 0 deletions acceptance/openstack/css/v1/change_password_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestChangePasswordWorkflow(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

opts := clusters.ChangePasswordOpts{

NewPassword: tools.RandomString("newpass-css-", 4),
}
err = clusters.ChangePassword(client, clusterID, opts)

th.AssertNoErr(t, err)
}
90 changes: 90 additions & 0 deletions acceptance/openstack/css/v1/cluster_add_nodes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/flavors"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestAddClusterClientNodes(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

nodeType := "ess-client"
nodeSize := 1
volumeType := "HIGH"

cluster, err := clusters.Get(client, clusterID)
th.AssertNoErr(t, err)

for _, instance := range cluster.Instances {
if instance.Type == nodeType {
t.Skip("Cluster already contains ess-client nodes.")
}
}

Versions, err := flavors.List(client)
th.AssertNoErr(t, err)
filteredVersions := flavors.FilterVersions(Versions, flavors.FilterOpts{
Version: cluster.Datastore.Version,
Type: nodeType,
})

_, err = clusters.AddClusterNodes(client, clusterID, nodeType, clusters.AddNodesOpts{
Flavor: filteredVersions[0].Flavors[0].FlavorID,
NodeSize: nodeSize,
VolumeType: volumeType,
})
th.AssertNoErr(t, err)

timeout := 1200

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}

func TestAddClusterMasterNodes(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

nodeType := "ess-master"
nodeSize := 3
volumeType := "HIGH"

cluster, err := clusters.Get(client, clusterID)
th.AssertNoErr(t, err)

for _, instance := range cluster.Instances {
if instance.Type == nodeType {
t.Skip("Cluster already contains ess-master nodes.")
}
}

Versions, err := flavors.List(client)
th.AssertNoErr(t, err)
filteredVersions := flavors.FilterVersions(Versions, flavors.FilterOpts{
Version: cluster.Datastore.Version,
Type: nodeType,
})

_, err = clusters.AddClusterNodes(client, clusterID, nodeType, clusters.AddNodesOpts{
Flavor: filteredVersions[0].Flavors[0].FlavorID,
NodeSize: nodeSize,
VolumeType: volumeType,
})
th.AssertNoErr(t, err)

timeout := 1200

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}
30 changes: 30 additions & 0 deletions acceptance/openstack/css/v1/cluster_scale_in_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestScaleInCluster(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

err = clusters.ScaleInCluster(client, clusterID, []clusters.ScaleInOpts{
{
Type: "ess",
ReduceNodeNum: 1,
},
})
th.AssertNoErr(t, err)

timeout := 1200

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}
113 changes: 113 additions & 0 deletions acceptance/openstack/css/v1/cluster_update_flavor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/flavors"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestUpdateClusterFlavor(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

cluster, err := clusters.Get(client, clusterID)
th.AssertNoErr(t, err)

var (
currentFlavor string
newFlavorID string
instanceType string = "ess"
)

for _, instance := range cluster.Instances {
if instance.Type == instanceType {
currentFlavor = instance.SpecCode
break
}
}

filterOpts := flavors.FilterOpts{
Version: "7.10.2",
Type: instanceType,
}

versions, err := flavors.List(client)
th.AssertNoErr(t, err)

filteredVersions := flavors.FilterVersions(versions, filterOpts)
if filteredVersions[0].Flavors[0].Name != currentFlavor {
newFlavorID = filteredVersions[0].Flavors[0].FlavorID
} else {
newFlavorID = filteredVersions[0].Flavors[1].FlavorID
}
needCheckReplica := false
err = clusters.UpdateClusterFlavor(client, clusterID, clusters.ClusterFlavorOpts{
NeedCheckReplica: &needCheckReplica,
NewFlavorID: newFlavorID,
})
th.AssertNoErr(t, err)

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}

func TestUpdateClusterNodeFlavor(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

cluster, err := clusters.Get(client, clusterID)
th.AssertNoErr(t, err)

var (
currentFlavor string
newFlavorID string
instanceType string
)

for _, instance := range cluster.Instances {
if instance.Type == "ess-cold" || instance.Type == "ess-client" || instance.Type == "ess-master" {
currentFlavor = instance.SpecCode
instanceType = instance.Type
break
}
}

if instanceType == "" {
t.Skip("There are no client, cold or master nodes to change the flavor.")
}

filterOpts := flavors.FilterOpts{
Version: "7.10.2",
Type: instanceType,
}

versions, err := flavors.List(client)
th.AssertNoErr(t, err)

filteredVersions := flavors.FilterVersions(versions, filterOpts)
if filteredVersions[0].Flavors[0].Name != currentFlavor {
newFlavorID = filteredVersions[0].Flavors[0].FlavorID
} else {
newFlavorID = filteredVersions[0].Flavors[1].FlavorID
}

needCheckReplica := false
err = clusters.UpdateClusterFlavor(client, clusterID, clusters.ClusterFlavorOpts{
NeedCheckReplica: &needCheckReplica,
NewFlavorID: newFlavorID,
NodeType: instanceType,
})
th.AssertNoErr(t, err)

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}
27 changes: 27 additions & 0 deletions acceptance/openstack/css/v1/cluster_update_sg_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package v1

import (
"testing"

"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/css/v1/clusters"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

func TestUpdateSecurityGroup(t *testing.T) {
clusterID := clients.EnvOS.GetEnv("CSS_CLUSTER_ID")
if clusterID == "" {
t.Skip("`CSS_CLUSTER_ID` must be defined")
}
sgID := openstack.DefaultSecurityGroup(t)
client, err := clients.NewCssV1Client()
th.AssertNoErr(t, err)

err = clusters.UpdateSecurityGroup(client, clusterID, clusters.SecurityGroupOpts{
SecurityGroupID: sgID,
})
th.AssertNoErr(t, err)

th.AssertNoErr(t, clusters.WaitForCluster(client, clusterID, timeout))
}
Loading
Loading