forked from snapcore/snapd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.yaml
92 lines (72 loc) · 3.02 KB
/
task.yaml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
summary: Ensure that lxd works
# only run this on ubuntu 16+, lxd will not work on !ubuntu systems
# currently nor on ubuntu 14.04
systems: [ubuntu-16*, ubuntu-core-*]
# lxd downloads can be quite slow
kill-timeout: 25m
restore: |
if [[ $(ls -1 "$GOHOME"/snapd_*.deb | wc -l || echo 0) -eq 0 ]]; then
exit
fi
lxd.lxc stop my-ubuntu
lxd.lxc delete my-ubuntu
debug: |
# debug output from lxd
journalctl -u snap.lxd.daemon.service
execute: |
if [[ $(ls -1 "$GOHOME"/snapd_*.deb | wc -l || echo 0) -eq 0 ]]; then
echo "No run lxd test when there are not .deb files built"
exit
fi
wait_for_lxd(){
while ! printf "GET / HTTP/1.0\n\n" | nc -U /var/snap/lxd/common/lxd/unix.socket | MATCH "200 OK"; do sleep 1; done
}
echo "Install lxd"
snap install lxd
echo "Create a trivial container using the lxd snap"
wait_for_lxd
lxd init --auto
echo "Setting up proxy for lxc"
if [ -n "${http_proxy:-}" ]; then
lxd.lxc config set core.proxy_http $http_proxy
fi
if [ -n "${https_proxy:-}" ]; then
lxd.lxc config set core.proxy_https $http_proxy
fi
lxd.lxc launch ubuntu:16.04 my-ubuntu
echo "Ensure we can run things inside"
lxd.lxc exec my-ubuntu echo hello | MATCH hello
echo "Ensure we can get network"
lxd.lxc network create testbr0
lxd.lxc network attach testbr0 my-ubuntu eth0
lxd.lxc exec my-ubuntu dhclient eth0
echo "Cleanup container"
lxd.lxc exec my-ubuntu -- apt autoremove --purge -y snapd ubuntu-core-launcher
echo "Install snapd"
lxd.lxc exec my-ubuntu -- mkdir -p "$GOHOME"
lxd.lxc file push "$GOHOME"/snapd_*.deb my-ubuntu/$GOPATH/
lxd.lxc exec my-ubuntu -- dpkg -i "$GOHOME"/snapd_*.deb
echo "Setting up proxy *inside* the container"
if [ -n "${http_proxy:-}" ]; then
lxd.lxc exec my-ubuntu -- sh -c "echo http_proxy=$http_proxy >> /etc/environment"
fi
if [ -n "${https_proxy:-}" ]; then
lxd.lxc exec my-ubuntu -- sh -c "echo https_proxy=$https_proxy >> /etc/environment"
fi
lxd.lxc exec my-ubuntu -- systemctl daemon-reload
lxd.lxc exec my-ubuntu -- systemctl restart snapd.service
lxd.lxc exec my-ubuntu -- cat /etc/environment
# FIXME: workaround for missing squashfuse
lxd.lxc exec my-ubuntu apt update
lxd.lxc exec my-ubuntu -- apt install -y squashfuse
# FIXME: ensure that the kernel running is recent enough, this
# will only work with an up-to-date xenial kernel (4.4.0-78+)
echo "Ensure we can use snapd inside lxd"
lxd.lxc exec my-ubuntu snap install test-snapd-tools
echo "And we can run snaps as regular users"
lxd.lxc exec my-ubuntu -- su -c "/snap/bin/test-snapd-tools.echo from-the-inside" ubuntu | MATCH from-the-inside
echo "And as root"
lxd.lxc exec my-ubuntu -- test-snapd-tools.echo from-the-inside | MATCH from-the-inside
echo "Install lxd-demo server to exercise the lxd interface"
snap install lxd-demo-server
snap connect lxd-demo-server:lxd lxd:lxd