Skip to content

Commit

Permalink
GCLOUD2-12605: Updated loadbalancers tests (#99)
Browse files Browse the repository at this point in the history
* Updated loadbalancers tests

* Added ip family type to create opts

* Fix tests
  • Loading branch information
lapson97 authored Dec 21, 2023
1 parent 02b3f9a commit c86cd33
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions client/loadbalancers/v1/loadbalancers/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ var loadBalancerCreateSubCommand = cli.Command{
VipNetworkID: c.String("vip-network-id"),
VipSubnetID: c.String("vip-subnet-id"),
Tags: c.StringSlice("tags"),
VIPIPFamily: types.IPFamilyType(c.String("vip-ip-family")),
}
flavor := c.String("flavor")
if flavor != "" {
Expand Down
39 changes: 34 additions & 5 deletions gcore/loadbalancer/v1/loadbalancers/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package testing

import (
"fmt"
"github.com/G-Core/gcorelabscloud-go/gcore/utils/metadata"
"net"
"time"

"github.com/G-Core/gcorelabscloud-go/gcore/utils/metadata"

gcorecloud "github.com/G-Core/gcorelabscloud-go"
"github.com/G-Core/gcorelabscloud-go/gcore/loadbalancer/v1/loadbalancers"
"github.com/G-Core/gcorelabscloud-go/gcore/loadbalancer/v1/types"
Expand All @@ -14,6 +15,25 @@ import (
fake "github.com/G-Core/gcorelabscloud-go/testhelper/client"
)

const VrrpIPsResponse = `
{
"ip_address": "10.94.79.54",
"subnet_id": "db5ebada-a86a-4702-8a19-00b23a1acb05"
},
{
"ip_address": "aa:bb:cc:dd::1d4",
"subnet_id": "abd99b68-e139-4715-b8c2-37ca324285b8"
},
{
"ip_address": "10.94.76.179",
"subnet_id": "db5ebada-a86a-4702-8a19-00b23a1acb05"
},
{
"ip_address": "aa:bb:cc:dd::2b5",
"subnet_id": "abd99b68-e139-4715-b8c2-37ca324285b8"
}
`

var ListResponse = fmt.Sprintf(`
{
"count": 1,
Expand All @@ -36,11 +56,12 @@ var ListResponse = fmt.Sprintf(`
"operating_status": "ONLINE",
"project_id": 1,
"region_id": 1,
"metadata": [%s]
"metadata": [%s],
"vrrp_ips": [%s]
}
]
}
`, testing.MetadataResponse)
`, testing.MetadataResponse, VrrpIPsResponse)

const ListCustomSecurityGroupResponse = `
{
Expand Down Expand Up @@ -73,14 +94,16 @@ var GetResponse = fmt.Sprintf(`
"operating_status": "ONLINE",
"project_id": 1,
"region_id": 1,
"metadata": [%s]
"metadata": [%s],
"vrrp_ips": [%s]
}
`, testing.MetadataResponse)
`, testing.MetadataResponse, VrrpIPsResponse)

const CreateRequest = `
{
"name": "lbname",
"vip_port_id": "169942e0-9b53-42df-95ef-1a8b6525c2bd",
"vip_ip_family": "dual",
"listeners": [
{
"name": "listener_name",
Expand Down Expand Up @@ -170,6 +193,12 @@ var (
RegionID: fake.RegionID,
Region: "RegionOne",
Metadata: []metadata.Metadata{testing.ResourceMetadataReadOnly},
VrrpIPs: []loadbalancers.NetworkPortFixedIP{
{IpAddress: net.ParseIP("10.94.79.54"), SubnetID: "db5ebada-a86a-4702-8a19-00b23a1acb05"},
{IpAddress: net.ParseIP("aa:bb:cc:dd::1d4"), SubnetID: "abd99b68-e139-4715-b8c2-37ca324285b8"},
{IpAddress: net.ParseIP("10.94.76.179"), SubnetID: "db5ebada-a86a-4702-8a19-00b23a1acb05"},
{IpAddress: net.ParseIP("aa:bb:cc:dd::2b5"), SubnetID: "abd99b68-e139-4715-b8c2-37ca324285b8"},
},
}
Tasks1 = tasks.TaskResults{
Tasks: []tasks.TaskID{"50f53a35-42ed-40c4-82b2-5a37fb3e00bc"},
Expand Down
3 changes: 2 additions & 1 deletion gcore/loadbalancer/v1/loadbalancers/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ func TestCreate(t *testing.T) {
SessionPersistence: nil,
}},
}},
VipPortID: "169942e0-9b53-42df-95ef-1a8b6525c2bd",
VipPortID: "169942e0-9b53-42df-95ef-1a8b6525c2bd",
VIPIPFamily: types.DualStackIPFamilyType,
}

client := fake.ServiceTokenClient("loadbalancers", "v1")
Expand Down
5 changes: 3 additions & 2 deletions gcore/network/v1/availablenetworks/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
gcorecloud "github.com/G-Core/gcorelabscloud-go"
"github.com/G-Core/gcorelabscloud-go/gcore/network/v1/availablenetworks"
"github.com/G-Core/gcorelabscloud-go/gcore/subnet/v1/subnets"
"github.com/G-Core/gcorelabscloud-go/gcore/subnet/v1/subnets/testing"
fake "github.com/G-Core/gcorelabscloud-go/testhelper/client"
)

Expand Down Expand Up @@ -71,8 +72,8 @@ var updatedTimeParsed, _ = time.Parse(gcorecloud.RFC3339Z, updatedTimeString)
var updatedTime = gcorecloud.JSONRFC3339Z{Time: updatedTimeParsed}
var cidr, _ = gcorecloud.ParseCIDRString("192.168.10.0/24")
var taskID = "50f53a35-42ed-40c4-82b2-5a37fb3e00bc"
var availableIps = 241
var totalIps = 243
var availableIps = testing.IPDual("241")
var totalIps = testing.IPDual("243")
var ip = net.ParseIP("10.0.0.13")
var gwip = net.ParseIP("10.0.0.1")
var routeCidr, _ = gcorecloud.ParseCIDRString("10.0.3.0/24")
Expand Down

0 comments on commit c86cd33

Please sign in to comment.