mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
Document more spread tests in detail. Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
47 lines
1.7 KiB
YAML
47 lines
1.7 KiB
YAML
summary: Ensure network errors are handled gracefully
|
|
|
|
details: |
|
|
Check that snapd handles and logs network errors correctly. The test does
|
|
this by rejecting DNS queries with iptables, flushing the DNS cache and
|
|
then forcing snapd to trigger a query.
|
|
|
|
# no iptables on core18+
|
|
systems: [-ubuntu-core-18-*, -ubuntu-core-2*]
|
|
|
|
restore: |
|
|
echo "Restoring iptables rules"
|
|
iptables -D OUTPUT -p udp --dport 53 -j REJECT --reject-with icmp-port-unreachable || true
|
|
iptables -D OUTPUT -p tcp --dport 53 -j REJECT --reject-with icmp-port-unreachable || true
|
|
|
|
debug: |
|
|
echo "iptables rules:"
|
|
iptables -L -n -v || true
|
|
|
|
execute: |
|
|
# Do a store op to avoid an unexpected device auth refresh on snap find
|
|
# below, which would produce different kind of error.
|
|
snap refresh
|
|
|
|
systemctl stop snapd.{socket,service}
|
|
|
|
echo "Disabling DNS queries"
|
|
# DNS queries generally use port 53 through UDP protocol, but TCP could be used as well
|
|
iptables -I OUTPUT -p udp --dport 53 -j REJECT --reject-with icmp-port-unreachable
|
|
iptables -I OUTPUT -p tcp --dport 53 -j REJECT --reject-with icmp-port-unreachable
|
|
|
|
if systemctl is-active systemd-resolved; then
|
|
# before systemd 239, the tool was named systemd-resolve some systems do not support
|
|
if command -v resolvectl; then
|
|
resolvectl flush-caches
|
|
elif systemd-resolve -h | MATCH flush-caches; then
|
|
# centos 7: doesn't support caching dns, so no flushing required
|
|
# ubuntu-core 16: systemd-resolve doesn't support flush-caches
|
|
systemd-resolve --flush-caches
|
|
fi
|
|
fi
|
|
|
|
systemctl start snapd.{socket,service}
|
|
|
|
OUT=$(snap find test 2>&1 || true)
|
|
echo "$OUT" | MATCH "error: unable to contact snap store"
|