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 (33 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download
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
summary: Verify pprof endpoints are accessible to the tooling

details: |
    pprof is go a tool for visualization and analysis of profiling data.

    This test checks that the pprof profiles can be accessed through
    the http://localhost/v2/debug/pprof/ API

systems:
    # ubuntu-core: no jq and no go
    - -ubuntu-core-*
    # Go packaging issue affecting openSUSE
    # https://warthogs.atlassian.net/browse/SNAPDENG-35300
    # https://bugzilla.suse.com/show_bug.cgi?id=1233357
    - -opensuse-tumbleweed-*

execute: |
    # endpoints are accessible only for the root user
    su -c 'snap debug api /v2/debug/pprof/cmdline' test > unauthorized
    MATCH "login-required" <<<"$(gojq '.result.kind' unauthorized)"

    # one of pprof endpoints exposes a cmdline of the process
    snap debug api /v2/debug/pprof/cmdline > reported-cmdline
    # should be the same as in /proc/<pid>/cmdline
    mainpid=$(systemctl show -p MainPID snapd.service | cut -f2 -d=)
    tr -d '\0' < "/proc/$mainpid/cmdline" > real-cmdline
    diff -up <(od -c real-cmdline) <(od -c reported-cmdline)

    # try to fetch a heap profile
    snap debug api /v2/debug/pprof/heap > heap

    # go tool pprof fails if profile is corrupted
    go tool pprof -raw ./heap