libnetwork_test: stop controllers at end of test

There are a handful of tests which neglected to stop all controllers
they created.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2022-11-08 17:49:52 -05:00
parent 010077ba0f
commit a0f9caec99
3 changed files with 6 additions and 1 deletions

View file

@ -33,6 +33,7 @@ func getTestEnv(t *testing.T, opts ...[]NetworkOption) (NetworkController, []Net
if err != nil {
t.Fatal(err)
}
t.Cleanup(c.Stop)
if len(opts) == 0 {
return c, nil

View file

@ -25,6 +25,7 @@ func TestNoPersist(t *testing.T) {
if err != nil {
t.Fatalf("Error new controller: %v", err)
}
defer ctrl.Stop()
nw, err := ctrl.NewNetwork("host", "host", "", NetworkOptionPersist(false))
if err != nil {
t.Fatalf("Error creating default \"host\" network: %v", err)

View file

@ -27,6 +27,7 @@ func testLocalBackend(t *testing.T, provider, url string, storeConfig *store.Con
if err != nil {
t.Fatalf("Error new controller: %v", err)
}
defer ctrl.Stop()
nw, err := ctrl.NewNetwork("host", "host", "")
if err != nil {
t.Fatalf("Error creating default \"host\" network: %v", err)
@ -49,6 +50,7 @@ func testLocalBackend(t *testing.T, provider, url string, storeConfig *store.Con
if err != nil {
t.Fatalf("Error creating controller: %v", err)
}
defer ctrl.Stop()
if _, err = ctrl.NetworkByID(nw.ID()); err != nil {
t.Fatalf("Error getting network %v", err)
}
@ -82,8 +84,9 @@ func TestMultipleControllersWithSameStore(t *testing.T) {
}
defer ctrl1.Stop()
// Use the same boltdb file without closing the previous controller
_, err = New(cfgOptions...)
ctrl2, err := New(cfgOptions...)
if err != nil {
t.Fatalf("Local store must support concurrent controllers")
}
ctrl2.Stop()
}