Browse code

Cleanup external sandbox from test

- otherwise "ValidKey" file is left behind

Signed-off-by: Alessandro Boch <aboch@docker.com>

Alessandro Boch authored on 2015/09/12 06:34:09
Showing 1 changed files
... ...
@@ -52,7 +52,6 @@ func TestMain(m *testing.M) {
52 52
 
53 53
 	err := controller.ConfigureNetworkDriver(bridgeNetType, genericOption)
54 54
 	if err != nil {
55
-		//m.Fatal(err)
56 55
 		os.Exit(1)
57 56
 	}
58 57
 
... ...
@@ -1243,6 +1242,7 @@ func TestExternalKey(t *testing.T) {
1243 1243
 		if err := cnt.Delete(); err != nil {
1244 1244
 			t.Fatal(err)
1245 1245
 		}
1246
+		osl.GC()
1246 1247
 	}()
1247 1248
 
1248 1249
 	// Join endpoint to sandbox before SetKey
... ...
@@ -1270,8 +1270,14 @@ func TestExternalKey(t *testing.T) {
1270 1270
 	}
1271 1271
 
1272 1272
 	// Create a new OS sandbox using the osl API before using it in SetKey
1273
-	if _, err := osl.NewSandbox("ValidKey", true); err != nil {
1273
+	if extOsBox, err := osl.NewSandbox("ValidKey", true); err != nil {
1274 1274
 		t.Fatalf("Failed to create new osl sandbox")
1275
+	} else {
1276
+		defer func() {
1277
+			if err := extOsBox.Destroy(); err != nil {
1278
+				log.Warnf("Failed to remove os sandbox: %v", err)
1279
+			}
1280
+		}()
1275 1281
 	}
1276 1282
 
1277 1283
 	if err := sbox.SetKey("ValidKey"); err != nil {