-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding CSS security mode, security group and flavor update functions * Adding CSS ClusterScaleIn func * add changeclustername, changepassword, restartcluster implementation and test code * Adding CSS AddClusterNodes func * adding small fixes to CSS tests and functions * Adding adjustments for CSS cluster_update_flavor function to use flavor name * Optimized css cluster functions and tests * Updated CSS AddClusterNodes function * Adding modifications based on feedback * added wait in TestRestartClusterWorkflow * Improvements based on suggestion from Muneeb --------- Co-authored-by: Vineet Pruthi <[email protected]> Co-authored-by: gerzson <[email protected]> Co-authored-by: Vineet Pruthi <[email protected]> Co-authored-by: anton-sidelnikov <[email protected]>
- Loading branch information
1 parent
94247b8
commit 45892d8
Showing
17 changed files
with
773 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,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) | ||
} |
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,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) | ||
} |
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,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)) | ||
} |
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,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
113
acceptance/openstack/css/v1/cluster_update_flavor_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,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)) | ||
} |
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,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)) | ||
} |
Oops, something went wrong.