Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lxd-user test #12379

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions test/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ if [ "${1:-"all"}" != "cluster" ]; then
run_test test_metrics "Metrics"
run_test test_storage_volume_recover "Recover storage volumes"
run_test test_syslog_socket "Syslog socket"
run_test test_lxd_user "lxd user"
fi

# shellcheck disable=SC2034
Expand Down
6 changes: 3 additions & 3 deletions test/suites/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ EOF

if [ "$poolDriver" = "zfs" ]; then
# Ensure custom storage volumes have been recovered.
lxc storage volume show "${poolName}" vol3| grep -q 'content_type: filesystem'
lxc storage volume show "${poolName}" vol4| grep -q 'content_type: filesystem'
lxc storage volume show "${poolName}" vol3 | grep -q 'content_type: filesystem'
lxc storage volume show "${poolName}" vol4 | grep -q 'content_type: filesystem'

# Cleanup
lxc storage volume delete "${poolName}" vol3
Expand All @@ -62,7 +62,7 @@ EOF
rm -f foo.iso
lxc storage volume delete "${poolName}" vol1
lxc storage volume delete "${poolName}" vol2
shutdown_lxd "${LXD_DIR}"
shutdown_lxd "${LXD_IMPORT_DIR}"
}

test_container_recover() {
Expand Down
31 changes: 31 additions & 0 deletions test/suites/lxd_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
test_lxd_user() {
ensure_import_testimage
ensure_has_localhost_remote "${LXD_ADDR}"

mkdir "${TEST_DIR}/lxd-user"
cd "${TEST_DIR}/lxd-user" || return

lxd-user &
USER_PID="$!"
while :; do
[ -S "${TEST_DIR}/lxd-user/unix.socket" ] && break
sleep 0.5
done

chgrp "nogroup" "${TEST_DIR}/lxd-user/unix.socket"
chmod 0660 "${TEST_DIR}/lxd-user/unix.socket"

USER_TEMPDIR="${TEST_DIR}/user"
mkdir "${USER_TEMPDIR}"
chown nobody:nogroup "${USER_TEMPDIR}"

bakLxdDir="${LXD_DIR}"
LXD_DIR="${TEST_DIR}/lxd-user"

cmd=$(unset -f lxc; command -v lxc)
sudo -u nobody -Es -- env LXD_CONF="${USER_TEMPDIR}" "${cmd}" project list

kill -9 "${USER_PID}"

LXD_DIR="${bakLxdDir}"
}
7 changes: 1 addition & 6 deletions test/suites/syslog.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
test_syslog_socket() {
LXD_DIR=$(mktemp -d -p "${TEST_DIR}" XXX)
export LXD_DIR
chmod +x "${LXD_DIR}"
spawn_lxd "${LXD_DIR}" true

lxc config set core.syslog_socket=true
lxc monitor --type=ovn > "${TEST_DIR}/ovn.log" &
monitorOVNPID=$!
Expand All @@ -16,5 +11,5 @@ test_syslog_socket() {
grep -qF "type: ovn" "${TEST_DIR}/ovn.log"
grep -qF "unix:/var/run/openvswitch/br-int.mgmt: connected" "${TEST_DIR}/ovn.log"

shutdown_lxd "${LXD_DIR}"
lxc config unset core.syslog_socket
}