Skip to content

Commit

Permalink
Ensure we pass network origin in the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRichardson committed Apr 23, 2020
1 parent 8544e6f commit 3772e9c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions container/lxd/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,14 @@ func (s *networkSuite) TestInterfaceInfoFromDevices(c *gc.C) {
MACAddress: "00:16:3e:00:00:3e",
ConfigType: corenetwork.ConfigDHCP,
ParentInterfaceName: "br1",
Origin: corenetwork.OriginProvider,
},
{
InterfaceName: "eth0",
MACAddress: "00:16:3e:00:00:00",
ConfigType: corenetwork.ConfigDHCP,
ParentInterfaceName: network.DefaultLXDBridge,
Origin: corenetwork.OriginProvider,
},
}
c.Check(info, jc.DeepEquals, exp)
Expand Down
13 changes: 13 additions & 0 deletions provider/maas/interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 0,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -456,6 +457,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -477,6 +479,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("admin", "10.50.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 2,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -498,6 +501,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("public", "10.100.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 3,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -520,6 +524,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: newAddressOnSpaceWithId("storage", "3", "10.250.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 4,
MACAddress: "52:54:00:08:24:2d",
Expand All @@ -539,6 +544,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSServers: nil,
DNSSearchDomains: nil,
MTU: 0,
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 5,
MACAddress: "52:54:00:08:24:2d",
Expand All @@ -561,6 +567,7 @@ var exampleParsedInterfaceSetJSON = []corenetwork.InterfaceInfo{{
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: newAddressOnSpaceWithId("space-0", "4", "192.168.20.2"),
Origin: corenetwork.OriginProvider,
}}

func (s *interfacesSuite) TestParseInterfacesNoJSON(c *gc.C) {
Expand Down Expand Up @@ -954,6 +961,7 @@ func (s *interfacesSuite) TestMAAS2NetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 0,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -974,6 +982,7 @@ func (s *interfacesSuite) TestMAAS2NetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -995,6 +1004,7 @@ func (s *interfacesSuite) TestMAAS2NetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("admin", "10.50.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 2,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -1016,6 +1026,7 @@ func (s *interfacesSuite) TestMAAS2NetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("public", "10.100.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 3,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -1038,6 +1049,7 @@ func (s *interfacesSuite) TestMAAS2NetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: newAddressOnSpaceWithId("storage", "3", "10.250.19.2"),
Origin: corenetwork.OriginProvider,
}}
machine := &fakeMachine{interfaceSet: exampleInterfaces}
instance := &maas2Instance{machine: machine}
Expand Down Expand Up @@ -1104,6 +1116,7 @@ func (s *interfacesSuite) TestMAAS2InterfacesNilVLAN(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}}

infos, err := maas2NetworkInterfaces(s.callCtx, instance, map[string]corenetwork.Id{})
Expand Down
15 changes: 13 additions & 2 deletions provider/maas/maas2_environ_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ func (suite *maas2EnvironSuite) TestStartInstanceNetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 0,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -1022,6 +1023,7 @@ func (suite *maas2EnvironSuite) TestStartInstanceNetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("default", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "52:54:00:70:9b:fe",
Expand All @@ -1043,8 +1045,8 @@ func (suite *maas2EnvironSuite) TestStartInstanceNetworkInterfaces(c *gc.C) {
DNSSearchDomains: nil,
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("admin", "10.50.19.2"),
},
}
Origin: corenetwork.OriginProvider,
}}
c.Assert(result.NetworkInfo, jc.DeepEquals, expected)
}

Expand Down Expand Up @@ -1178,6 +1180,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesSingleNic(c *gc.C)
GatewayIP: "192.168.1.1",
Metric: 100,
}},
Origin: corenetwork.OriginProvider,
}}
c.Assert(result, jc.DeepEquals, expected)
}
Expand Down Expand Up @@ -1303,6 +1306,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesNoStaticRoutesAPI(
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("freckles", "10.20.19.2"),
Routes: []corenetwork.Route{},
Origin: corenetwork.OriginProvider,
}}
c.Assert(result, jc.DeepEquals, expected)
}
Expand Down Expand Up @@ -1542,6 +1546,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesDualNic(c *gc.C) {
DNSServers: corenetwork.NewProviderAddressesInSpace("freckles", "10.20.19.2", "10.20.19.3"),
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("freckles", "10.20.19.2"),
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "52:54:00:70:9b:f4",
Expand All @@ -1562,6 +1567,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesDualNic(c *gc.C) {
GatewayIP: "192.168.1.1",
Metric: 100,
}},
Origin: corenetwork.OriginProvider,
}}
ignored := names.NewMachineTag("1/lxd/0")
result, err := env.AllocateContainerAddresses(suite.callCtx, instance.Id("1"), ignored, prepared)
Expand Down Expand Up @@ -1767,6 +1773,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesSubnetMissing(c *g
NoAutoStart: false,
ConfigType: "manual",
MTU: 1500,
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "53:54:00:70:9b:f1",
Expand All @@ -1779,6 +1786,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerAddressesSubnetMissing(c *g
NoAutoStart: false,
ConfigType: "manual",
MTU: 1500,
Origin: corenetwork.OriginProvider,
}})
}

Expand Down Expand Up @@ -1999,6 +2007,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerReuseExistingDevice(c *gc.C
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("space-1", "10.20.19.2"),
Routes: []corenetwork.Route{},
Origin: corenetwork.OriginProvider,
}}
c.Assert(result, jc.DeepEquals, expected)
}
Expand Down Expand Up @@ -2198,6 +2207,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerRefusesReuseInvalidNIC(c *g
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("freckles", "10.20.19.2"),
Routes: []corenetwork.Route{},
Origin: corenetwork.OriginProvider,
}, {
DeviceIndex: 1,
MACAddress: "53:54:00:70:88:bb",
Expand All @@ -2215,6 +2225,7 @@ func (suite *maas2EnvironSuite) TestAllocateContainerRefusesReuseInvalidNIC(c *g
MTU: 1500,
GatewayAddress: corenetwork.NewProviderAddressInSpace("freckles", "192.168.1.1"),
Routes: []corenetwork.Route{},
Origin: corenetwork.OriginProvider,
}}
c.Assert(result, jc.DeepEquals, expected)
}
Expand Down
1 change: 1 addition & 0 deletions provider/openstack/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ func (s *providerUnitTests) TestNetworksForInstanceWithAZ(c *gc.C) {
MACAddress: "mac-address",
Addresses: corenetwork.NewProviderAddresses("10.10.10.1"),
ConfigType: corenetwork.ConfigDHCP,
Origin: corenetwork.OriginProvider,
}}).Return(nil)

siParams := environs.StartInstanceParams{
Expand Down

0 comments on commit 3772e9c

Please sign in to comment.