diff --git a/hack/make.sh b/hack/make.sh index f6843ec949..8632af3caf 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -96,6 +96,16 @@ function install_lxcfs fi } +# local-persist is a volume plugin +function install_local_persist +{ + echo "Try installing local-persist" + wget --quiet -O /tmp/local-persist \ + https://github.com/CWSpear/local-persist/releases/download/v1.3.0/local-persist-linux-amd64 + chmod +x /tmp/local-persist + mv /tmp/local-persist /usr/local/bin/ +} + function install_nsenter { echo "Try installing nsenter" @@ -193,7 +203,12 @@ function target $IMAGE \ bash -c "cd test && go test -c -o integration-test" - #start pouch daemon + install_local_persist + + # start local-persist + local-perist > $TMP/volume.log 2 >&1 & + + # start pouch daemon echo "start pouch daemon" if stat /usr/bin/lxcfs ; then pouchd --debug --enable-lxcfs=true \ diff --git a/test/api_system_test.go b/test/api_system_test.go index 28a60fa1a3..3e3de65f97 100644 --- a/test/api_system_test.go +++ b/test/api_system_test.go @@ -53,10 +53,11 @@ func (suite *APISystemSuite) TestInfo(c *check.C) { c.Assert(got.NCPU, check.Equals, int64(runtime.NumCPU())) // Check the volume drivers - c.Assert(len(got.VolumeDrivers), check.Equals, 3) + c.Assert(len(got.VolumeDrivers), check.Equals, 4) c.Assert(got.VolumeDrivers[0], check.Equals, "ceph") c.Assert(got.VolumeDrivers[1], check.Equals, "local") - c.Assert(got.VolumeDrivers[2], check.Equals, "tmpfs") + c.Assert(got.VolumeDrivers[2], check.Equals, "local-persist") + c.Assert(got.VolumeDrivers[3], check.Equals, "tmpfs") } // TestVersion tests /version API. diff --git a/test/api_volume_create_test.go b/test/api_volume_create_test.go index e251772479..0a6db4259b 100644 --- a/test/api_volume_create_test.go +++ b/test/api_volume_create_test.go @@ -39,3 +39,25 @@ func (suite *APIVolumeCreateSuite) TestVolumeCreateOk(c *check.C) { c.Assert(err, check.IsNil) CheckRespStatus(c, resp, 204) } + +// TestPluginVolumeCreateOk tests creating a volume which created by volume plugin +func (suite *APIVolumeCreateSuite) TestPluginVolumeCreateOk(c *check.C) { + vol := "TestPluginVolumeCreateOk" + + obj := map[string]interface{}{ + "Driver": "local-persist", + "Name": vol, + "DriverOpts": map[string]string{"mountpoint": "/data/images"}, + } + + path := "/volumes/create" + body := request.WithJSONBody(obj) + resp, err := request.Post(path, body) + c.Assert(err, check.IsNil) + CheckRespStatus(c, resp, 201) + + path = "/volumes/" + vol + resp, err = request.Delete(path) + c.Assert(err, check.IsNil) + CheckRespStatus(c, resp, 204) +}