File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (60 lines) | stat: -rw-r--r-- 3,164 bytes parent folder | download | duplicates (2)
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
58
59
60
summary: Check that snap timer services work

details: |
    A snap service may define a timer declaring when the service must
    be run automatically. Those timers translate to systemd timer
    units.

    This test verifies that the installation of a snap with timers, or
    enabling of the snap, will create corresponding systemd timer. It
    will also verify that removal or disabling of the snap will also
    remove the timer units.

execute: |
    echo "When the service snap is installed"
    "$TESTSTOOLS"/snaps-state install-local test-snapd-timer-service

    echo "We can see the timers being active"
    for service in regular-timer random-timer range-timer trivial-timer; do
        systemctl show -p ActiveState snap.test-snapd-timer-service.$service.timer | MATCH "ActiveState=active"
        systemctl show -p SubState snap.test-snapd-timer-service.$service.timer | MATCH "SubState=(waiting|running)"
        systemctl show -p Triggers snap.test-snapd-timer-service.$service.timer | \
            MATCH "snap.test-snapd-timer-service.$service.service"
        systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled"
    done
    # systemctl list-timers output:
    # NEXT                         LEFT          LAST                         PASSED        UNIT                                        ACTIVATES
    # Fri 2018-02-23 11:00:00 CET  3min 25s left Fri 2018-02-23 10:45:36 CET  10min ago     snap.timer-service-snap.regular-timer.timer snap.timer-service-snap.regular-timer.service
    # Fri 2018-02-23 11:01:00 CET  4min 25s left Fri 2018-02-23 10:51:36 CET  4min 58s ago  snap.timer-service-snap.random-timer.timer  snap.timer-service-snap.random-timer.service
    echo "When disabled, times are not listed by systemd"
    snap disable test-snapd-timer-service
    if os.query is-trusty; then
        for service in regular-timer random-timer range-timer trivial-timer; do
            systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
        done
    else
        systemctl list-timers | NOMATCH "test-snapd-timer-service"
    fi

    echo "When reenabled, the timers are present again"
    snap enable test-snapd-timer-service
    if os.query is-trusty; then
        for service in regular-timer random-timer range-timer trivial-timer; do
            systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState=enabled"
        done
    else
        systemctl list-timers | MATCH "test-snapd-timer-service"
    fi

    echo "When removed, times are not listed by systemd"
    snap remove --purge test-snapd-timer-service
    if os.query is-trusty; then
        for service in regular-timer random-timer range-timer trivial-timer; do
            systemctl show -p UnitFileState snap.test-snapd-timer-service.$service.timer | MATCH "UnitFileState="
        done
    else
        systemctl list-timers | NOMATCH "test-snapd-timer-service"
    fi

    echo "No timer files are left behind"
    test "$(find /etc/systemd/system -name 'snap.test-snapd-timer-service.*.timer' | wc -l)" -eq "0"