Skip to content

Commit

Permalink
test: add lxcfs binary check
Browse files Browse the repository at this point in the history
Signed-off-by: letty <[email protected]>
  • Loading branch information
Letty5411 committed Apr 17, 2018
1 parent c37e2d2 commit 86ddb2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ func (suite *PouchRunSuite) TestRunInWrongWay(c *check.C) {

// TestRunEnableLxcfs is to verify run container with lxcfs.
func (suite *PouchRunSuite) TestRunEnableLxcfs(c *check.C) {
// TODO: also check if the pouchd started with lxcfs option
SkipIfFalse(c, environment.IsLxcfsEnabled)
name := "test-run-lxcfs"

command.PouchRun("run", "-d", "--name", name, "-m", "512M", "--enableLxcfs=true",
Expand Down
15 changes: 15 additions & 0 deletions test/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,18 @@ func IsGrpquota() bool {
return IsDiskQuota() &&
(icmd.RunCommand("mount", "|grep grpquota").ExitCode == 0)
}

// IsLxcfsEnabled checks if the lxcfs is installed and service is enabled.
func IsLxcfsEnabled() bool {
if icmd.RunCommand("which", "lxcfs").ExitCode != 0 {
return false
}
if icmd.RunCommand("pgrep", "lxcfs").ExitCode != 0 {
return false
}
cmd := "ps -ef |grep pouchd |grep \"enable\\-lxcfs\""
if icmd.RunCommand("sh", "-c", cmd).ExitCode != 0 {
return false
}
return true
}

0 comments on commit 86ddb2c

Please sign in to comment.