-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#11187 from SimonRichardson/openstack-subnets-…
…spaces juju#11187 ### Checklist - [x] Checked if it requires a [pylibjuju](https://github.com/juju/python-libjuju) change? - [x] Added [integration tests](https://github.com/juju/juju/tree/develop/tests) for the PR? - [x] Added or updated [doc.go](https://discourse.jujucharms.com/t/readme-in-packages/451) related to packages changed? - [x] Do comments answer the question of why design decisions were made? ---- ## Description of change The following is a mechanical change to move the ability to find subnet ids from available zones. This is a very generic function, one that can be extracted to core and be tested in isolation. ## QA steps Bootstrapping to aws should be fine. ```sh juju bootstrap aws test --no-gui --debug ```
- Loading branch information
Showing
5 changed files
with
96 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2020 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package network_test | ||
|
||
import ( | ||
"github.com/juju/errors" | ||
"github.com/juju/juju/core/network" | ||
"github.com/juju/testing" | ||
jc "github.com/juju/testing/checkers" | ||
gc "gopkg.in/check.v1" | ||
) | ||
|
||
type subnetSuite struct { | ||
testing.IsolationSuite | ||
} | ||
|
||
var _ = gc.Suite(&subnetSuite{}) | ||
|
||
func (*subnetSuite) TestFindSubnetIDsForAZ(c *gc.C) { | ||
testCases := []struct { | ||
name string | ||
zoneName string | ||
subnetsToZones map[network.Id][]string | ||
expected []string | ||
expectedErr func(error) bool | ||
}{ | ||
{ | ||
name: "empty", | ||
zoneName: "", | ||
subnetsToZones: make(map[network.Id][]string), | ||
expected: make([]string, 0), | ||
expectedErr: errors.IsNotFound, | ||
}, | ||
{ | ||
name: "no match", | ||
zoneName: "fuzz", | ||
subnetsToZones: map[network.Id][]string{ | ||
"bar": {"foo", "baz"}, | ||
}, | ||
expected: make([]string, 0), | ||
expectedErr: errors.IsNotFound, | ||
}, | ||
{ | ||
name: "match", | ||
zoneName: "foo", | ||
subnetsToZones: map[network.Id][]string{ | ||
"bar": {"foo", "baz"}, | ||
}, | ||
expected: []string{"bar"}, | ||
}, | ||
{ | ||
name: "multi-match", | ||
zoneName: "foo", | ||
subnetsToZones: map[network.Id][]string{ | ||
"bar": {"foo", "baz"}, | ||
"other": {"aaa", "foo", "xxx"}, | ||
}, | ||
expected: []string{"bar", "other"}, | ||
}, | ||
} | ||
|
||
for i, t := range testCases { | ||
c.Logf("test %d: %s", i, t.name) | ||
|
||
res, err := network.FindSubnetIDsForAvailabilityZone(t.zoneName, t.subnetsToZones) | ||
if t.expectedErr != nil { | ||
c.Check(t.expectedErr(err), jc.IsTrue) | ||
} else { | ||
c.Assert(err, gc.IsNil) | ||
c.Check(res, gc.DeepEquals, t.expected) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters