Переглянути джерело

Merge pull request #279 from aboch/smrm

Make sure sandbox files are removed after tests
Jana Radhakrishnan 10 роки тому
батько
коміт
79e87c22ae
2 змінених файлів з 33 додано та 5 видалено
  1. 22 4
      libnetwork/sandbox/sandbox_test.go
  2. 11 1
      libnetwork/sandboxdata_test.go

+ 22 - 4
libnetwork/sandbox/sandbox_test.go

@@ -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)
 }

+ 11 - 1
libnetwork/sandboxdata_test.go

@@ -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()
 }