diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-11-07 23:28:37 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-11-07 23:29:48 -0800 |
commit | 90e81b2e5c665b9fc149f97dcf15142c190260c6 (patch) | |
tree | 3fa27177d77c080e92aa3fd8b23a2d337200e000 /runsc/test/root/crictl_test.go | |
parent | d12a0dd6b8afaca9fbb5fe60fb84a3ae0502261a (diff) |
Add test that volume can be mounted on top of a symlink
PiperOrigin-RevId: 220588094
Change-Id: I18915e892ceac86eac1f89ebcadffb4fdf8d0cf6
Diffstat (limited to 'runsc/test/root/crictl_test.go')
-rw-r--r-- | runsc/test/root/crictl_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/runsc/test/root/crictl_test.go b/runsc/test/root/crictl_test.go index 88e24782a..556d95fff 100644 --- a/runsc/test/root/crictl_test.go +++ b/runsc/test/root/crictl_test.go @@ -25,6 +25,7 @@ import ( "os/exec" "path" "path/filepath" + "strings" "testing" "time" @@ -79,6 +80,43 @@ func TestMountPaths(t *testing.T) { t.Fatal(err) } } +func TestMountOverSymlinks(t *testing.T) { + // Setup containerd and crictl. + crictl, cleanup, err := setup(t) + if err != nil { + t.Fatalf("failed to setup crictl: %v", err) + } + defer cleanup() + podID, contID, err := crictl.StartPodAndContainer("k8s.gcr.io/busybox", testdata.Sandbox, testdata.MountOverSymlink) + if err != nil { + t.Fatal(err) + } + + out, err := crictl.Exec(contID, "readlink", "/etc/resolv.conf") + if err != nil { + t.Fatal(err) + } + if want := "/tmp/resolv.conf"; !strings.Contains(string(out), want) { + t.Fatalf("/etc/resolv.conf is not pointing to %q: %q", want, string(out)) + } + + etc, err := crictl.Exec(contID, "cat", "/etc/resolv.conf") + if err != nil { + t.Fatal(err) + } + tmp, err := crictl.Exec(contID, "cat", "/tmp/resolv.conf") + if err != nil { + t.Fatal(err) + } + if tmp != etc { + t.Fatalf("file content doesn't match:\n\t/etc/resolv.conf: %s\n\t/tmp/resolv.conf: %s", string(etc), string(tmp)) + } + + // Stop everything. + if err := crictl.StopPodAndContainer(podID, contID); err != nil { + t.Fatal(err) + } +} // setup sets up before a test. Specifically it: // * Creates directories and a socket for containerd to utilize. |