mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
Merge branch 'master' into f-grpc-executor
* master: (71 commits) Fix output of 'nomad deployment fail' with no arg Always create a running allocation when testing task state tests: ensure exec tests pass valid task resources (#4992) some changes for more idiomatic code fix iops related tests fixed bug in loop delay gofmt improved code for readability client: updateAlloc release lock after read fixup! device attributes in `nomad node status -verbose` drivers/exec: support device binds and mounts fix iops bug and increase test matrix coverage tests: tag image explicitly changelog ci: install lxc-templates explicitly tests: skip checking rdma cgroup ci: use Ubuntu 16.04 (Xenial) in TravisCI client: update driver info on new fingerprint drivers/docker: enforce volumes.enabled (#4983) client: Style: use fluent style for building loggers ...
This commit is contained in:
@@ -20,7 +20,9 @@ import (
|
||||
"github.com/hashicorp/nomad/nomad/mock"
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
tu "github.com/hashicorp/nomad/testutil"
|
||||
lconfigs "github.com/opencontainers/runc/libcontainer/configs"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -170,11 +172,24 @@ func TestExecutor_ClientCleanup(t *testing.T) {
|
||||
execCmd.ResourceLimits = true
|
||||
|
||||
ps, err := executor.Launch(execCmd)
|
||||
|
||||
require.NoError(err)
|
||||
require.NotZero(ps.Pid)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond))
|
||||
executor.Wait(context.Background())
|
||||
|
||||
ch := make(chan interface{})
|
||||
go func() {
|
||||
executor.Wait(context.Background())
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
// all good
|
||||
case <-time.After(5 * time.Second):
|
||||
require.Fail("timeout waiting for exec to shutdown")
|
||||
}
|
||||
|
||||
outWriter, _ := execCmd.GetWriters()
|
||||
output := outWriter.(*bufferCloser).String()
|
||||
@@ -183,3 +198,66 @@ func TestExecutor_ClientCleanup(t *testing.T) {
|
||||
output1 := outWriter.(*bufferCloser).String()
|
||||
require.Equal(len(output), len(output1))
|
||||
}
|
||||
|
||||
func TestExecutor_cmdDevices(t *testing.T) {
|
||||
input := []*drivers.DeviceConfig{
|
||||
{
|
||||
HostPath: "/dev/null",
|
||||
TaskPath: "/task/dev/null",
|
||||
Permissions: "rwm",
|
||||
},
|
||||
}
|
||||
|
||||
expected := &lconfigs.Device{
|
||||
Path: "/task/dev/null",
|
||||
Type: 99,
|
||||
Major: 1,
|
||||
Minor: 3,
|
||||
Permissions: "rwm",
|
||||
}
|
||||
|
||||
found, err := cmdDevices(input)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, found, 1)
|
||||
|
||||
// ignore file permission and ownership
|
||||
// as they are host specific potentially
|
||||
d := found[0]
|
||||
d.FileMode = 0
|
||||
d.Uid = 0
|
||||
d.Gid = 0
|
||||
|
||||
require.EqualValues(t, expected, d)
|
||||
}
|
||||
|
||||
func TestExecutor_cmdMounts(t *testing.T) {
|
||||
input := []*drivers.MountConfig{
|
||||
{
|
||||
HostPath: "/host/path-ro",
|
||||
TaskPath: "/task/path-ro",
|
||||
Readonly: true,
|
||||
},
|
||||
{
|
||||
HostPath: "/host/path-rw",
|
||||
TaskPath: "/task/path-rw",
|
||||
Readonly: false,
|
||||
},
|
||||
}
|
||||
|
||||
expected := []*lconfigs.Mount{
|
||||
{
|
||||
Source: "/host/path-ro",
|
||||
Destination: "/task/path-ro",
|
||||
Flags: unix.MS_BIND | unix.MS_RDONLY,
|
||||
Device: "bind",
|
||||
},
|
||||
{
|
||||
Source: "/host/path-rw",
|
||||
Destination: "/task/path-rw",
|
||||
Flags: unix.MS_BIND,
|
||||
Device: "bind",
|
||||
},
|
||||
}
|
||||
|
||||
require.EqualValues(t, expected, cmdMounts(input))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user