mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 09:55:44 +03:00
Respond to comments and fix test
This commit is contained in:
@@ -95,6 +95,7 @@ type Task struct {
|
||||
Artifacts []*TaskArtifact
|
||||
}
|
||||
|
||||
// TaskArtifact is used to download artifacts before running a task.
|
||||
type TaskArtifact struct {
|
||||
GetterSource string
|
||||
GetterOptions map[string]string
|
||||
|
||||
@@ -149,7 +149,7 @@ func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
||||
Cmd: exec.Command(bin, "executor", pluginLogFile),
|
||||
}
|
||||
|
||||
execImpl, pluginClient, err := createExecutor(pluginConfig, d.config.LogOutput, d.config)
|
||||
execIntf, pluginClient, err := createExecutor(pluginConfig, d.config.LogOutput, d.config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ps, err := execImpl.LaunchCmd(&executor.ExecCommand{Cmd: absPath, Args: args}, executorCtx)
|
||||
ps, err := execIntf.LaunchCmd(&executor.ExecCommand{Cmd: absPath, Args: args}, executorCtx)
|
||||
if err != nil {
|
||||
pluginClient.Kill()
|
||||
return nil, fmt.Errorf("error starting process via the plugin: %v", err)
|
||||
@@ -180,7 +180,7 @@ func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
||||
maxKill := d.DriverContext.config.MaxKillTimeout
|
||||
h := &javaHandle{
|
||||
pluginClient: pluginClient,
|
||||
executor: execImpl,
|
||||
executor: execIntf,
|
||||
userPid: ps.Pid,
|
||||
isolationConfig: ps.IsolationConfig,
|
||||
taskDir: taskDir,
|
||||
|
||||
@@ -103,8 +103,7 @@ func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle,
|
||||
vmID := filepath.Base(vmPath)
|
||||
|
||||
// Get the tasks local directory.
|
||||
taskName := d.DriverContext.taskName
|
||||
taskDir, ok := ctx.AllocDir.TaskDirs[taskName]
|
||||
taskDir, ok := ctx.AllocDir.TaskDirs[d.DriverContext.taskName]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Could not find task directory for task: %v", d.DriverContext.taskName)
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
||||
Cmd: exec.Command(bin, "executor", pluginLogFile),
|
||||
}
|
||||
|
||||
execImpl, pluginClient, err := createExecutor(pluginConfig, d.config.LogOutput, d.config)
|
||||
execIntf, pluginClient, err := createExecutor(pluginConfig, d.config.LogOutput, d.config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ps, err := execImpl.LaunchCmd(&executor.ExecCommand{Cmd: absPath, Args: cmdArgs}, executorCtx)
|
||||
ps, err := execIntf.LaunchCmd(&executor.ExecCommand{Cmd: absPath, Args: cmdArgs}, executorCtx)
|
||||
if err != nil {
|
||||
pluginClient.Kill()
|
||||
return nil, fmt.Errorf("error starting process via the plugin: %v", err)
|
||||
@@ -256,7 +256,7 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
||||
maxKill := d.DriverContext.config.MaxKillTimeout
|
||||
h := &rktHandle{
|
||||
pluginClient: pluginClient,
|
||||
executor: execImpl,
|
||||
executor: execIntf,
|
||||
executorPid: ps.Pid,
|
||||
allocDir: ctx.AllocDir,
|
||||
logger: d.logger,
|
||||
|
||||
@@ -315,6 +315,11 @@ func TestParse(t *testing.T) {
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bad-artifact.hcl",
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
13
jobspec/test-fixtures/bad-artifact.hcl
Normal file
13
jobspec/test-fixtures/bad-artifact.hcl
Normal file
@@ -0,0 +1,13 @@
|
||||
job "binstore-storagelocker" {
|
||||
group "binsl" {
|
||||
count = 5
|
||||
task "binstore" {
|
||||
driver = "docker"
|
||||
|
||||
artifact {
|
||||
bad = "bad"
|
||||
}
|
||||
resources {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1677,7 +1677,7 @@ func (t *Task) FindHostAndPortFor(portLabel string) (string, int) {
|
||||
return "", 0
|
||||
}
|
||||
|
||||
// Validate is used to sanity check a task group
|
||||
// Validate is used to sanity check a task
|
||||
func (t *Task) Validate() error {
|
||||
var mErr multierror.Error
|
||||
if t.Name == "" {
|
||||
|
||||
@@ -131,6 +131,11 @@ func testJob() *Job {
|
||||
Env: map[string]string{
|
||||
"FOO": "bar",
|
||||
},
|
||||
Artifacts: []*TaskArtifact{
|
||||
{
|
||||
GetterSource: "http://foo.com",
|
||||
},
|
||||
},
|
||||
Services: []*Service{
|
||||
{
|
||||
Name: "${TASK}-frontend",
|
||||
|
||||
@@ -10,4 +10,4 @@ go build -o $TEMPDIR/nomad || exit 1
|
||||
|
||||
# Run the tests
|
||||
echo "--> Running tests"
|
||||
go list ./... | grep -v '/vendor/' | sudo -E PATH=$TEMPDIR:$PATH xargs -n1 go test -cover -timeout=180s
|
||||
go list ./... | grep -v '/vendor/' | sudo -E PATH=$TEMPDIR:$PATH xargs -n1 go test -cover -timeout=300s
|
||||
|
||||
Reference in New Issue
Block a user