瀏覽代碼

Cleanup external sandbox from test

- otherwise "ValidKey" file is left behind

Signed-off-by: Alessandro Boch <aboch@docker.com>
Alessandro Boch 9 年之前
父節點
當前提交
4104c0d0e5
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      libnetwork/libnetwork_test.go

+ 8 - 2
libnetwork/libnetwork_test.go

@@ -52,7 +52,6 @@ func TestMain(m *testing.M) {
 
 
 	err := controller.ConfigureNetworkDriver(bridgeNetType, genericOption)
 	err := controller.ConfigureNetworkDriver(bridgeNetType, genericOption)
 	if err != nil {
 	if err != nil {
-		//m.Fatal(err)
 		os.Exit(1)
 		os.Exit(1)
 	}
 	}
 
 
@@ -1243,6 +1242,7 @@ func TestExternalKey(t *testing.T) {
 		if err := cnt.Delete(); err != nil {
 		if err := cnt.Delete(); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
+		osl.GC()
 	}()
 	}()
 
 
 	// Join endpoint to sandbox before SetKey
 	// Join endpoint to sandbox before SetKey
@@ -1270,8 +1270,14 @@ func TestExternalKey(t *testing.T) {
 	}
 	}
 
 
 	// Create a new OS sandbox using the osl API before using it in SetKey
 	// Create a new OS sandbox using the osl API before using it in SetKey
-	if _, err := osl.NewSandbox("ValidKey", true); err != nil {
+	if extOsBox, err := osl.NewSandbox("ValidKey", true); err != nil {
 		t.Fatalf("Failed to create new osl sandbox")
 		t.Fatalf("Failed to create new osl sandbox")
+	} else {
+		defer func() {
+			if err := extOsBox.Destroy(); err != nil {
+				log.Warnf("Failed to remove os sandbox: %v", err)
+			}
+		}()
 	}
 	}
 
 
 	if err := sbox.SetKey("ValidKey"); err != nil {
 	if err := sbox.SetKey("ValidKey"); err != nil {