mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Make sure sandbox files are removed after tests
- and check for error on sandbox.Destroy() in tests Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
d67a1b3908
commit
b92d253d60
2 changed files with 33 additions and 5 deletions
|
@ -65,7 +65,10 @@ func TestSandboxCreate(t *testing.T) {
|
|||
verifySandbox(t, s, []string{"0", "1", "2"})
|
||||
runtime.LockOSThread()
|
||||
|
||||
s.Destroy()
|
||||
err = s.Destroy()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
verifyCleanup(t, s, true)
|
||||
}
|
||||
|
||||
|
@ -90,7 +93,13 @@ func TestSandboxCreateTwice(t *testing.T) {
|
|||
t.Fatalf("Failed to create a new sandbox: %v", err)
|
||||
}
|
||||
runtime.LockOSThread()
|
||||
s.Destroy()
|
||||
|
||||
err = s.Destroy()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
GC()
|
||||
verifyCleanup(t, s, false)
|
||||
}
|
||||
|
||||
func TestSandboxGC(t *testing.T) {
|
||||
|
@ -104,7 +113,10 @@ func TestSandboxGC(t *testing.T) {
|
|||
t.Fatalf("Failed to create a new sandbox: %v", err)
|
||||
}
|
||||
|
||||
s.Destroy()
|
||||
err = s.Destroy()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
GC()
|
||||
verifyCleanup(t, s, false)
|
||||
|
@ -168,5 +180,11 @@ func TestAddRemoveInterface(t *testing.T) {
|
|||
verifySandbox(t, s, []string{"1", "2", "3"})
|
||||
runtime.LockOSThread()
|
||||
|
||||
s.Destroy()
|
||||
err = s.Destroy()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
GC()
|
||||
verifyCleanup(t, s, false)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package libnetwork
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/libnetwork/sandbox"
|
||||
)
|
||||
|
||||
func createEmptyCtrlr() *controller {
|
||||
return &controller{sandboxes: sandboxTable{}}
|
||||
|
@ -31,6 +35,8 @@ func TestSandboxAddEmpty(t *testing.T) {
|
|||
if len(ctrlr.sandboxes) != 0 {
|
||||
t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
|
||||
}
|
||||
|
||||
sandbox.GC()
|
||||
}
|
||||
|
||||
func TestSandboxAddMultiPrio(t *testing.T) {
|
||||
|
@ -90,6 +96,8 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
|||
if len(ctrlr.sandboxes) != 0 {
|
||||
t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
|
||||
}
|
||||
|
||||
sandbox.GC()
|
||||
}
|
||||
|
||||
func TestSandboxAddSamePrio(t *testing.T) {
|
||||
|
@ -127,4 +135,6 @@ func TestSandboxAddSamePrio(t *testing.T) {
|
|||
if len(ctrlr.sandboxes) != 0 {
|
||||
t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
|
||||
}
|
||||
|
||||
sandbox.GC()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue