executor: fix tests
This commit is contained in:
parent
913efed9f5
commit
19a695308f
|
@ -303,7 +303,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
|||
Env: cfg.EnvList(),
|
||||
User: cfg.User,
|
||||
ResourceLimits: true,
|
||||
Resources: toExecResources(cfg.Resources),
|
||||
Resources: cfg.Resources,
|
||||
TaskDir: cfg.TaskDir().Dir,
|
||||
StdoutPath: cfg.StdoutPath,
|
||||
StderrPath: cfg.StderrPath,
|
||||
|
@ -344,19 +344,6 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
|||
return handle, nil, nil
|
||||
}
|
||||
|
||||
func toExecResources(resources *drivers.Resources) *executor.Resources {
|
||||
if resources == nil || resources.NomadResources == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &executor.Resources{
|
||||
CPU: resources.NomadResources.CPU,
|
||||
MemoryMB: resources.NomadResources.MemoryMB,
|
||||
DiskMB: resources.NomadResources.DiskMB,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {
|
||||
handle, ok := d.tasks.Get(taskID)
|
||||
if !ok {
|
||||
|
|
|
@ -334,11 +334,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
|||
Env: cfg.EnvList(),
|
||||
User: cfg.User,
|
||||
ResourceLimits: true,
|
||||
Resources: &executor.Resources{
|
||||
CPU: cfg.Resources.NomadResources.CPU,
|
||||
MemoryMB: cfg.Resources.NomadResources.MemoryMB,
|
||||
DiskMB: cfg.Resources.NomadResources.DiskMB,
|
||||
},
|
||||
Resources: cfg.Resources,
|
||||
TaskDir: cfg.TaskDir().Dir,
|
||||
StdoutPath: cfg.StdoutPath,
|
||||
StderrPath: cfg.StderrPath,
|
||||
|
|
|
@ -645,11 +645,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
|
|||
Cmd: absPath,
|
||||
Args: runArgs,
|
||||
ResourceLimits: true,
|
||||
Resources: &executor.Resources{
|
||||
CPU: int(cfg.Resources.LinuxResources.CPUShares),
|
||||
MemoryMB: int(drivers.BytesToMB(cfg.Resources.LinuxResources.MemoryLimitBytes)),
|
||||
DiskMB: cfg.Resources.NomadResources.DiskMB,
|
||||
},
|
||||
Resources: cfg.Resources,
|
||||
Env: cfg.EnvList(),
|
||||
TaskDir: cfg.TaskDir().Dir,
|
||||
StdoutPath: cfg.StdoutPath,
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/hashicorp/nomad/client/testutil"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/mock"
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
tu "github.com/hashicorp/nomad/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -65,11 +66,8 @@ func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocD
|
|||
cmd := &ExecCommand{
|
||||
Env: taskEnv.List(),
|
||||
TaskDir: td.Dir,
|
||||
Resources: &Resources{
|
||||
CPU: task.Resources.CPU,
|
||||
MemoryMB: task.Resources.MemoryMB,
|
||||
IOPS: task.Resources.IOPS,
|
||||
DiskMB: task.Resources.DiskMB,
|
||||
Resources: &drivers.Resources{
|
||||
NomadResources: task.Resources,
|
||||
},
|
||||
}
|
||||
configureTLogging(cmd)
|
||||
|
@ -109,7 +107,7 @@ func TestExecutor_IsolationAndConstraints(t *testing.T) {
|
|||
data, err := ioutil.ReadFile(memLimits)
|
||||
require.NoError(err)
|
||||
|
||||
expectedMemLim := strconv.Itoa(execCmd.Resources.MemoryMB * 1024 * 1024)
|
||||
expectedMemLim := strconv.Itoa(execCmd.Resources.NomadResources.MemoryMB * 1024 * 1024)
|
||||
actualMemLim := strings.TrimSpace(string(data))
|
||||
require.Equal(actualMemLim, expectedMemLim)
|
||||
require.NoError(executor.Shutdown("", 0))
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
tu "github.com/hashicorp/nomad/testutil"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
|
@ -52,11 +53,8 @@ func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) {
|
|||
cmd := &ExecCommand{
|
||||
Env: taskEnv.List(),
|
||||
TaskDir: td.Dir,
|
||||
Resources: &Resources{
|
||||
CPU: task.Resources.CPU,
|
||||
MemoryMB: task.Resources.MemoryMB,
|
||||
IOPS: task.Resources.IOPS,
|
||||
DiskMB: task.Resources.DiskMB,
|
||||
Resources: &drivers.Resources{
|
||||
NomadResources: task.Resources,
|
||||
},
|
||||
}
|
||||
configureTLogging(cmd)
|
||||
|
|
Loading…
Reference in New Issue