Files
snapd/tests/main/interfaces-libvirt/task.yaml
Zygmunt Bazyli Krynicki 6da6dd1472 tests: document or tweak documentation of interface tests (#13896)
* tests: fix typo: case

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-audio-playback-record

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-avahi-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-cli

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-content-circular

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-content-empty-content-attr

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-cups-control-autoconect

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-cups-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-content-mkdir-writable

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-custom-device-app-slot

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-desktop-document-portal

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-firewall-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-fuse-support

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: fix typo: default

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-random-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-hardware-random-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-home

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-hooks

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-hooks-plug-with-number

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-kernel-module-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-libvirt

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-locale-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-location-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-log-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-mount-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite documentation of interfaces-mount-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-netlink-connector

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite documentation of interfaces-network-bind

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-network-manager

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat and tweak details of interfaces-network-status

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-packagekit-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-password-manager-service

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-personal-files

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: rewrite details of interfaces-polkit

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-pulseaudio

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-snapd-control

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-snapd-control-with-manage

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-system-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: reformat details of interfaces-upower-observe

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document interfaces-wayland

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document known

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document known-remote

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: correct the summary for known-remote test

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: fix typo: bound

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document install-local-w-metadata

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests/main: document login

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

---------

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-26 15:10:48 +02:00

89 lines
3.2 KiB
YAML

summary: Ensure that the libvirt interface works.
details: |
The libvirt interface allows a snap to access the libvirtd socket in order
to manage libvirt domains and other resources.
A snap which defines a libvirt plug must be shown in the interfaces list.
The plug must not be auto-connected on install and, as usual, must be able
to be reconnected.
A snap declaring a plug on this interface must be able to create and destroy
a domain. The test uses a snap that carries a unikernel built to be run on
top of qemu, boot and respond to ping. Once the domain is created, the test
checks connectivity to the unikernel.
systems: [ubuntu-2*]
prepare: |
if not os.query is-pc-amd64; then
echo "The snap test-snapd-libvirt-consumer is just available for amd64"
exit
fi
# Given test user is added to the libvirt group
adduser test libvirt
echo "And libvirt is configured to manage /dev/net/tun"
systemctl stop libvirtd.service || true
echo 'cgroup_device_acl = ["/dev/net/tun", "/dev/random", "/dev/urandom"]' | tee -a /etc/libvirt/qemu.conf
echo "And the required services up"
systemctl start libvirtd.service
systemctl start virtlogd.socket
echo "And a snap declaring a plug on the libvirt interface is installed"
snap install --edge test-snapd-libvirt-consumer
# Temporary workaround until the updated test snap is released
mount -o bind "$TESTSLIB/snaps/store/test-snapd-libvirt-consumer/vm/ping-unikernel.xml" \
/snap/test-snapd-libvirt-consumer/current/vm/ping-unikernel.xml
echo "And the required tap interface is in place"
ip tuntap add tap100 mode tap
ip addr add 10.0.0.1/24 dev tap100
ip link set dev tap100 up
restore: |
if not os.query is-pc-amd64; then
echo "The snap test-snapd-libvirt-consumer is just available for amd64"
exit
fi
ip link delete tap100
# remove test user from the libvirt group
deluser test libvirt
execute: |
if not os.query is-pc-amd64; then
echo "The snap test-snapd-libvirt-consumer is just available for amd64"
exit
fi
echo "The interface is not connected by default"
snap interfaces -i libvirt | MATCH '^- +test-snapd-libvirt-consumer:libvirt'
echo "When the plug is connected"
snap connect test-snapd-libvirt-consumer:libvirt
echo "Then the snap is able to create the unikernel domain"
su -l -c "test-snapd-libvirt-consumer.machine-up" test
virsh list | MATCH ping-unikernel
echo "And the unikernel is accesible"
ping -c 1 -q -W 1 10.0.0.2
echo "And the snap is able to destroy the unikernel domain"
su -l -c "test-snapd-libvirt-consumer.machine-down" test
virsh list | NOMATCH ping-unikernel
echo "When the plug is disconnected"
snap disconnect test-snapd-libvirt-consumer:libvirt
echo "Then the snap is not able to create a domain"
if su -l -c "test-snapd-libvirt-consumer.machine-up" test 2> creation.error; then
echo "Expected permission error accessing libvirtd socket with disconnected plug"
exit 1
fi
MATCH "Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied" < creation.error