mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 19:35:41 +03:00
Added a test for the exec script check
This commit is contained in:
@@ -10,7 +10,7 @@ func (e *ExecScriptCheck) setChroot(cmd *exec.Cmd) {
|
||||
if cmd.SysProcAttr == nil {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||
}
|
||||
cmd.SysProcAttr.Chroot = e.taskDir
|
||||
}
|
||||
cmd.SysProcAttr.Chroot = e.taskDir
|
||||
cmd.Dir = "/"
|
||||
}
|
||||
|
||||
30
client/driver/executor/checks_test.go
Normal file
30
client/driver/executor/checks_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExecScriptCheckNoIsolation(t *testing.T) {
|
||||
check := &ExecScriptCheck{
|
||||
id: "foo",
|
||||
cmd: "/bin/echo",
|
||||
args: []string{"hello", "world"},
|
||||
taskDir: "/tmp",
|
||||
FSIsolation: false,
|
||||
}
|
||||
|
||||
res := check.Run()
|
||||
expectedOutput := "hello world"
|
||||
expectedExitCode := 0
|
||||
if res.Err != nil {
|
||||
t.Fatalf("err: %v", res.Err)
|
||||
}
|
||||
if strings.TrimSpace(res.Output) != expectedOutput {
|
||||
t.Fatalf("output expected: %v, actual: %v", expectedOutput, res.Output)
|
||||
}
|
||||
|
||||
if res.ExitCode != expectedExitCode {
|
||||
t.Fatalf("exitcode expected: %v, actual: %v", expectedExitCode, res.ExitCode)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user