#!/bin/bash

set -ex

export no_proxy=10.0.8.1,$no_proxy

# For the future- tests, we can't really make a 'yenial' image to launch from
# lxd, and the default will be the LTS anyway. So, treat this as a test of
# using the next development release spawning xenial lxd machines.
# TODO: This needs something fancier for backporting to earlier series.
SERIES=xenial

echo "Prepopulating lxd with daily $SERIES image: "
lxc image copy ubuntu-daily:$SERIES local: --alias ubuntu-$SERIES

echo "Testing juju bootstrap: "
juju bootstrap my-controller lxd --upload-tools --debug --config default-series=$SERIES
echo "OK"

echo "Waiting for environment to bootstrap: "
juju status --debug -m admin
juju status --debug
echo "OK"

echo "Destroying environment: "
juju destroy-controller --debug --yes my-controller
echo "OK"
