mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
The change updates the layout of the tests following a proposed order which should make the test easier to read and understand The proposed order is: summary details backends systems manual priority warn-timout kill-timeout environment prepare restore debug execute
83 lines
4.4 KiB
YAML
83 lines
4.4 KiB
YAML
summary: Checks for parallel installation of a local snap files
|
|
|
|
prepare: |
|
|
# ensure we have no snap user data directory yet
|
|
rm -rf /home/test/snap
|
|
rm -rf /var/snap/test-snapd-sh /var/snap/test-snapd-sh_foo
|
|
|
|
snap set system experimental.parallel-instances=true
|
|
|
|
restore: |
|
|
snap set system experimental.parallel-instances=null
|
|
|
|
execute: |
|
|
"$TESTSTOOLS"/snaps-state install-local test-snapd-sh
|
|
"$TESTSTOOLS"/snaps-state install-local-as test-snapd-sh test-snapd-sh_foo
|
|
|
|
su -l -c '! test -d ~/snap/test-snapd-sh' test
|
|
su -l -c '! test -d ~/snap/test-snapd-sh_foo' test
|
|
|
|
su -l -c 'test-snapd-sh_foo.sh -c "echo foo"' test | MATCH foo
|
|
su -l -c 'test -d ~/snap/test-snapd-sh' test
|
|
su -l -c 'test -d ~/snap/test-snapd-sh_foo' test
|
|
|
|
# instance environment variables are correctly set up
|
|
su -l -c 'test-snapd-sh_foo.sh -c "env"' test > snap_foo-env.txt
|
|
MATCH 'SNAP_INSTANCE_NAME=test-snapd-sh_foo' < snap_foo-env.txt
|
|
MATCH 'SNAP_NAME=test-snapd-sh' < snap_foo-env.txt
|
|
MATCH 'SNAP_INSTANCE_KEY=foo' < snap_foo-env.txt
|
|
MATCH 'SNAP=/snap/test-snapd-sh/x1' < snap_foo-env.txt
|
|
MATCH 'SNAP_COMMON=/var/snap/test-snapd-sh/common' < snap_foo-env.txt
|
|
MATCH 'SNAP_DATA=/var/snap/test-snapd-sh/x1' < snap_foo-env.txt
|
|
MATCH 'SNAP_USER_DATA=/home/test/snap/test-snapd-sh_foo/x1' < snap_foo-env.txt
|
|
MATCH 'SNAP_USER_COMMON=/home/test/snap/test-snapd-sh_foo/common' < snap_foo-env.txt
|
|
|
|
# and non-instance one's are too
|
|
su -l -c 'test-snapd-sh.sh -c env' test > snap-env.txt
|
|
MATCH 'SNAP_INSTANCE_NAME=test-snapd-sh' < snap-env.txt
|
|
MATCH 'SNAP_NAME=test-snapd-sh' < snap-env.txt
|
|
MATCH 'SNAP_INSTANCE_KEY=$' < snap-env.txt
|
|
MATCH 'SNAP=/snap/test-snapd-sh/x1' < snap-env.txt
|
|
|
|
mkdir /var/snap/test-snapd-sh_foo/common/foobar
|
|
echo canary-instance > /var/snap/test-snapd-sh_foo/common/foobar/data
|
|
chown -R test:test /var/snap/test-snapd-sh_foo/common/foobar
|
|
|
|
mkdir /var/snap/test-snapd-sh/common/foobar
|
|
echo canary-regular > /var/snap/test-snapd-sh/common/foobar/data
|
|
chown -R test:test /var/snap/test-snapd-sh/common/foobar
|
|
|
|
echo "Make sure snap data writes and reads work"
|
|
|
|
# instance can access its data
|
|
su -l -c "test-snapd-sh_foo.sh -c 'cat \$SNAP_COMMON/foobar/data'" test | MATCH canary-instance
|
|
# non-instance sees its data
|
|
su -l -c "test-snapd-sh.sh -c 'cat \$SNAP_COMMON/foobar/data'" test | MATCH canary-regular
|
|
|
|
# instance can write data
|
|
su -l -c "test-snapd-sh_foo.sh -c 'echo hello from instance \$SNAP_INSTANCE_NAME > \$SNAP_COMMON/foobar/hello'" test
|
|
MATCH 'hello from instance test-snapd-sh_foo' < /var/snap/test-snapd-sh_foo/common/foobar/hello
|
|
# and the file is not visible in non instance snap
|
|
su -l -c "test-snapd-sh.sh -c 'cat \$SNAP_COMMON/foobar/hello || true'" test 2>&1 | MATCH 'cat: /var/snap/test-snapd-sh/common/foobar/hello: No such file or directory'
|
|
|
|
echo "Make sure snap user data writes work"
|
|
echo canary-instance-snap > /home/test/snap/test-snapd-sh_foo/x1/canary
|
|
chown test:test /home/test/snap/test-snapd-sh_foo/x1/canary
|
|
echo canary-instance-common > /home/test/snap/test-snapd-sh_foo/common/canary
|
|
chown test:test /home/test/snap/test-snapd-sh_foo/common/canary
|
|
|
|
# instance snap can write to user data
|
|
su -l -c "test-snapd-sh_foo.sh -c 'echo hello user data from \$SNAP_INSTANCE_NAME > \$SNAP_USER_DATA/data'" test
|
|
MATCH 'hello user data from test-snapd-sh_foo' < /home/test/snap/test-snapd-sh_foo/x1/data
|
|
# the file not present in non-instance snap data
|
|
not test -f /home/test/snap/test-snapd-sh/x1/data
|
|
|
|
# instance snap can write to common user data
|
|
su -l -c "test-snapd-sh_foo.sh -c 'echo hello user data from \$SNAP_INSTANCE_NAME > \$SNAP_USER_COMMON/data'" test
|
|
MATCH 'hello user data from test-snapd-sh_foo' < /home/test/snap/test-snapd-sh_foo/common/data
|
|
# the file not present in non-instance snap data
|
|
not test -f /home/test/snap/test-snapd-sh/common/data
|
|
|
|
su -l -c "test-snapd-sh_foo.sh -c 'cat \$SNAP_USER_COMMON/canary'" test | MATCH canary-instance-common
|
|
su -l -c "test-snapd-sh_foo.sh -c 'cat \$SNAP_USER_DATA/canary'" test | MATCH canary-instance-snap
|