-
Notifications
You must be signed in to change notification settings - Fork 494
/
deploy_bundles.sh
274 lines (208 loc) · 9.01 KB
/
deploy_bundles.sh
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
run_deploy_bundle() {
echo
file="${TEST_DIR}/test-bundles-deploy.log"
ensure "test-bundles-deploy" "${file}"
juju deploy juju-qa-bundle-test
wait_for "juju-qa-test" ".applications | keys[0]"
wait_for "ntp" "$(idle_subordinate_condition "ntp" "juju-qa-test")"
destroy_model "test-bundles-deploy"
}
run_deploy_bundle_overlay() {
echo
file="${TEST_DIR}/test-bundles-deploy-overlay.log"
ensure "test-bundles-deploy-overlay" "${file}"
bundle=./tests/suites/deploy/bundles/overlay_bundle.yaml
juju deploy ${bundle}
wait_for "ubuntu" "$(idle_condition "ubuntu" 0 0)"
wait_for "ubuntu" "$(idle_condition "ubuntu" 0 1)"
destroy_model "test-bundles-deploy-overlay"
}
run_deploy_cmr_bundle() {
echo
file="${TEST_DIR}/test-cmr-bundles-deploy.log"
ensure "test-cmr-bundles-deploy" "${file}"
juju deploy easyrsa
wait_for "easyrsa" ".applications | keys[0]"
juju offer easyrsa:client
juju add-model other
juju switch other
bundle=./tests/suites/deploy/bundles/cmr_bundles_test_deploy.yaml
sed "s/{{BOOTSTRAPPED_JUJU_CTRL_NAME}}/${BOOTSTRAPPED_JUJU_CTRL_NAME}/g" "${bundle}" >"${TEST_DIR}/cmr_bundles_test_deploy.yaml"
# TODO - upgrade this bundle to use focal
# Must wait until the wordpress charm is updated to support focal/jammy
# https://charmhub.io/wordpress
juju deploy "${TEST_DIR}/cmr_bundles_test_deploy.yaml"
wait_for "etcd" "$(idle_condition "etcd")"
destroy_model "test-cmr-bundles-deploy"
destroy_model "other"
}
# run_deploy_exported_charmhub_bundle_with_fixed_revisions tests how juju deploys
# a charmhub bundle that specifies revisions for its charms
run_deploy_exported_charmhub_bundle_with_fixed_revisions() {
echo
file="${TEST_DIR}/test-export-bundles-deploy-with-fixed-revisions.log"
ensure "test-export-bundles-deploy-with-fixed-revisions" "${file}"
bundle=./tests/suites/deploy/bundles/telegraf_bundle.yaml
juju deploy ${bundle}
echo "Make a copy of reference yaml"
cp ${bundle} "${TEST_DIR}/telegraf_bundle.yaml"
if [[ -n ${MODEL_ARCH:-} ]]; then
yq -i "
.machines.\"0\".constraints = \"arch=${MODEL_ARCH}\" |
.machines.\"1\".constraints = \"arch=${MODEL_ARCH}\"
" "${TEST_DIR}/telegraf_bundle.yaml"
else
yq -i . "${TEST_DIR}/telegraf_bundle.yaml"
fi
# no need to wait for the bundle to finish deploying to
# check the export.
echo "Compare export-bundle with telegraf_bundle"
juju export-bundle --filename "${TEST_DIR}/exported_bundle.yaml"
yq -i . "${TEST_DIR}/exported_bundle.yaml"
diff -u "${TEST_DIR}/telegraf_bundle.yaml" "${TEST_DIR}/exported_bundle.yaml"
destroy_model "test-export-bundles-deploy-with-fixed-revisions"
}
# run_deploy_exported_charmhub_bundle_with_float_revisions checks how juju
# deploys a charmhub bundle when the revisions are not pinned
run_deploy_exported_charmhub_bundle_with_float_revisions() {
echo
file="${TEST_DIR}/test-export-bundles-deploy-with-float-revisions.log"
ensure "test-export-bundles-deploy-with-float-revisions" "${file}"
bundle=./tests/suites/deploy/bundles/telegraf_bundle_without_revisions.yaml
bundle_with_fake_revisions=./tests/suites/deploy/bundles/telegraf_bundle_with_fake_revisions.yaml
juju deploy ${bundle}
echo "Create telegraf_bundle_without_revisions.yaml with known latest revisions from charmhub"
influxdb_rev=$(juju info influxdb --format json | jq -r '."channel-map"."latest/stable".revision')
telegraf_rev=$(juju info telegraf --format json | jq -r '."channel-map"."latest/stable".revision')
ubuntu_rev=$(juju info ubuntu --format json | jq -r '."channel-map"."latest/stable".revision')
echo "Make a copy of reference yaml and insert revisions in it"
cp ${bundle_with_fake_revisions} "${TEST_DIR}/telegraf_bundle_with_revisions.yaml"
yq -i "
.applications.influxdb.revision = ${influxdb_rev} |
.applications.telegraf.revision = ${telegraf_rev} |
.applications.ubuntu.revision = ${ubuntu_rev}
" "${TEST_DIR}/telegraf_bundle_with_revisions.yaml"
if [[ -n ${MODEL_ARCH:-} ]]; then
yq -i "
.machines.\"0\".constraints = \"arch=${MODEL_ARCH}\" |
.machines.\"1\".constraints = \"arch=${MODEL_ARCH}\"
" "${TEST_DIR}/telegraf_bundle_with_revisions.yaml"
fi
# The model should be updated immediately, so we can export the bundle before
# everything is done deploying
echo "Compare export-bundle with telegraf_bundle_with_revisions"
juju export-bundle --filename "${TEST_DIR}/exported_bundle.yaml"
# reformat the yaml to have the same format as telegraf_bundle_with_revisions.yaml
yq -i . "${TEST_DIR}/exported_bundle.yaml"
diff -u "${TEST_DIR}/telegraf_bundle_with_revisions.yaml" "${TEST_DIR}/exported_bundle.yaml"
destroy_model "test-export-bundles-deploy-with-float-revisions"
}
run_deploy_trusted_bundle() {
echo
file="${TEST_DIR}/test-trusted-bundles-deploy.log"
ensure "test-trusted-bundles-deploy" "${file}"
# TODO - upgrade the charm to support focal
bundle=./tests/suites/deploy/bundles/trusted_bundle.yaml
OUT=$(juju deploy ${bundle} 2>&1 || true)
echo "${OUT}" | check "repeat the deploy command with the --trust argument"
juju deploy --trust ${bundle} --force # TODO: remove --force once "juju-qa-trust-checker" supports jammy.
wait_for "trust-checker" "$(idle_condition "trust-checker")"
destroy_model "test-trusted-bundles-deploy"
}
run_deploy_charmhub_bundle() {
echo
model_name="test-charmhub-bundle-deploy"
file="${TEST_DIR}/${model_name}.log"
ensure "${model_name}" "${file}"
bundle=juju-qa-bundle-test
juju deploy "${bundle}"
wait_for "juju-qa-test" "$(charm_channel "juju-qa-test" "2.0/stable")"
wait_for "juju-qa-test-focal" "$(charm_channel "juju-qa-test-focal" "latest/candidate")"
wait_for "juju-qa-test" "$(idle_condition "juju-qa-test")"
wait_for "juju-qa-test-focal" "$(idle_condition "juju-qa-test-focal" 1)"
wait_for "ntp" "$(idle_subordinate_condition "ntp" "juju-qa-test")"
wait_for "ntp-focal" "$(idle_subordinate_condition "ntp-focal" "juju-qa-test-focal")"
destroy_model "${model_name}"
}
# run_deploy_lxd_profile_bundle_openstack is to test a more
# real world scenario of a minimal openstack bundle with a
# charm using an lxd profile.
run_deploy_lxd_profile_bundle_openstack() {
echo
model_name="test-deploy-lxd-profile-bundle-o7k"
file="${TEST_DIR}/${model_name}.log"
ensure "${model_name}" "${file}"
bundle=./tests/suites/deploy/bundles/basic-openstack.yaml
juju deploy "${bundle}"
wait_for "mysql" "$(idle_condition "mysql" 2)"
wait_for "rabbitmq-server" "$(idle_condition "rabbitmq-server" 8)"
wait_for "glance" "$(idle_condition "glance" 0)"
wait_for "keystone" "$(idle_condition "keystone" 1)"
wait_for "neutron-api" "$(idle_condition "neutron-api" 3)"
wait_for "neutron-gateway" "$(idle_condition "neutron-gateway" 4)"
wait_for "nova-compute" "$(idle_condition "nova-compute" 7)"
wait_for "neutron-openvswitch" "$(idle_subordinate_condition "neutron-openvswitch" "nova-compute")"
wait_for "nova-cloud-controller" "$(idle_condition "nova-cloud-controller" 6)"
lxd_profile_name="juju-${model_name}-neutron-openvswitch"
machine_6="$(machine_path 6)"
juju status --format=json | jq "${machine_6}" | check "${lxd_profile_name}"
destroy_model "${model_name}"
}
# run_deploy_lxd_profile_bundle is to deploy multiple units of the
# same charm which has an lxdprofile in a bundle. The scenario
# created by the bundle was found to produce failure cases during
# development of the lxd profile feature.
run_deploy_lxd_profile_bundle() {
echo
model_name="test-deploy-lxd-profile-bundle"
file="${TEST_DIR}/${model_name}.log"
ensure "${model_name}" "${file}"
bundle=./tests/suites/deploy/bundles/lxd-profile-bundle.yaml
# TODO - upgrade the charm to support focal
juju deploy "${bundle}"
# 8 units of lxd-profile
for i in 0 1 2 3 4 5 6 7; do
wait_for "lxd-profile" "$(idle_condition "lxd-profile" 0 "${i}")"
done
# 4 units of ubuntu
for i in 0 1 2 3; do
wait_for "ubuntu" "$(idle_condition "ubuntu" 1 "${i}")"
done
lxd_profile_name="juju-${model_name}-lxd-profile"
for i in 0 1 2 3; do
machine_n_lxd0="$(machine_container_path "${i}" "${i}"/lxd/0)"
juju status --format=json | jq "${machine_n_lxd0}" | check "${lxd_profile_name}"
machine_n_lxd1="$(machine_container_path "${i}" "${i}"/lxd/1)"
juju status --format=json | jq "${machine_n_lxd1}" | check "${lxd_profile_name}"
done
destroy_model "${model_name}"
}
test_deploy_bundles() {
if [ "$(skip 'test_deploy_bundles')" ]; then
echo "==> TEST SKIPPED: deploy bundles"
return
fi
(
set_verbosity
cd .. || exit
run "run_deploy_bundle"
run "run_deploy_bundle_overlay"
run "run_deploy_exported_charmhub_bundle_with_fixed_revisions"
run "run_deploy_exported_charmhub_bundle_with_float_revisions"
run "run_deploy_trusted_bundle"
run "run_deploy_charmhub_bundle"
case "${BOOTSTRAP_PROVIDER:-}" in
"lxd" | "localhost")
run "run_deploy_lxd_profile_bundle_openstack"
run "run_deploy_lxd_profile_bundle"
;;
*)
echo "==> TEST SKIPPED: deploy_lxd_profile_bundle_openstack - tests for LXD only"
echo "==> TEST SKIPPED: deploy_lxd_profile_bundle - tests for LXD only"
;;
esac
# Run this last so the other tests run, there are intermittent issues
# in cmr tear down.
run "run_deploy_cmr_bundle"
)
}