Skip to content

Commit

Permalink
fix acceptance test using specific subnet cidr
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Lamarche authored and EmilienM committed Jan 16, 2024
1 parent 4bf78c0 commit 9a96aa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ func TestLoadbalancersCRUD(t *testing.T) {
th.AssertNoErr(t, err)
defer networking.DeleteNetwork(t, netClient, network.ID)

subnet, err := networking.CreateSubnet(t, netClient, network.ID)
subnet, err := networking.CreateSubnetWithCIDR(t, netClient, network.ID, "192.168.1.0/24", "192.168.1.1")
th.AssertNoErr(t, err)
defer networking.DeleteSubnet(t, netClient, subnet.ID)

additionalSubnet, err := networking.CreateSubnet(t, netClient, network.ID)
additionalSubnet, err := networking.CreateSubnetWithCIDR(t, netClient, network.ID, "192.168.2.0/24", "192.168.2.1")
th.AssertNoErr(t, err)
defer networking.DeleteSubnet(t, netClient, additionalSubnet.ID)

Expand Down
10 changes: 8 additions & 2 deletions internal/acceptance/openstack/networking/v2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,17 @@ func CreatePortWithMultipleFixedIPs(t *testing.T, client *gophercloud.ServiceCli
// CreateSubnet will create a subnet on the specified Network ID. An error
// will be returned if the subnet could not be created.
func CreateSubnet(t *testing.T, client *gophercloud.ServiceClient, networkID string) (*subnets.Subnet, error) {
subnetName := tools.RandomString("TESTACC-", 8)
subnetDescription := tools.RandomString("TESTACC-DESC-", 8)
subnetOctet := tools.RandomInt(1, 250)
subnetCIDR := fmt.Sprintf("192.168.%d.0/24", subnetOctet)
subnetGateway := fmt.Sprintf("192.168.%d.1", subnetOctet)
return CreateSubnetWithCIDR(t, client, networkID, subnetCIDR, subnetGateway)
}

// CreateSubnetWithCIDR will create a subnet on the specified Network ID and CIDR. An error
// will be returned if the subnet could not be created.
func CreateSubnetWithCIDR(t *testing.T, client *gophercloud.ServiceClient, networkID, subnetCIDR, subnetGateway string) (*subnets.Subnet, error) {
subnetName := tools.RandomString("TESTACC-", 8)
subnetDescription := tools.RandomString("TESTACC-DESC-", 8)
createOpts := subnets.CreateOpts{
NetworkID: networkID,
CIDR: subnetCIDR,
Expand Down

0 comments on commit 9a96aa5

Please sign in to comment.