Skip to content

Commit

Permalink
tests: Test volume subpaths
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Aug 8, 2024
1 parent a16f6f6 commit 0718a34
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/suites/container_devices_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_container_devices_disk() {
incus init testimage foo

test_container_devices_disk_shift
test_container_devices_disk_subpath
test_container_devices_raw_mount_options
test_container_devices_disk_ceph
test_container_devices_disk_cephfs
Expand Down Expand Up @@ -182,3 +183,44 @@ test_container_devices_disk_char() {
incus config device remove foo char
incus stop foo -f
}

test_container_devices_disk_subpath() {
# Create a test volume and main container
incus storage volume create "${POOL}" foo
incus launch testimage foo
incus config device add foo foo disk pool="${POOL}" source=foo path=/foo

# Create some entries
incus exec foo -- mkdir /foo/path1 /foo/path2
incus exec foo -- ln -s /etc /foo/path3
incus exec foo -- ln -s path1 /foo/path4
echo path1 | incus file push - foo/foo/path1/hello
echo path2 | incus file push - foo/foo/path2/hello

# Create some test containers
incus create testimage foo-path1
incus config device add foo-path1 foo disk pool="${POOL}" source=foo/path1 path=/foo

incus create testimage foo-path2
incus config device add foo-path2 foo disk pool="${POOL}" source=foo/path2 path=/foo

incus create testimage foo-path3
incus config device add foo-path3 foo disk pool="${POOL}" source=foo/path3 path=/foo

incus create testimage foo-path4
incus config device add foo-path4 foo disk pool="${POOL}" source=foo/path4 path=/foo

# Validation
incus start foo-path1
incus start foo-path2
! incus start foo-path3 || false
incus start foo-path4

[ "$(incus file pull foo-path1/foo/hello -)" = "path1" ]
[ "$(incus file pull foo-path2/foo/hello -)" = "path2" ]
[ "$(incus file pull foo-path4/foo/hello -)" = "path1" ]

# Cleanup
incus delete -f foo foo-path1 foo-path2 foo-path3 foo-path4
incus storage volume delete "${POOL}" foo
}

0 comments on commit 0718a34

Please sign in to comment.