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 (76 lines) | stat: -rw-r--r-- 2,375 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
summary: Check that preseeded chroot can be re-set.

details: |
  This test checks that preseeding of Ubuntu cloud images with snap-preseed
  can be undone with --reset flag.

# Ubuntu 24.04: there is no longer any seeded snaps in base or minimal cloud images
# https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/2051346
# https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/2051572
systems: [ubuntu-20*, ubuntu-22*, ubuntu-23*]

environment:
  IMAGE_MOUNTPOINT: /mnt/cloudimg

prepare: |
  # shellcheck source=tests/lib/image.sh
  . "$TESTSLIB"/image.sh

  # the get_image_url_for_vm is a convenient helper that returns
  # a cloud image url matching current $SPREAD_SYSTEM.
  wget --quiet "$(get_image_url_for_vm)" -O cloudimg.img
  mkdir -p "$IMAGE_MOUNTPOINT"

  #shellcheck source=tests/lib/preseed.sh
  . "$TESTSLIB/preseed.sh"

  mount_ubuntu_image "$(pwd)/cloudimg.img" "$IMAGE_MOUNTPOINT"

  # for images that are already preseeded, we need to undo the preseeding there
  echo "Running preseed --reset for already preseeded cloud images"
  SNAPD_DEBUG=1 /usr/lib/snapd/snap-preseed --reset "$IMAGE_MOUNTPOINT"

restore: |
  rm -f before-preseeding.txt
  rm -f after-reset.txt

  #shellcheck source=tests/lib/preseed.sh
  . "$TESTSLIB/preseed.sh"
  umount_ubuntu_image "$IMAGE_MOUNTPOINT"

execute: |
  find_files() {
    find "$IMAGE_MOUNTPOINT/etc/" "$IMAGE_MOUNTPOINT/usr/" "$IMAGE_MOUNTPOINT/var/"
  }

  find_files > before-preseeding.txt

  echo "Running pre-seeding"
  /usr/lib/snapd/snap-preseed "$IMAGE_MOUNTPOINT"

  echo "Running preseeding again should fail"
  if OUT=$(/usr/lib/snapd/snap-preseed "$IMAGE_MOUNTPOINT" 2>&1); then
    echo "Expected snap-preseed to fail"
    exit 1
  fi
  echo "$OUT" | MATCH "the system at \"$IMAGE_MOUNTPOINT\" appears to be preseeded"

  echo "Resetting"
  /usr/lib/snapd/snap-preseed --reset "$IMAGE_MOUNTPOINT"

  echo "Checking that there are no leftovers"
  find_files > after-reset.txt
  diff before-preseeding.txt after-reset.txt

  if [ -d "$IMAGE_MOUNTPOINT/snap" ]; then
    echo "$IMAGE_MOUNTPOINT/snap shouldn't exist"
    exit 1
  fi

  echo "Running preseeding again should succeed"
  /usr/lib/snapd/snap-preseed "$IMAGE_MOUNTPOINT"

  echo "And running snap-preseed with a relative path works"
  cd /mnt
  /usr/lib/snapd/snap-preseed --reset cloudimg
  /usr/lib/snapd/snap-preseed cloudimg