diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-08-21 23:06:11 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-21 23:07:39 -0700 |
commit | e2ab7ec39e500627126fe8be8e37400711410cde (patch) | |
tree | 657daefdfb39d5062527108ab5ee8ccec634ca9b | |
parent | 8bb50dab790d575a83a935cf3361099cdb1a6aac (diff) |
Fix TestUnixDomainSockets failure when path is too large
UDS has a lower size limit than regular files. When running under bazel
this limit is exceeded. Test was changed to always mount /tmp and use
it for the test.
PiperOrigin-RevId: 209717830
Change-Id: I1dbe19fe2051ffdddbaa32b188a9167f446ed193
-rw-r--r-- | runsc/container/container_test.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index 7f2bac4b8..d847dca97 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -704,22 +704,20 @@ func TestCheckpointRestore(t *testing.T) { // TestUnixDomainSockets checks that Checkpoint/Restore works in cases // with filesystem Unix Domain Socket use. func TestUnixDomainSockets(t *testing.T) { - const ( - output = "uds_output" - socket = "uds_socket" - ) - // Skip overlay because test requires writing to host file. for _, conf := range configs(noOverlay...) { t.Logf("Running test with conf: %+v", conf) - dir, err := ioutil.TempDir(testutil.TmpDir(), "uds-test") + // UDS path is limited to 108 chars for compatibility with older systems. + // Use '/tmp' (instead of testutil.TmpDir) to to ensure the size limit is + // not exceeded. Assumes '/tmp' exists in the system. + dir, err := ioutil.TempDir("/tmp", "uds-test") if err != nil { t.Fatalf("ioutil.TempDir failed: %v", err) } defer os.RemoveAll(dir) - outputPath := filepath.Join(dir, output) + outputPath := filepath.Join(dir, "uds_output") outputFile, err := os.OpenFile(outputPath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666) if err != nil { t.Fatalf("error creating output file: %v", err) @@ -731,7 +729,7 @@ func TestUnixDomainSockets(t *testing.T) { t.Fatal("error finding uds_test_app:", err) } - socketPath := filepath.Join(dir, socket) + socketPath := filepath.Join(dir, "uds_socket") defer os.Remove(socketPath) spec := testutil.NewSpecWithArgs(app, "--file", outputPath, "--socket", socketPath) @@ -739,6 +737,13 @@ func TestUnixDomainSockets(t *testing.T) { UID: uint32(os.Getuid()), GID: uint32(os.Getgid()), } + spec.Mounts = []specs.Mount{ + specs.Mount{ + Type: "bind", + Destination: "/tmp", + Source: "/tmp", + }, + } rootDir, bundleDir, err := testutil.SetupContainer(spec, conf) if err != nil { |