From 4104c0d0e5ca3bd891c9e7ae48dd27ea6cea79a5 Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Fri, 11 Sep 2015 14:34:09 -0700 Subject: [PATCH] Cleanup external sandbox from test - otherwise "ValidKey" file is left behind Signed-off-by: Alessandro Boch --- libnetwork/libnetwork_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnetwork/libnetwork_test.go b/libnetwork/libnetwork_test.go index 8366761cca..25ec8f889e 100644 --- a/libnetwork/libnetwork_test.go +++ b/libnetwork/libnetwork_test.go @@ -52,7 +52,6 @@ func TestMain(m *testing.M) { err := controller.ConfigureNetworkDriver(bridgeNetType, genericOption) if err != nil { - //m.Fatal(err) os.Exit(1) } @@ -1243,6 +1242,7 @@ func TestExternalKey(t *testing.T) { if err := cnt.Delete(); err != nil { t.Fatal(err) } + osl.GC() }() // 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 - 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") + } 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 {