mirror of
https://github.com/clearlinux/rkt.git
synced 2026-08-18 21:16:13 +00:00
functional tests: Port volume tests to rkt run context
This commit is contained in:
@@ -31,35 +31,35 @@ var volTests = []struct {
|
||||
}{
|
||||
// Check that we can read files in the ACI
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true ./rkt-inspect-read-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true ./rkt-inspect-read-file.aci"`,
|
||||
`<<<dir1>>>`,
|
||||
},
|
||||
// Check that we can read files from a volume (both ro and rw)
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-rw-read-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-rw-read-file.aci"`,
|
||||
`<<<host>>>`,
|
||||
},
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-read-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-read-file.aci"`,
|
||||
`<<<host>>>`,
|
||||
},
|
||||
// Check that we can write to files in the ACI
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true ./rkt-inspect-write-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=1 ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true ./rkt-inspect-write-file.aci"`,
|
||||
`<<<1>>>`,
|
||||
},
|
||||
// Check that we can write files to a volume (both ro and rw)
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=2 ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-rw-write-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=2 ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-rw-write-file.aci"`,
|
||||
`<<<2>>>`,
|
||||
},
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=3 ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-write-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file CONTENT=3 ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-write-file.aci"`,
|
||||
`Cannot write to file "/dir1/file": open /dir1/file: read-only file system`,
|
||||
},
|
||||
// Check that the volume still contain the file previously written
|
||||
{
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ../bin/rkt --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-read-file.aci"`,
|
||||
`/bin/sh -c "export FILE=/dir1/file ; ^RKT_BIN^ --debug --insecure-skip-verify run --inherit-env=true --volume=dir1,kind=host,source=$TMPDIR ./rkt-inspect-vol-ro-read-file.aci"`,
|
||||
`<<<2>>>`,
|
||||
},
|
||||
}
|
||||
@@ -77,22 +77,24 @@ func TestVolumes(t *testing.T) {
|
||||
defer os.Remove("rkt-inspect-vol-ro-read-file.aci")
|
||||
patchTestACI("rkt-inspect-vol-ro-write-file.aci", "--exec=/inspect --write-file --read-file", "--mounts=dir1,path=/dir1,readOnly=true")
|
||||
defer os.Remove("rkt-inspect-vol-ro-write-file.aci")
|
||||
ctx := newRktRunCtx()
|
||||
defer ctx.cleanup()
|
||||
|
||||
tmpdir, err := ioutil.TempDir("", "rkt-tests.")
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot create temporary directory: %v", err)
|
||||
}
|
||||
defer os.Remove(tmpdir)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
tmpfile := filepath.Join(tmpdir, "file")
|
||||
err = ioutil.WriteFile(tmpfile, []byte("host"), 0600)
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot create temporary file: %v", err)
|
||||
}
|
||||
defer os.Remove(tmpfile)
|
||||
|
||||
for i, tt := range volTests {
|
||||
cmd := strings.Replace(tt.rktCmd, "$TMPDIR", tmpdir, -1)
|
||||
cmd = strings.Replace(cmd, "^RKT_BIN^", ctx.cmd(), -1)
|
||||
|
||||
t.Logf("Running test #%v: %v", i, cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user