File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (57 lines) | stat: -rw-r--r-- 1,897 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
summary: Ensure network retry works correctly

details: |
    Snapd has certain capability to retry failed network operations, as network
    in never perfectly reliable. The test creates an environment where the DNS
    system is broken, attempts to install a snap from the store, fixes the DNS
    environment and ensures that the snap is installed correctly.

environment:
    # on core systems, the test was seen to misbehave when memory limit is set
    SNAPD_NO_MEMORY_LIMIT: 1

prepare: |
    echo "Break DNS"
    if os.query is-core; then
       resolvConf=$(realpath /etc/resolv.conf)
       mv "${resolvConf}" "${resolvConf}.save"
       echo "${resolvConf}" > resolvConf.txt
    else
        mv /etc/resolv.conf /etc/resolv.conf.save
    fi
    systemctl stop snapd.service
    if systemctl is-active systemd-resolved; then
        systemctl stop systemd-resolved
        touch resolved.active
    fi

restore: |
    echo "Unbreak DNS"
    if os.query is-core; then
       resolvConf=$(cat resolvConf.txt)
       mv "${resolvConf}.save" "${resolvConf}"
    else
       mv /etc/resolv.conf.save /etc/resolv.conf
    fi
    if [ -e resolved.active ]; then
        systemctl start systemd-resolved
    fi
    systemctl stop snapd.service

execute: |
    if [ -n "${http_proxy:-}" ] || [ -n "${https_proxy:-}" ] ||
       [ -n "${HTTPS_PROXY:-}" ] || [ -n "${HTTPS_PROXY:-}" ]; then
       # all queries will go through the proxy so breaking DNS will not work
       echo "SKIP: cannot run when there is a http proxy set"
       exit 0
    fi

    echo "Try to install a snap with broken DNS"
    if snap install test-snapd-sh; then
        echo "Installing test-snapd-sh with broken DNS should not work"
        echo "Test broken"
        exit 1
    fi

    echo "Ensure we tried to retry this operation"
    "$TESTSTOOLS"/journal-state match-log 'Retrying because of temporary net error'