Skip to content

Commit

Permalink
[Test] less variables, obtain info from cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-sidelnikov committed Nov 28, 2024
1 parent ebba418 commit 395a8f4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions acceptance/openstack/cce/v3/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients"
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/openstack/cce"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/cce/v3/clusters"
"github.com/opentelekomcloud/gophertelekomcloud/openstack/networking/v1/subnets"
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper"
)

Expand All @@ -19,20 +20,27 @@ func TestListCluster(t *testing.T) {

func TestCluster(t *testing.T) {
vpcID := clients.EnvOS.GetEnv("VPC_ID")
subnetID := clients.EnvOS.GetEnv("NETWORK_ID")
eniSubnetID := clients.EnvOS.GetEnv("ENI_SUBNET_ID")
eniCidr := clients.EnvOS.GetEnv("ENI_SUBNET_CIDR")
if vpcID == "" || subnetID == "" || eniSubnetID == "" {
t.Skip("OS_VPC_ID, OS_NETWORK_ID and OS_ENI_SUBNET_ID are required for this test")
if vpcID == "" {
t.Skip("OS_VPC_ID is required for this test")
}
if eniCidr == "" {
eniCidr = "192.168.0.0/24"

clientNet, err := clients.NewNetworkV1Client()
th.AssertNoErr(t, err)

listOpts := subnets.ListOpts{
VpcID: vpcID,
}
subnetsList, err := subnets.List(clientNet, listOpts)
th.AssertNoErr(t, err)

if len(subnetsList) < 1 {
t.Skip("no subnets found in selected VPC")
}

client, err := clients.NewCceV3Client()
th.AssertNoErr(t, err)

cluster := cce.CreateTurboCluster(t, vpcID, subnetID, eniSubnetID, eniCidr)
cluster := cce.CreateTurboCluster(t, vpcID, subnetsList[0].NetworkID, subnetsList[0].SubnetID, subnetsList[0].CIDR)

clusterID := cluster.Metadata.Id

Expand Down

0 comments on commit 395a8f4

Please sign in to comment.