2018-02-05 16:05:59 -05:00
|
|
|
package store // import "github.com/docker/docker/volume/store"
|
2015-09-18 19:58:05 -04:00
|
|
|
|
|
|
|
import (
|
2015-10-19 20:41:22 -04:00
|
|
|
"errors"
|
2017-11-15 13:13:22 -05:00
|
|
|
"fmt"
|
2016-12-01 17:17:07 -05:00
|
|
|
"io/ioutil"
|
2017-11-15 13:13:22 -05:00
|
|
|
"net"
|
2016-12-01 17:17:07 -05:00
|
|
|
"os"
|
2015-09-23 16:29:14 -04:00
|
|
|
"strings"
|
2015-09-18 19:58:05 -04:00
|
|
|
"testing"
|
|
|
|
|
2017-09-19 14:34:41 -04:00
|
|
|
"github.com/docker/docker/volume"
|
2018-03-19 17:18:52 -04:00
|
|
|
volumedrivers "github.com/docker/docker/volume/drivers"
|
2016-09-12 03:34:19 -04:00
|
|
|
volumetestutils "github.com/docker/docker/volume/testutils"
|
2017-12-22 16:30:49 -05:00
|
|
|
"github.com/google/go-cmp/cmp"
|
2018-03-13 15:28:34 -04:00
|
|
|
"github.com/gotestyourself/gotestyourself/assert"
|
|
|
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
2015-09-18 19:58:05 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCreate(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
2016-12-01 17:17:07 -05:00
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
v, err := s.Create("fake1", "fake", nil, nil)
|
2015-09-18 19:58:05 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if v.Name() != "fake1" {
|
|
|
|
t.Fatalf("Expected fake1 volume, got %v", v)
|
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
if l, _, _ := s.List(); len(l) != 1 {
|
2015-09-18 19:58:05 -04:00
|
|
|
t.Fatalf("Expected 1 volume in the store, got %v: %v", len(l), l)
|
|
|
|
}
|
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("none", "none", nil, nil); err == nil {
|
2015-09-18 19:58:05 -04:00
|
|
|
t.Fatalf("Expected unknown driver error, got nil")
|
|
|
|
}
|
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
_, err = s.Create("fakeerror", "fake", map[string]string{"error": "create error"}, nil)
|
2015-11-13 15:30:13 -05:00
|
|
|
expected := &OpErr{Op: "create", Name: "fakeerror", Err: errors.New("create error")}
|
2015-10-19 20:41:22 -04:00
|
|
|
if err != nil && err.Error() != expected.Error() {
|
|
|
|
t.Fatalf("Expected create fakeError: create error, got %v", err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemove(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("noop"), "noop")
|
2015-09-23 16:29:14 -04:00
|
|
|
|
|
|
|
// doing string compare here since this error comes directly from the driver
|
|
|
|
expected := "no such volume"
|
2016-09-12 03:34:19 -04:00
|
|
|
if err := s.Remove(volumetestutils.NoopVolume{}); err == nil || !strings.Contains(err.Error(), expected) {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatalf("Expected error %q, got %v", expected, err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
v, err := s.CreateWithRef("fake1", "fake", "fake", nil, nil)
|
2015-09-18 19:58:05 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
|
2015-10-19 20:41:22 -04:00
|
|
|
if err := s.Remove(v); !IsInUse(err) {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatalf("Expected ErrVolumeInUse error, got %v", err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
s.Dereference(v, "fake")
|
2015-09-18 19:58:05 -04:00
|
|
|
if err := s.Remove(v); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
if l, _, _ := s.List(); len(l) != 0 {
|
2015-09-18 19:58:05 -04:00
|
|
|
t.Fatalf("Expected 0 volumes in the store, got %v, %v", len(l), l)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
func TestList(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
|
2016-12-01 17:17:07 -05:00
|
|
|
dir, err := ioutil.TempDir("", "test-list")
|
2018-03-19 17:18:52 -04:00
|
|
|
assert.NilError(t, err)
|
2016-12-01 17:17:07 -05:00
|
|
|
defer os.RemoveAll(dir)
|
2015-09-23 16:29:14 -04:00
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
drivers := volumedrivers.NewStore(nil)
|
|
|
|
drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
|
|
|
drivers.Register(volumetestutils.NewFakeDriver("fake2"), "fake2")
|
|
|
|
|
|
|
|
s, err := New(dir, drivers)
|
|
|
|
assert.NilError(t, err)
|
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("test", "fake", nil, nil); err != nil {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("test2", "fake2", nil, nil); err != nil {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
ls, _, err := s.List()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
if len(ls) != 2 {
|
|
|
|
t.Fatalf("expected 2 volumes, got: %d", len(ls))
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2016-12-01 17:17:07 -05:00
|
|
|
if err := s.Shutdown(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2015-09-18 19:58:05 -04:00
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
// and again with a new store
|
2018-03-19 17:18:52 -04:00
|
|
|
s, err = New(dir, drivers)
|
2016-03-16 17:52:34 -04:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2015-09-23 16:29:14 -04:00
|
|
|
ls, _, err = s.List()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(ls) != 2 {
|
|
|
|
t.Fatalf("expected 2 volumes, got: %d", len(ls))
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
func TestFilterByDriver(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("noop"), "noop")
|
2015-09-18 19:58:05 -04:00
|
|
|
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("fake1", "fake", nil, nil); err != nil {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("fake2", "fake", nil, nil); err != nil {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
2016-03-16 17:52:34 -04:00
|
|
|
if _, err := s.Create("fake3", "noop", nil, nil); err != nil {
|
2015-09-23 16:29:14 -04:00
|
|
|
t.Fatal(err)
|
2015-09-18 19:58:05 -04:00
|
|
|
}
|
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
if l, _ := s.FilterByDriver("fake"); len(l) != 2 {
|
2015-09-18 19:58:05 -04:00
|
|
|
t.Fatalf("Expected 2 volumes, got %v, %v", len(l), l)
|
|
|
|
}
|
|
|
|
|
2015-09-23 16:29:14 -04:00
|
|
|
if l, _ := s.FilterByDriver("noop"); len(l) != 1 {
|
2015-09-18 19:58:05 -04:00
|
|
|
t.Fatalf("Expected 1 volume, got %v, %v", len(l), l)
|
|
|
|
}
|
|
|
|
}
|
2016-01-25 14:39:41 -05:00
|
|
|
|
|
|
|
func TestFilterByUsed(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
2016-01-25 14:39:41 -05:00
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("noop"), "noop")
|
2016-03-16 17:52:34 -04:00
|
|
|
|
|
|
|
if _, err := s.CreateWithRef("fake1", "fake", "volReference", nil, nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if _, err := s.Create("fake2", "fake", nil, nil); err != nil {
|
2016-01-25 14:39:41 -05:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
vols, _, err := s.List()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
dangling := s.FilterByUsed(vols, false)
|
|
|
|
if len(dangling) != 1 {
|
2016-12-01 04:07:38 -05:00
|
|
|
t.Fatalf("expected 1 dangling volume, got %v", len(dangling))
|
2016-01-25 14:39:41 -05:00
|
|
|
}
|
|
|
|
if dangling[0].Name() != "fake2" {
|
2016-12-01 04:07:38 -05:00
|
|
|
t.Fatalf("expected dangling volume fake2, got %s", dangling[0].Name())
|
2016-01-25 14:39:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
used := s.FilterByUsed(vols, true)
|
|
|
|
if len(used) != 1 {
|
|
|
|
t.Fatalf("expected 1 used volume, got %v", len(used))
|
|
|
|
}
|
|
|
|
if used[0].Name() != "fake1" {
|
|
|
|
t.Fatalf("expected used volume fake1, got %s", used[0].Name())
|
|
|
|
}
|
|
|
|
}
|
2016-02-16 21:10:45 -05:00
|
|
|
|
|
|
|
func TestDerefMultipleOfSameRef(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver("fake"), "fake")
|
2016-03-16 17:52:34 -04:00
|
|
|
|
|
|
|
v, err := s.CreateWithRef("fake1", "fake", "volReference", nil, nil)
|
2016-02-16 21:10:45 -05:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := s.GetWithRef("fake1", "fake", "volReference"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
s.Dereference(v, "volReference")
|
|
|
|
if err := s.Remove(v); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
2017-09-19 14:34:41 -04:00
|
|
|
|
|
|
|
func TestCreateKeepOptsLabelsWhenExistsRemotely(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
2017-09-19 14:34:41 -04:00
|
|
|
vd := volumetestutils.NewFakeDriver("fake")
|
2018-03-19 17:18:52 -04:00
|
|
|
s.drivers.Register(vd, "fake")
|
2017-09-19 14:34:41 -04:00
|
|
|
|
|
|
|
// Create a volume in the driver directly
|
|
|
|
if _, err := vd.Create("foo", nil); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
v, err := s.Create("foo", "fake", nil, map[string]string{"hello": "world"})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
switch dv := v.(type) {
|
|
|
|
case volume.DetailedVolume:
|
|
|
|
if dv.Labels()["hello"] != "world" {
|
|
|
|
t.Fatalf("labels don't match")
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
t.Fatalf("got unexpected type: %T", v)
|
|
|
|
}
|
|
|
|
}
|
2017-11-15 13:13:22 -05:00
|
|
|
|
|
|
|
func TestDefererencePluginOnCreateError(t *testing.T) {
|
2018-03-19 17:18:52 -04:00
|
|
|
t.Parallel()
|
|
|
|
|
2017-11-15 13:13:22 -05:00
|
|
|
var (
|
|
|
|
l net.Listener
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
for i := 32768; l == nil && i < 40000; i++ {
|
|
|
|
l, err = net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", i))
|
|
|
|
}
|
|
|
|
if l == nil {
|
|
|
|
t.Fatalf("could not create listener: %v", err)
|
|
|
|
}
|
|
|
|
defer l.Close()
|
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
2017-11-15 13:13:22 -05:00
|
|
|
d := volumetestutils.NewFakeDriver("TestDefererencePluginOnCreateError")
|
|
|
|
p, err := volumetestutils.MakeFakePlugin(d, l)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pg := volumetestutils.NewFakePluginGetter(p)
|
2018-03-19 17:18:52 -04:00
|
|
|
s.drivers = volumedrivers.NewStore(pg)
|
2017-11-15 13:13:22 -05:00
|
|
|
|
|
|
|
// create a good volume so we have a plugin reference
|
|
|
|
_, err = s.Create("fake1", d.Name(), nil, nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now create another one expecting an error
|
|
|
|
_, err = s.Create("fake2", d.Name(), map[string]string{"error": "some error"}, nil)
|
|
|
|
if err == nil || !strings.Contains(err.Error(), "some error") {
|
|
|
|
t.Fatalf("expected an error on create: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// There should be only 1 plugin reference
|
|
|
|
if refs := volumetestutils.FakeRefs(p); refs != 1 {
|
|
|
|
t.Fatalf("expected 1 plugin reference, got: %d", refs)
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
func TestRefDerefRemove(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
driverName := "test-ref-deref-remove"
|
2018-03-19 17:18:52 -04:00
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver(driverName), driverName)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
v, err := s.CreateWithRef("test", driverName, "test-ref", nil, nil)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
err = s.Remove(v)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Assert(t, is.ErrorContains(err, ""))
|
|
|
|
assert.Equal(t, errVolumeInUse, err.(*OpErr).Err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
s.Dereference(v, "test-ref")
|
|
|
|
err = s.Remove(v)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestGet(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
driverName := "test-get"
|
2018-03-19 17:18:52 -04:00
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver(driverName), driverName)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
_, err := s.Get("not-exist")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Assert(t, is.ErrorContains(err, ""))
|
|
|
|
assert.Equal(t, errNoSuchVolume, err.(*OpErr).Err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
v1, err := s.Create("test", driverName, nil, map[string]string{"a": "1"})
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
v2, err := s.Get("test")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2017-12-22 16:30:49 -05:00
|
|
|
assert.DeepEqual(t, v1, v2, cmpVolume)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
dv := v2.(volume.DetailedVolume)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Equal(t, "1", dv.Labels()["a"])
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
err = s.Remove(v1)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetWithRef(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
driverName := "test-get-with-ref"
|
2018-03-19 17:18:52 -04:00
|
|
|
s, cleanup := setupTest(t)
|
|
|
|
defer cleanup()
|
|
|
|
s.drivers.Register(volumetestutils.NewFakeDriver(driverName), driverName)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
_, err := s.GetWithRef("not-exist", driverName, "test-ref")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Assert(t, is.ErrorContains(err, ""))
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
v1, err := s.Create("test", driverName, nil, map[string]string{"a": "1"})
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
v2, err := s.GetWithRef("test", driverName, "test-ref")
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2017-12-22 16:30:49 -05:00
|
|
|
assert.DeepEqual(t, v1, v2, cmpVolume)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
err = s.Remove(v2)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Assert(t, is.ErrorContains(err, ""))
|
|
|
|
assert.Equal(t, errVolumeInUse, err.(*OpErr).Err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
|
|
|
s.Dereference(v2, "test-ref")
|
|
|
|
err = s.Remove(v2)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
}
|
|
|
|
|
2017-12-22 16:30:49 -05:00
|
|
|
var cmpVolume = cmp.AllowUnexported(volumetestutils.FakeVolume{}, volumeWrapper{})
|
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
func setupTest(t *testing.T) (*VolumeStore, func()) {
|
2018-03-13 15:39:23 -04:00
|
|
|
t.Helper()
|
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
dirName := strings.Replace(t.Name(), string(os.PathSeparator), "_", -1)
|
|
|
|
dir, err := ioutil.TempDir("", dirName)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
cleanup := func() {
|
2018-03-13 15:39:23 -04:00
|
|
|
err := os.RemoveAll(dir)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, err)
|
2018-03-13 15:39:23 -04:00
|
|
|
}
|
|
|
|
|
2018-03-19 17:18:52 -04:00
|
|
|
s, err := New(dir, volumedrivers.NewStore(nil))
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, err)
|
2018-03-19 17:18:52 -04:00
|
|
|
return s, func() {
|
2018-03-13 15:39:23 -04:00
|
|
|
s.Shutdown()
|
2018-03-19 17:18:52 -04:00
|
|
|
cleanup()
|
2018-03-13 15:39:23 -04:00
|
|
|
}
|
|
|
|
}
|