Skip to content

Commit

Permalink
Merge pull request #9003 from hashicorp/b-tests-vagrant-20200930
Browse files Browse the repository at this point in the history
Tests: fix some tests for Ubuntu 18.04
  • Loading branch information
Mahmood Ali authored Oct 1, 2020
2 parents c8bc851 + fe501c9 commit 318f7b0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion drivers/exec/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/") {
Expand Down
6 changes: 4 additions & 2 deletions drivers/shared/executor/executor_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
7 changes: 6 additions & 1 deletion drivers/shared/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
})
})
Expand Down
3 changes: 2 additions & 1 deletion drivers/shared/resolvconf/mount_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
13 changes: 11 additions & 2 deletions plugins/drivers/testutils/dns_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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))
Expand Down

0 comments on commit 318f7b0

Please sign in to comment.