-
Notifications
You must be signed in to change notification settings - Fork 285
Adding functions to modify network settings and policies. Adding RemoteSubnetRoutePolicy. #358
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
Changes from all commits
3a3001e
c2d4408
119a079
b19dd74
f18977c
fa0fcc4
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 |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import ( | |
| ) | ||
|
|
||
| func TestCreateDeleteNetwork(t *testing.T) { | ||
| network, err := HcnCreateTestNetwork() | ||
| network, err := HcnCreateTestNATNetwork() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
@@ -25,7 +25,7 @@ func TestCreateDeleteNetwork(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetNetworkByName(t *testing.T) { | ||
| network, err := HcnCreateTestNetwork() | ||
| network, err := HcnCreateTestNATNetwork() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
@@ -43,7 +43,7 @@ func TestGetNetworkByName(t *testing.T) { | |
| } | ||
|
|
||
| func TestGetNetworkById(t *testing.T) { | ||
| network, err := HcnCreateTestNetwork() | ||
| network, err := HcnCreateTestNATNetwork() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
@@ -66,3 +66,61 @@ func TestListNetwork(t *testing.T) { | |
| t.Fatal(err) | ||
| } | ||
| } | ||
|
|
||
| func TestAddRemoveRemoteSubnetRoutePolicy(t *testing.T) { | ||
|
|
||
| network, err := CreateTestOverlayNetwork() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| remoteSubnetRoutePolicy, err := HcnCreateTestRemoteSubnetRoute() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| //Add Policy | ||
| network.AddPolicy(*remoteSubnetRoutePolicy) | ||
|
|
||
| //Reload the network object from HNS. | ||
| network, err = GetNetworkByID(network.Id) | ||
|
Contributor
Author
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. I'm not fond of this pattern. We shouldn't have to reload the network after modifying. After updating the network (or endpoint) the network should be automatically updated. However, this behavior is consistent with the Endpoint API's. 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. I like your proposal. |
||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| foundPolicy := false | ||
| for _, policy := range network.Policies { | ||
| if policy.Type == RemoteSubnetRoute { | ||
| foundPolicy = true | ||
| break | ||
| } | ||
| } | ||
| if !foundPolicy { | ||
| t.Fatalf("Could not find remote subnet route policy on network.") | ||
| } | ||
|
|
||
| //Remove Policy. | ||
| network.RemovePolicy(*remoteSubnetRoutePolicy) | ||
|
|
||
| //Reload the network object from HNS. | ||
| network, err = GetNetworkByID(network.Id) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| foundPolicy = false | ||
| for _, policy := range network.Policies { | ||
| if policy.Type == RemoteSubnetRoute { | ||
| foundPolicy = true | ||
| break | ||
| } | ||
| } | ||
| if foundPolicy { | ||
| t.Fatalf("Found remote subnet route policy on network when it should have been deleted.") | ||
| } | ||
|
|
||
| _, err = network.Delete() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.