2018-02-28 00:42:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eux
|
|
|
|
IMAGE=$1
|
2018-05-24 22:43:11 +00:00
|
|
|
SCRIPT=$2
|
2021-11-09 21:20:41 +00:00
|
|
|
TESTER=subiquity-${IMAGE##*:}
|
2018-02-28 00:42:47 +00:00
|
|
|
|
|
|
|
lxd init --auto
|
|
|
|
|
2021-11-09 12:42:57 +00:00
|
|
|
if [ -z "$(lxc list -f csv -c n ^${TESTER}\$)" ]
|
2021-11-08 22:20:44 +00:00
|
|
|
then
|
|
|
|
lxc launch $IMAGE $TESTER
|
|
|
|
lxc config device add $TESTER code disk source=`pwd` path=/subiquity
|
|
|
|
else
|
|
|
|
lxc start $TESTER
|
|
|
|
fi
|
2021-06-07 20:36:37 +00:00
|
|
|
# copy is allowed to fail, in case the subiquity directory being tested
|
|
|
|
# includes some uncopyable stuff
|
2021-11-08 22:20:44 +00:00
|
|
|
lxc exec $TESTER -- sh -ec "
|
2021-06-07 20:36:37 +00:00
|
|
|
cd ~
|
|
|
|
sudo cp -a /subiquity . || true
|
|
|
|
[ -d ~/subiquity ]
|
|
|
|
"
|
2018-02-28 00:42:47 +00:00
|
|
|
|
|
|
|
attempts=0
|
2021-11-08 22:20:44 +00:00
|
|
|
while ! lxc file pull $TESTER/etc/resolv.conf - 2> /dev/null | grep -q ^nameserver; do
|
2018-02-28 00:42:47 +00:00
|
|
|
sleep 1
|
|
|
|
attempts=$((attempts+1))
|
|
|
|
if [ $attempts -gt 30 ]; then
|
2021-11-08 22:20:44 +00:00
|
|
|
lxc file pull $TESTER/etc/resolv.conf
|
|
|
|
lxc exec $TESTER -- ps aux
|
2018-02-28 00:42:47 +00:00
|
|
|
echo "Network failed to come up after 30 seconds"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2021-11-08 22:20:44 +00:00
|
|
|
if ! lxc file pull $TESTER/etc/resolv.conf - 2> /dev/null | grep ^nameserver | grep -qv 127.0.0.53
|
2018-02-28 00:42:47 +00:00
|
|
|
then
|
|
|
|
echo "systemd-resolved"
|
2021-11-08 22:20:44 +00:00
|
|
|
while ! lxc file pull $TESTER/run/systemd/resolve/resolv.conf - 2> /dev/null | grep -v fe80 | grep -q ^nameserver; do
|
2018-02-28 00:42:47 +00:00
|
|
|
sleep 1
|
|
|
|
attempts=$((attempts+1))
|
|
|
|
if [ $attempts -gt 30 ]; then
|
|
|
|
echo "Network failed to come up after 30 seconds"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-11-08 22:20:44 +00:00
|
|
|
lxc exec $TESTER -- cloud-init status --wait
|
2021-06-08 22:07:32 +00:00
|
|
|
|
2021-11-08 22:20:44 +00:00
|
|
|
lxc exec $TESTER -- sh -ec "
|
2021-06-07 20:36:37 +00:00
|
|
|
cd ~/subiquity
|
|
|
|
./scripts/installdeps.sh
|
|
|
|
$SCRIPT"
|
2021-11-08 22:20:44 +00:00
|
|
|
|
2021-11-09 21:20:41 +00:00
|
|
|
lxc stop $TESTER
|