-
Notifications
You must be signed in to change notification settings - Fork 11
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
[API Update & Refactor] ELB #522
base: devel
Are you sure you want to change the base?
Changes from all commits
abe705b
0d151a8
0e367a6
eb224cd
38eb831
40727de
5648490
a321d88
28858f5
1039d1e
4eef813
092f723
db36ee3
610639a
64a7228
d72fa6c
45851b8
29422be
049227a
1be0427
34183ac
c269d2f
e74fce4
ca4da36
389019d
c098263
080b8d3
c657385
b23f2e8
2e23795
748441c
9afec52
496a804
b21b7d2
1d5425e
111c190
712f304
74f9f8e
6cd075e
676e073
ec30638
9fd6f83
fe32c36
055f3da
2a8dad0
12c50ba
837aa13
8c155ac
13f337c
7839e32
c3048ae
1f0a4c1
d298f71
997986b
8ba0e6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ func TestIpGroupList(t *testing.T) { | |
client, err := clients.NewElbV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
listOpts := ipgroups.ListOpts{} | ||
ipgroupsList, err := ipgroups.List(client, listOpts) | ||
ipgroupsLists, err := ipgroups.List(client, ipgroups.ListOpts{}).AllPages() | ||
th.AssertNoErr(t, err) | ||
ipgroupsList, err := ipgroups.ExtractIpGroups(ipgroupsLists) | ||
th.AssertNoErr(t, err) | ||
|
||
for _, gr := range ipgroupsList { | ||
|
@@ -29,20 +30,19 @@ func TestIpGroupsLifecycle(t *testing.T) { | |
th.AssertNoErr(t, err) | ||
|
||
loadbalancerID := createLoadBalancer(t, client) | ||
defer deleteLoadbalancer(t, client, loadbalancerID) | ||
t.Cleanup(func() { | ||
deleteLoadbalancer(t, client, loadbalancerID) | ||
}) | ||
|
||
ipGroupOpts := ipgroups.IpGroupOption{ | ||
Ip: "192.168.10.10", | ||
Description: "first", | ||
} | ||
ipGroupName := tools.RandomString("create-ip-group-", 3) | ||
createOpts := ipgroups.CreateOpts{ | ||
Description: "some interesting description", | ||
Name: ipGroupName, | ||
IpList: []ipgroups.IpGroupOption{ipGroupOpts}, | ||
} | ||
t.Logf("Attempting to create ELBv3 IpGroup") | ||
ipGroup, err := ipgroups.Create(client, createOpts) | ||
ipGroup, err := ipgroups.Create(client, ipgroups.CreateOpts{ | ||
Description: "some interesting description", | ||
Name: tools.RandomString("create-ip-group-", 3), | ||
IpList: []ipgroups.IpGroupOption{ipgroups.IpGroupOption{ | ||
Ip: "192.168.10.10", | ||
Description: "first", | ||
}}, | ||
}) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Cleanup(func() { | ||
|
@@ -52,9 +52,8 @@ func TestIpGroupsLifecycle(t *testing.T) { | |
}) | ||
|
||
t.Logf("Attempting to update ELBv3 IpGroup: %s", ipGroup.ID) | ||
ipGroupNameUpdate := tools.RandomString("update-ip-group-", 3) | ||
updateOpts := ipgroups.UpdateOpts{ | ||
Name: ipGroupNameUpdate, | ||
_, err = ipgroups.Update(client, ipGroup.ID, ipgroups.UpdateOpts{ | ||
Name: tools.RandomString("update-ip-group-", 3), | ||
IpList: []ipgroups.IpGroupOption{ | ||
{ | ||
Ip: "192.168.10.12", | ||
|
@@ -65,34 +64,37 @@ func TestIpGroupsLifecycle(t *testing.T) { | |
Description: "fourth", | ||
}, | ||
}, | ||
} | ||
err = ipgroups.Update(client, ipGroup.ID, updateOpts) | ||
}) | ||
th.AssertNoErr(t, err) | ||
t.Logf("Updated ELBv3 ipGroup: %s", ipGroup.ID) | ||
|
||
updatedIpGroup, err := ipgroups.Get(client, ipGroup.ID) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, ipGroupNameUpdate, updatedIpGroup.Name) | ||
th.AssertEquals(t, tools.RandomString("update-ip-group-", 3), updatedIpGroup.Name) | ||
|
||
listOpts := ipgroups.ListOpts{} | ||
ipGroupsSlice, err := ipgroups.List(client, listOpts) | ||
ipGroupsSlices, err := ipgroups.List(client, ipgroups.ListOpts{}).AllPages() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract and paging should be inside list func There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you change that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
th.AssertNoErr(t, err) | ||
ipGroupsSlice, err := ipgroups.ExtractIpGroups(ipGroupsSlices) | ||
th.AssertNoErr(t, err) | ||
|
||
th.AssertEquals(t, 1, len(ipGroupsSlice)) | ||
th.AssertDeepEquals(t, *updatedIpGroup, ipGroupsSlice[0]) | ||
|
||
t.Logf("Attempting to create ELBv3 Listener with ipGroup association") | ||
listener, err := listeners.Create(client, listeners.CreateOpts{ | ||
LoadbalancerID: loadbalancerID, | ||
Protocol: listeners.ProtocolHTTP, | ||
Protocol: "HTTP", | ||
ProtocolPort: 80, | ||
EnhanceL7policy: pointerto.Bool(true), | ||
IpGroup: &listeners.IpGroup{ | ||
IpGroupID: ipGroup.ID, | ||
Enable: pointerto.Bool(true), | ||
}, | ||
}).Extract() | ||
}) | ||
th.AssertNoErr(t, err) | ||
defer deleteListener(t, client, listener.ID) | ||
t.Cleanup(func() { | ||
deleteListener(t, client, listener.ID) | ||
}) | ||
|
||
updatedIpList, err := ipgroups.UpdateIpList(client, ipGroup.ID, ipgroups.UpdateOpts{ | ||
IpList: []ipgroups.IpGroupOption{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ func TestLoadBalancerList(t *testing.T) { | |
loadbalancerPages, err := loadbalancers.List(client, listOpts).AllPages() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract and paging should be inside list func again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently no. have to change how the Page struct works. |
||
th.AssertNoErr(t, err) | ||
|
||
loadbalancerList, err := loadbalancers.ExtractLoadbalancers(loadbalancerPages) | ||
loadbalancerList, err := loadbalancers.ExtractLoadBalancers(loadbalancerPages) | ||
th.AssertNoErr(t, err) | ||
|
||
for _, lb := range loadbalancerList { | ||
|
@@ -31,35 +31,37 @@ func TestLoadBalancerLifecycle(t *testing.T) { | |
th.AssertNoErr(t, err) | ||
|
||
loadbalancerID := createLoadBalancer(t, client) | ||
defer deleteLoadbalancer(t, client, loadbalancerID) | ||
t.Cleanup(func() { | ||
deleteLoadbalancer(t, client, loadbalancerID) | ||
}) | ||
|
||
t.Logf("Attempting to update ELBv3 LoadBalancer: %s", loadbalancerID) | ||
lbName := tools.RandomString("update-lb-", 3) | ||
emptyDescription := "" | ||
updateOptsDpE := loadbalancers.UpdateOpts{ | ||
Name: lbName, | ||
Description: &emptyDescription, | ||
Description: emptyDescription, | ||
DeletionProtectionEnable: pointerto.Bool(true), | ||
} | ||
_, err = loadbalancers.Update(client, loadbalancerID, updateOptsDpE).Extract() | ||
_, err = loadbalancers.Update(client, loadbalancerID, updateOptsDpE) | ||
th.AssertNoErr(t, err) | ||
t.Logf("Updated ELBv3 LoadBalancer: %s", loadbalancerID) | ||
|
||
err = loadbalancers.Delete(client, loadbalancerID).ExtractErr() | ||
err = loadbalancers.Delete(client, loadbalancerID) | ||
if err != nil { | ||
t.Logf("Cannot delete, Deletion Protection enabled for ELBv3 LoadBalancer: %s", loadbalancerID) | ||
} | ||
|
||
updateOptsDpD := loadbalancers.UpdateOpts{ | ||
Name: lbName, | ||
Description: &emptyDescription, | ||
Description: emptyDescription, | ||
DeletionProtectionEnable: pointerto.Bool(false), | ||
} | ||
_, err = loadbalancers.Update(client, loadbalancerID, updateOptsDpD).Extract() | ||
_, err = loadbalancers.Update(client, loadbalancerID, updateOptsDpD) | ||
th.AssertNoErr(t, err) | ||
t.Logf("Updated ELBv3 LoadBalancer: %s", loadbalancerID) | ||
|
||
newLoadbalancer, err := loadbalancers.Get(client, loadbalancerID).Extract() | ||
newLoadbalancer, err := loadbalancers.Get(client, loadbalancerID) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, updateOptsDpD.Name, newLoadbalancer.Name) | ||
th.AssertEquals(t, emptyDescription, newLoadbalancer.Description) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why extract here? Previously it works without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All List API returned with pageinfo should warp with Page
https://docs.otc.t-systems.com/elastic-load-balancing/api-ref/apis_v3/ip_address_group/querying_ip_address_groups.html#:~:text=is%20automatically%20generated.-,page_info,-PageInfo%20object