-
Notifications
You must be signed in to change notification settings - Fork 72
/
spread.yaml
232 lines (206 loc) · 8.06 KB
/
spread.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
project: charmcraft
path: /charmcraft
environment:
PROJECT_PATH: /charmcraft
SNAPD_TESTING_TOOLS: $PROJECT_PATH/tools/external/tools
PATH: /snap/bin:$PATH:$SNAPD_TESTING_TOOLS
CRAFT_DEBUG: 1 # Show exception tracebacks.
CRAFT_VERBOSITY_LEVEL: debug # Show debugging output when failing.
# Use the staging store for tests:
CHARMCRAFT_STORE_API_URL: https://api.staging.charmhub.io
CHARMCRAFT_UPLOAD_URL: https://storage.staging.snapcraftcontent.com
CHARMCRAFT_REGISTRY_URL: https://registry.staging.jujucharms.com
exclude:
- .git
- .github
- .tox
- .venv
- .*_cache
backends:
google:
key: '$(HOST: echo "$SPREAD_GOOGLE_KEY")'
location: snapd-spread/us-east1-b
halt-timeout: 2h
systems:
- ubuntu-18.04-64:
workers: 1
storage: 40G
- ubuntu-20.04-64:
workers: 3
storage: 40G
- ubuntu-22.04-64:
workers: 6
storage: 40G
multipass:
type: adhoc
allocate: |
sleep 0.$RANDOM # Minimize chances of a race condition
mkdir -p $HOME/.spread
export counter_file="$HOME/.spread/multipass-count"
instance_num=$(flock -x $counter_file bash -c '
[ -s $counter_file ] || echo 0 > $counter_file
num=$(< $counter_file)
echo $num
echo $(( $num + 1 )) > $counter_file')
multipass_image=$(echo ${SPREAD_SYSTEM} | sed -e s/ubuntu-// -e s/-64//)
system=$(echo "${SPREAD_SYSTEM}" | tr . -)
instance_name="spread-${SPREAD_BACKEND}-${instance_num}-${system}"
multipass launch --cpus 2 --disk 20G --memory 2G --name "${instance_name}" "${multipass_image}"
# Enable PasswordAuthentication for root over SSH.
multipass exec "$instance_name" -- \
sudo sh -c "echo root:${SPREAD_PASSWORD} | sudo chpasswd"
multipass exec "$instance_name" -- \
sudo sh -c \
"if [ -d /etc/ssh/sshd_config.d/ ]
then
echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config.d/10-spread.conf
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config.d/10-spread.conf
else
sed -i /etc/ssh/sshd_config -E -e 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/' -e 's/^#?PermitRootLogin.*/PermitRootLogin yes/'
fi"
multipass exec "$instance_name" -- \
sudo systemctl restart ssh
# Get the IP from the instance
ip=$(multipass info --format csv "$instance_name" | tail -1 | cut -d\, -f3)
ADDRESS "$ip"
discard: |
instance_name=$(multipass list --format csv | grep $SPREAD_SYSTEM_ADDRESS | cut -f1 -d\,)
multipass delete --purge "${instance_name}"
systems:
- ubuntu-18.04-64:
workers: 1
- ubuntu-20.04-64:
workers: 1
- ubuntu-22.04-64:
workers: 4
prepare: |
set -e
# if the 'tools' directory inside the submodule does not exist, then assume the submodule is empty
if [[ ! -d "$SNAPD_TESTING_TOOLS" ]]; then
echo "Cannot run spread because submodule 'snapd-testing-tools' is empty. Fetch with 'git submodule update --init' and rerun spread."
exit 1
fi
if os.query is-ubuntu; then
tempfile="$(mktemp)"
if ! apt-get update > "$tempfile" 2>&1; then
cat "$tempfile"
exit 1
fi
fi
tests.pkgs install snapd
tests.pkgs install unzip
snap wait system seed.loaded
# The /snap directory does not exist in some environments
[ ! -d /snap ] && ln -s /var/lib/snapd/snap /snap
# install lxd (previously removing the APT version, if there)
[ -e /usr/bin/lxd ] && apt-get remove --purge --yes lxd lxd-client lxcfs liblxc1
snap install lxd
# Hold snap refreshes for 24h.
snap set system refresh.hold="$(date --date=tomorrow +%Y-%m-%dT%H:%M:%S%:z)"
if ! snap watch --last=auto-refresh?; then
journalctl -xe
fi
if ! snap watch --last=install?; then
journalctl -xe
fi
lxd waitready --timeout=30
lxd init --auto
#shellcheck source=tests/spread/tools/prepare.sh
. "/charmcraft/tests/spread/tools/prepare.sh"
install_charmcraft
suites:
tests/spread/commands/:
summary: simple charmcraft commands
tests/spread/charms/:
summary: real charm building tests
prepare: |
snap install juju --channel=3.2/stable
snap install microk8s --channel=1.28-strict/stable
# Set up Juju controllers for the charms
lxc network set lxdbr0 ipv6.address none
mkdir -p ~/.local/share # Workaround for Juju not being able to create the directory
microk8s enable hostpath-storage
microk8s enable dns
snap alias microk8s.kubectl kubectl
if ! juju controllers | grep -q k8s; then
juju bootstrap microk8s k8s
fi
if ! juju controllers | grep -q lxd; then
juju bootstrap localhost lxd
fi
prepare-each: |
if [[ -v JUJU_MODEL ]] && ! juju add-model "${JUJU_MODEL}"; then
juju destroy-model --force --no-prompt --destroy-storage "${JUJU_MODEL}" || true
juju add-model "${JUJU_MODEL}"
fi
restore-each: |
if [[ -v JUJU_MODEL ]]; then
juju destroy-model --no-prompt --force --destroy-storage $JUJU_MODEL
fi
rm -f ~/*.charm
tests/spread/dependencies/:
summary: test charm dependencies
systems:
- ubuntu-22.04-64
kill-timeout: 60m # Setting up Juju can take a while.
priority: 50 # Because setting up Juju takes a while, do these first.
prepare: |
snap install juju --channel=3.2/stable
# Set up Juju controllers for the charms
lxc network set lxdbr0 ipv6.address none
mkdir -p ~/.local/share # Workaround for Juju not being able to create the directory
if ! juju controllers | grep -q lxd; then
juju bootstrap localhost lxd
fi
prepare-each: |
if [[ -v JUJU_MODEL ]] && ! juju add-model "${JUJU_MODEL}"; then
juju destroy-model --force --no-prompt --destroy-storage "${JUJU_MODEL}" || true
juju add-model "${JUJU_MODEL}"
fi
restore-each: |
if [[ -v JUJU_MODEL ]]; then
juju destroy-model --no-prompt --force --no-wait --timeout 15s --destroy-storage $JUJU_MODEL
fi
rm -f ~/*.charm
rm -rf charm
tests/spread/smoketests/:
summary: basic charm builds in different combinations
systems:
- ubuntu-20.04-64
- ubuntu-22.04-64
tests/spread/hooks/:
summary: snap hook tests
kill-timeout: 30m
tests/spread/store/:
prepare: |
snap install docker
# make sure docker is working
retry -n 10 --wait 2 sh -c 'docker run --rm hello-world'
# https://linuxcontainers.org/lxd/docs/master/howto/network_bridge_firewalld/#prevent-issues-with-lxd-and-docker
# https://github.com/canonical/lxd-cloud/blob/f20a64a8af42485440dcbfd370faf14137d2f349/test/includes/lxd.sh#L13-L23
iptables -P FORWARD ACCEPT
# Ensure that the reused charms are registered if necessary.
if ! charmcraft status "${CHARM_DEFAULT_NAME}"; then
charmcraft register $CHARM_DEFAULT_NAME
fi
rm -f charmcraft.yaml
restore: |
snap remove docker --purge
summary: sequence of commands for different store-related functionalities
kill-timeout: 30m
manual: true
systems:
- ubuntu-22.04-64
environment:
# the content for this key is the content of FILE after running
# charmcraft login --export=FILE --ttl=5184000#
# (as the owner of CHARM_DEFAULT_NAME and BUNDLE_DEFAULT_NAME below), and it
# should be part of the environment (when running spread locally just define it,
# for GH actions set it in Settings -> Security -> Actions -> Repository secrets)
CHARMCRAFT_AUTH: "$(HOST: echo $CHARMCRAFT_AUTH)"
CHARMCRAFT_SINGLE_CHARM_AUTH: "$(HOST: echo $CHARMCRAFT_SINGLE_CHARM_AUTH)"
# to not flood Charmhub with names the same two are always used in the Store related
# tests (except in the names registration tests, of course); register them manually
# in staging Charmhub authenticating with the configured credentials
CHARM_DEFAULT_NAME: "$(HOST: echo ${CHARM_DEFAULT_NAME:-$USER-test-charm})"
BUNDLE_DEFAULT_NAME: "$(HOST: echo ${BUNDLE_DEFAULT_NAME:-$USER-test-bundle})"