Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (81 sloc) 3.79 KB
summary: Ensure that the ubuntu-core -> core transition works
# we never test on core because the transition can only happen on "classic"
# we disable on ppc64el because the downloads are very slow there
systems: [-ubuntu-core-16-*, -ubuntu-*-ppc64el]
warn-timeout: 1m
kill-timeout: 5m
restore: |
rm -f state.json.new
execute: |
wait_for_service() {
local service_name="$1"
local state="${2:-active}"
while ! systemctl show -p ActiveState $service_name | grep -q "ActiveState=$state"; do systemctl status $service_name || true; sleep 1; done
}
curl() {
local url="$1"
# sadly systemd active means not that its really ready so we wait
# here for the socket to be available
while ! netstat -t -l -n|grep :80; do
netstat -l -l -n
sleep 1
done
python3 -c "import urllib.request; print(urllib.request.urlopen(\"$url\").read().decode(\"utf-8\"))"
}
. "$TESTSLIB/pkgdb.sh"
echo "Ensure core is gone and we have ubuntu-core instead"
dpkg --purge --force-depends snapd
apt-get install -f -y
distro_install_build_snapd
# modify daemon state to set ubuntu-core-transition-last-retry-time to the
# current time to prevent the ubuntu-core transition before the test snap is
# installed
systemctl stop snapd.{service,socket}
now=$(date --utc -Ins)
cat /var/lib/snapd/state.json | jq -c '. + {data: (.data + {"ubuntu-core-transition-last-retry-time": "'"$now"'"})}' > state.json.new
mv state.json.new /var/lib/snapd/state.json
systemctl start snapd.{service,socket}
snap download --${CORE_CHANNEL} ubuntu-core
snap ack ./ubuntu-core_*.assert
snap install ./ubuntu-core_*.snap
snap install test-snapd-python-webserver
snap interfaces | MATCH ":network +test-snapd-python-webserver"
snap interfaces | MATCH ":network-bind +.*test-snapd-python-webserver"
echo "Ensure the webserver is working"
wait_for_service snap.test-snapd-python-webserver.test-snapd-python-webserver
curl http://localhost | MATCH "XKCD rocks"
# restore ubuntu-core-transition-last-retry-time to its previous value and restart the daemon
systemctl stop snapd.{service,socket}
cat /var/lib/snapd/state.json | jq -c 'del(.["data"]["ubuntu-core-transition-last-retry-time"])' > state.json.new
mv state.json.new /var/lib/snapd/state.json
systemctl start snapd.{service,socket}
echo "Ensure transition is triggered"
snap debug ensure-state-soon
. $TESTSLIB/changes.sh
while ! snap changes|grep ".*Done.*Transition ubuntu-core to core"; do
snap changes
snap change $(change_id "Transition ubuntu-core to core")||true
sleep 1
done
if snap list|grep ubuntu-core; then
echo "ubuntu-core still installed, transition failed"
exit 1
fi
snap interfaces | MATCH ":network +test-snapd-python-webserver"
snap interfaces | MATCH ":network-bind +.*test-snapd-python-webserver"
echo "Ensure the webserver is still working"
wait_for_service snap.test-snapd-python-webserver.test-snapd-python-webserver
curl http://localhost | MATCH "XKCD rocks"
systemctl restart snap.test-snapd-python-webserver.test-snapd-python-webserver
wait_for_service snap.test-snapd-python-webserver.test-snapd-python-webserver
echo "Ensure the webserver is working after a snap restart"
curl http://localhost | MATCH "XKCD rocks"
echo "Ensure interfaces are connected"
snap interfaces | MATCH ":core-support.*core:core-support-plug"
echo "Ensure snap set core works"
snap set core system.power-key-action=ignore
if [ "$(snap get core system.power-key-action)" != "ignore" ]; then
echo "snap get did not return the expected result: "
snap get core system.power-key-action
exit 1
fi