Skip to content

Commit

Permalink
Tiny misc fixes (#14038)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomponline authored Sep 4, 2024
2 parents 1e0b353 + 79ca22d commit 6de52be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions test/suites/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ test_exec() {
# Check non-websocket based exec works.
opID=$(lxc query -X POST -d '{\"command\":[\"touch\",\"/root/foo1\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id)
sleep 1
lxc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "0"
[ "$(lxc query /1.0/operations/"${opID}" | jq .metadata.return)" = "0" ]
lxc exec x1 -- stat /root/foo1

opID=$(lxc query -X POST -d '{\"command\":[\"missingcmd\"],\"record-output\":false}' /1.0/instances/x1/exec | jq -r .id)
sleep 1
lxc query /1.0/operations/"${opID}" | jq .metadata.return | grep -F "127"
[ "$(lxc query /1.0/operations/"${opID}" | jq .metadata.return)" = "127" ]

echo "hello" | lxc exec x1 -- tee /root/foo1
opID=$(lxc query -X POST -d '{\"command\":[\"cat\",\"/root/foo1\"],\"record-output\":true}' /1.0/instances/x1/exec | jq -r .id)
sleep 1
stdOutURL=$(lxc query /1.0/operations/"${opID}" | jq '.metadata.output["1"]')
lxc query "${stdOutURL}" | grep -F "hello"
stdOutURL="$(lxc query /1.0/operations/"${opID}" | jq '.metadata.output["1"]')"
[ "$(lxc query "${stdOutURL}")" = "hello" ]

lxc stop "${name}" --force
lxc delete "${name}"
Expand Down
2 changes: 1 addition & 1 deletion test/suites/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test_image_import_dir() {
local exported
exported="${fingerprint}.tar.xz"

tar tvf "$exported" | grep -Fq metadata.yaml
tar tvf "$exported" metadata.yaml
rm "$exported"
}

Expand Down
14 changes: 9 additions & 5 deletions test/suites/storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ test_storage() {
storage_volume="${storage_pool}-vol"
lxc storage create "$storage_pool" "$lxd_backend"
lxc storage show "$storage_pool" | sed 's/^description:.*/description: foo/' | lxc storage edit "$storage_pool"
lxc storage show "$storage_pool" | grep -q 'description: foo'
[ "$(lxc storage get "$storage_pool" -p description)" = "foo" ]
lxc storage set "$storage_pool" -p description="baz"
[ "$(lxc storage get "$storage_pool" -p description)" = "baz" ]

lxc storage volume create "$storage_pool" "$storage_volume"

# Test setting description on a storage volume
lxc storage volume show "$storage_pool" "$storage_volume" | sed 's/^description:.*/description: bar/' | lxc storage volume edit "$storage_pool" "$storage_volume"
lxc storage volume show "$storage_pool" "$storage_volume" | grep -q 'description: bar'
[ "$(lxc storage volume get "$storage_pool" "$storage_volume" -p description)" = "bar" ]
lxc storage volume set "$storage_pool" "$storage_volume" -p description="baz"
[ "$(lxc storage volume get "$storage_pool" "$storage_volume" -p description)" = "baz" ]

# Test creating a storage pool from yaml
storage_pool_yaml="lxdtest-$(basename "${LXD_DIR}")-pool-yaml"
Expand All @@ -32,7 +36,7 @@ config:
EOF

[ "$(lxc storage get "$storage_pool_yaml" size)" = "2GiB" ]
[ "$(lxc storage show "$storage_pool_yaml" | grep -i "description:" | awk '{print $2}')" = "foo" ]
[ "$(lxc storage get "$storage_pool_yaml" -p description)" = "foo" ]
elif [ "${lxd_backend}" = "dir" ]; then
tempdir=$(mktemp -d)
lxc storage create "$storage_pool_yaml" "$lxd_backend" <<EOF
Expand All @@ -42,7 +46,7 @@ config:
EOF

[ "$(lxc storage get "$storage_pool_yaml" source)" = "${tempdir}" ]
[ "$(lxc storage show "$storage_pool_yaml" | grep -i "description:" | awk '{print $2}')" = "foo" ]
[ "$(lxc storage get "$storage_pool_yaml" -p description)" = "foo" ]
elif [ "${lxd_backend}" = "ceph" ]; then
lxc storage create "$storage_pool_yaml" "$lxd_backend" <<EOF
description: foo
Expand All @@ -51,7 +55,7 @@ config:
EOF

[ "$(lxc storage get "$storage_pool_yaml" ceph.cluster_name)" = "ceph" ]
[ "$(lxc storage show "$storage_pool_yaml" | grep -i "description:" | awk '{print $2}')" = "foo" ]
[ "$(lxc storage get "$storage_pool_yaml" -p description)" = "foo" ]
fi

# Delete storage pool
Expand Down
2 changes: 1 addition & 1 deletion test/suites/storage_volume_attach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ config:
EOF
# Check that the size and description are set correctly
[ "$(lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")" testvolume-yaml size)" = "3GiB" ]
[ "$(lxc storage volume show "lxdtest-$(basename "${LXD_DIR}")" testvolume-yaml | grep -i "description:" | awk '{print $2}')" = "foo" ]
[ "$(lxc storage volume get "lxdtest-$(basename "${LXD_DIR}")" testvolume-yaml -p description)" = "foo" ]

# create containers
lxc launch testimage c1 -c security.privileged=true
Expand Down

0 comments on commit 6de52be

Please sign in to comment.