Merge pull request #1121 from CarlosNihelton/ft-test-lxd-local
Enables preserving existing container instances.
This commit is contained in:
commit
fe9caa4715
|
@ -2,34 +2,40 @@
|
||||||
set -eux
|
set -eux
|
||||||
IMAGE=$1
|
IMAGE=$1
|
||||||
SCRIPT=$2
|
SCRIPT=$2
|
||||||
|
TESTER=subiquity-${IMAGE##*:}
|
||||||
|
|
||||||
lxd init --auto
|
lxd init --auto
|
||||||
|
|
||||||
lxc launch $IMAGE tester
|
if [ -z "$(lxc list -f csv -c n ^${TESTER}\$)" ]
|
||||||
lxc config device add tester code disk source=`pwd` path=/subiquity
|
then
|
||||||
|
lxc launch $IMAGE $TESTER
|
||||||
|
lxc config device add $TESTER code disk source=`pwd` path=/subiquity
|
||||||
|
else
|
||||||
|
lxc start $TESTER
|
||||||
|
fi
|
||||||
# copy is allowed to fail, in case the subiquity directory being tested
|
# copy is allowed to fail, in case the subiquity directory being tested
|
||||||
# includes some uncopyable stuff
|
# includes some uncopyable stuff
|
||||||
lxc exec tester -- sh -ec "
|
lxc exec $TESTER -- sh -ec "
|
||||||
cd ~
|
cd ~
|
||||||
sudo cp -a /subiquity . || true
|
sudo cp -a /subiquity . || true
|
||||||
[ -d ~/subiquity ]
|
[ -d ~/subiquity ]
|
||||||
"
|
"
|
||||||
|
|
||||||
attempts=0
|
attempts=0
|
||||||
while ! lxc file pull tester/etc/resolv.conf - 2> /dev/null | grep -q ^nameserver; do
|
while ! lxc file pull $TESTER/etc/resolv.conf - 2> /dev/null | grep -q ^nameserver; do
|
||||||
sleep 1
|
sleep 1
|
||||||
attempts=$((attempts+1))
|
attempts=$((attempts+1))
|
||||||
if [ $attempts -gt 30 ]; then
|
if [ $attempts -gt 30 ]; then
|
||||||
lxc file pull tester/etc/resolv.conf
|
lxc file pull $TESTER/etc/resolv.conf
|
||||||
lxc exec tester -- ps aux
|
lxc exec $TESTER -- ps aux
|
||||||
echo "Network failed to come up after 30 seconds"
|
echo "Network failed to come up after 30 seconds"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if ! lxc file pull tester/etc/resolv.conf - 2> /dev/null | grep ^nameserver | grep -qv 127.0.0.53
|
if ! lxc file pull $TESTER/etc/resolv.conf - 2> /dev/null | grep ^nameserver | grep -qv 127.0.0.53
|
||||||
then
|
then
|
||||||
echo "systemd-resolved"
|
echo "systemd-resolved"
|
||||||
while ! lxc file pull tester/run/systemd/resolve/resolv.conf - 2> /dev/null | grep -v fe80 | grep -q ^nameserver; do
|
while ! lxc file pull $TESTER/run/systemd/resolve/resolv.conf - 2> /dev/null | grep -v fe80 | grep -q ^nameserver; do
|
||||||
sleep 1
|
sleep 1
|
||||||
attempts=$((attempts+1))
|
attempts=$((attempts+1))
|
||||||
if [ $attempts -gt 30 ]; then
|
if [ $attempts -gt 30 ]; then
|
||||||
|
@ -39,9 +45,11 @@ then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lxc exec tester -- cloud-init status --wait
|
lxc exec $TESTER -- cloud-init status --wait
|
||||||
|
|
||||||
lxc exec tester -- sh -ec "
|
lxc exec $TESTER -- sh -ec "
|
||||||
cd ~/subiquity
|
cd ~/subiquity
|
||||||
./scripts/installdeps.sh
|
./scripts/installdeps.sh
|
||||||
$SCRIPT"
|
$SCRIPT"
|
||||||
|
|
||||||
|
lxc stop $TESTER
|
||||||
|
|
Loading…
Reference in New Issue