Skip to content

Commit

Permalink
test: add ci tests for volume plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Li <[email protected]>
  • Loading branch information
shaloulcy committed May 21, 2018
1 parent 1e75a11 commit 7509083
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
17 changes: 16 additions & 1 deletion hack/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions test/api_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions test/api_volume_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 7509083

Please sign in to comment.