Skip to content

Commit

Permalink
Merge pull request #1127 from Letty5411/0413
Browse files Browse the repository at this point in the history
test: add lxcfs binary check
  • Loading branch information
Ace-Tang authored Apr 17, 2018
2 parents 9ed2a9a + 86ddb2c commit 9fff714
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 9fff714

Please sign in to comment.