Skip to content

Commit 011fb3f

Browse files
committed
Replaces test added to the noNeutronSuite, with an new test in the localServerSuite that clears the test networks in the arrange phase.
1 parent 3dea35f commit 011fb3f

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

provider/openstack/local_test.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"gopkg.in/goose.v2/nova"
3333
"gopkg.in/goose.v2/testservices/hook"
3434
"gopkg.in/goose.v2/testservices/identityservice"
35+
"gopkg.in/goose.v2/testservices/neutronmodel"
3536
"gopkg.in/goose.v2/testservices/neutronservice"
3637
"gopkg.in/goose.v2/testservices/novaservice"
3738
"gopkg.in/goose.v2/testservices/openstackservice"
@@ -580,6 +581,27 @@ func (s *localServerSuite) TestStartInstanceNetworkNotSetReturnsError(c *gc.C) {
580581
or supply it via --config when creating a new model`)
581582
}
582583

584+
func (s *localServerSuite) TestStartInstanceNoNetworksNetworkNotSetNoError(c *gc.C) {
585+
// Modify the server that is created by default, to clear the networks.
586+
model := neutronmodel.New()
587+
for _, net := range model.AllNetworks() {
588+
model.RemoveNetwork(net.Id)
589+
}
590+
s.srv.Openstack.Neutron.AddNeutronModel(model)
591+
s.srv.Openstack.Nova.AddNeutronModel(model)
592+
593+
cfg, err := s.env.Config().Apply(coretesting.Attrs{
594+
"network": "",
595+
})
596+
c.Assert(err, jc.ErrorIsNil)
597+
err = s.env.SetConfig(cfg)
598+
c.Assert(err, jc.ErrorIsNil)
599+
600+
inst, _, _, err := testing.StartInstance(s.env, s.callCtx, s.ControllerUUID, "100")
601+
c.Check(inst, gc.NotNil)
602+
c.Assert(err, jc.ErrorIsNil)
603+
}
604+
583605
func (s *localServerSuite) TestStartInstanceNetworksDifferentAZ(c *gc.C) {
584606
// If both the network and external-network config values are
585607
// specified, there is not check for them being on different
@@ -2680,22 +2702,6 @@ func (s *noNeutronSuite) TestUpdateGroupControllerNoNeutron(c *gc.C) {
26802702
))
26812703
}
26822704

2683-
func (s *noNeutronSuite) TestStartInstanceNetworkNotSetNoError(c *gc.C) {
2684-
cfg, err := s.env.Config().Apply(coretesting.Attrs{
2685-
"network": "",
2686-
})
2687-
c.Assert(err, jc.ErrorIsNil)
2688-
err = s.env.SetConfig(cfg)
2689-
c.Assert(err, jc.ErrorIsNil)
2690-
2691-
callCtx := context.NewCloudCallContext()
2692-
ctrlUUID := coretesting.FakeControllerConfig().ControllerUUID()
2693-
2694-
inst, _, _, err := testing.StartInstance(s.env, callCtx, ctrlUUID, "100")
2695-
c.Assert(err, jc.ErrorIsNil)
2696-
c.Check(inst, gc.NotNil)
2697-
}
2698-
26992705
func createNovaSecurityGroup(c *gc.C, client *nova.Client, name string) {
27002706
c.Logf("creating group %q", name)
27012707
_, err := client.CreateSecurityGroup(name, "")

0 commit comments

Comments
 (0)