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
|
#!/bin/sh
set -ex
#######################################################################
p='r'
pkg=ruby-defaults
native_arch=$(dpkg --print-architecture)
max_wait=30
#######################################################################
export DEBIAN_FRONTEND=noninteractive
echo 'debci_backend=fake' > /etc/debci/conf.d/backend.conf
if [ -n "$other_arch" ]; then
echo "debci_arch_list='$native_arch $other_arch'" > /etc/debci/conf.d/arch_list.conf
test_arch="$other_arch"
else
test_arch="$native_arch"
fi
apt-mark hold lxc
apt-get install -qy --no-install-recommends \
debci-collector debci-worker
if [ -n "$other_arch" ]; then
# start worker for other architecture. This is safe because we are using the
# "fake" backend, which does not _really_ run code; but we are testing that all
# other components work OK in a multi-architecture setup.
other_worker=/etc/systemd/system/debci-worker@2.service
ln -s /lib/systemd/system/debci-worker@.service $other_worker
mkdir ${other_worker}.d
cat > ${other_worker}.d/arch.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/debci worker --arch $other_arch
EOF
systemctl daemon-reload
systemctl start debci-worker@2.service
sleep 5s
# submit job for other architecture
debci enqueue --arch $other_arch $pkg
fi
debci enqueue $pkg
sleep 5s
# wait until all queues are empty
pending_jobs() {
rabbitmqctl list_queues | awk 'BEGIN { c = 0 } { if ($1 ~ /debci/) { c += $2 } } END { print(c) }'
}
waited=0
while [ "$(pending_jobs)" -ne 0 ] && [ $waited -lt $max_wait ]; do
sleep 1s
waited=$(($waited + 1))
done
sudo systemctl start debci-update.service
sleep 5s
set +ex
#######################################################################
data=/var/lib/debci/data
html=$data/.html
assertFileExists() {
local file_description="$1"
local filename="$2"
local waited=0
while [ ! -f "$filename" ] && [ "$waited" -lt "$max_wait" ]; do
sleep 1s
waited=$(($waited + 1))
done
assertTrue "missing $file_description ($filename); waited $max_wait seconds" \
"[ -f $filename ]"
}
test_has_global_status_file() {
assertFileExists 'global status file' \
"${data}/status/unstable/$test_arch/status.json"
}
test_has_global_package_status_file() {
assertFileExists 'global package status file' \
"${data}/status/unstable/$test_arch/packages.json"
}
. shunit2
|