mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
Merge pull request #9003 from hashicorp/b-tests-vagrant-20200930
Tests: fix some tests for Ubuntu 18.04
This commit is contained in:
@@ -570,7 +570,7 @@ func TestExecDriver_HandlerExec(t *testing.T) {
|
||||
}
|
||||
// Skip rdma subsystem; rdma was added in most recent kernels and libcontainer/docker
|
||||
// don't isolate it by default.
|
||||
if strings.Contains(line, ":rdma:") {
|
||||
if strings.Contains(line, ":rdma:") || strings.Contains(line, "::") {
|
||||
continue
|
||||
}
|
||||
if !strings.Contains(line, ":/nomad/") {
|
||||
|
||||
@@ -206,7 +206,9 @@ func TestExecutor_CgroupPaths(t *testing.T) {
|
||||
|
||||
// Skip rdma subsystem; rdma was added in most recent kernels and libcontainer/docker
|
||||
// don't isolate it by default.
|
||||
if strings.Contains(line, ":rdma:") {
|
||||
// :: filters out odd empty cgroup found in latest Ubuntu lines, e.g. 0::/user.slice/user-1000.slice/session-17.scope
|
||||
// that is also not used for isolation
|
||||
if strings.Contains(line, ":rdma:") || strings.Contains(line, "::") {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -260,7 +262,7 @@ func TestExecutor_CgroupPathsAreDestroyed(t *testing.T) {
|
||||
|
||||
// Skip rdma subsystem; rdma was added in most recent kernels and libcontainer/docker
|
||||
// don't isolate it by default.
|
||||
if strings.Contains(line, ":rdma:") {
|
||||
if strings.Contains(line, ":rdma:") || strings.Contains(line, "::") {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -495,7 +495,10 @@ func copyFile(t *testing.T, src, dst string) {
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
ins, err := in.Stat()
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
|
||||
out, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, ins.Mode())
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
defer func() {
|
||||
if err := out.Close(); err != nil {
|
||||
@@ -633,6 +636,8 @@ func TestExecutor_Start_NonExecutableBinaries(pt *testing.T) {
|
||||
}
|
||||
return true, nil
|
||||
}, func(err error) {
|
||||
stderr := strings.TrimSpace(string(testExecCmd.stderr.String()))
|
||||
t.Logf("stderr: %v", stderr)
|
||||
require.NoError(err)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,12 +8,13 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
dresolvconf "github.com/docker/libnetwork/resolvconf"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_copySystemDNS(t *testing.T) {
|
||||
require := require.New(t)
|
||||
data, err := ioutil.ReadFile("/etc/resolv.conf")
|
||||
data, err := ioutil.ReadFile(dresolvconf.Path())
|
||||
require.NoError(err)
|
||||
|
||||
tmp, err := ioutil.TempDir("", "copySystemDNS_Test")
|
||||
|
||||
@@ -16,7 +16,11 @@ func TestTaskDNSConfig(t *testing.T, driver *DriverHarness, taskID string, dns *
|
||||
caps, err := driver.Capabilities()
|
||||
require.NoError(t, err)
|
||||
|
||||
isolated := (caps.FSIsolation != drivers.FSIsolationNone)
|
||||
// FS isolation is used here as a proxy for network isolation.
|
||||
// This is true for the current built-in drivers but it is not necessarily so.
|
||||
isolated := caps.FSIsolation != drivers.FSIsolationNone
|
||||
usesHostNetwork := caps.FSIsolation != drivers.FSIsolationImage
|
||||
|
||||
if !isolated {
|
||||
t.Skip("dns config not supported on non isolated drivers")
|
||||
}
|
||||
@@ -39,7 +43,12 @@ func TestTaskDNSConfig(t *testing.T, driver *DriverHarness, taskID string, dns *
|
||||
require.ElementsMatch(t, dns.Options, dresolvconf.GetOptions(resolvConf))
|
||||
}
|
||||
} else {
|
||||
system, err := dresolvconf.Get()
|
||||
systemPath := "/etc/resolv.conf"
|
||||
if !usesHostNetwork {
|
||||
systemPath = dresolvconf.Path()
|
||||
}
|
||||
|
||||
system, err := dresolvconf.GetSpecific(systemPath)
|
||||
require.NoError(t, err)
|
||||
require.ElementsMatch(t, dresolvconf.GetNameservers(system.Content, dtypes.IP), dresolvconf.GetNameservers(resolvConf, dtypes.IP))
|
||||
require.ElementsMatch(t, dresolvconf.GetSearchDomains(system.Content), dresolvconf.GetSearchDomains(resolvConf))
|
||||
|
||||
Reference in New Issue
Block a user