-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from ajkavanagh/integration-test-in-vm
Add integration tests that can run on fresh vm with LXD
- Loading branch information
Showing
5 changed files
with
80 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
_dir="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)" | ||
_release=$(lsb_release -cs) | ||
|
||
sudo apt-get update | ||
sudo apt-get install -y tox python3-dev libssl-dev libffi-dev build-essential | ||
|
||
lxc config set core.trust_password password | ||
lxc config set core.https_address [::] | ||
|
||
if [[ "${_release}" == "bionic" ]]; then | ||
# force generation of client certificate to an address that doesn't work (http) | ||
# generate an openssl certificate and key for the remote not verified test | ||
mkdir -p $HOME/.config/lxc | ||
openssl genrsa 1024 > $HOME/.config/lxc/client.key | ||
chmod 400 $HOME/.config/lxc/client.key | ||
|
||
openssl req -new -x509 -nodes -sha1 -days 365 \ | ||
-key $HOME/.config/lxc/client.key -out $HOME/.config/lxc/client.crt \ | ||
-subj="/C=UK/ST=London/L=London/O=OrgName/OU=Test/CN=example.com" | ||
|
||
# create a default dir storage pool for bionic | ||
lxc storage create default dir | ||
lxc profile device add default root disk path=/ pool=default | ||
echo "Run 18.04 (bionic) integration tests" | ||
else | ||
echo "Run 16.04 (xenial) integration tests" | ||
fi | ||
|
||
# finally run the integration tests | ||
tox -e integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# This script runs the integration tests on an already configured LXD machine | ||
# where the tests are run LXD in LXD. i.e. an LXD container is spawned, pylxd | ||
# is copied into the container, and then the container runs the integration | ||
# tests. | ||
|
||
# This script is NOT used by the CI system, but for people to run integration | ||
# tests on their own computers where they don't want the integration test to | ||
# mess with their setup. | ||
|
||
set -ex | ||
|
||
_dir="$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)" | ||
|
||
function _run_tests { | ||
local _target=${1} | ||
CONTAINER_NAME=pylxd-`uuidgen | cut -d"-" -f1` | ||
|
||
if [[ "${_target}" == "bionic" ]]; then | ||
echo "Running Bionic (18:04) integration tests" | ||
CONTAINER_IMAGE="ubuntu:18.04" | ||
else | ||
echo "Running Xenial (16:04) integration tests" | ||
CONTAINER_IMAGE="ubuntu:16.04" | ||
fi | ||
|
||
# This creates a privileged container, because I was bumping into situations where it | ||
# seemed that we had maxed out user namespaces (I haven't checked it out, but it's likely | ||
# a bug in LXD). | ||
lxc launch $CONTAINER_IMAGE $CONTAINER_NAME -c security.nesting=true -c security.privileged=true | ||
sleep 5 # Wait for the network to come up | ||
|
||
lxc exec $CONTAINER_NAME -- mkdir -p /opt/pylxd | ||
# NOTE: rockstar (13 Sep 2016) - --recursive is not supported in lxd <2.1, so | ||
# until we have pervasive support for that, we'll do this tar hack. | ||
local ldir="${_dir}/.." | ||
cd ${ldir} && tar cf - * .git | lxc exec $CONTAINER_NAME -- tar xf - -C /opt/pylxd | ||
cd ${_dir} | ||
lxc exec $CONTAINER_NAME -- /bin/sh -c "cd /opt/pylxd && integration/run-integration-tests" | ||
|
||
lxc delete --force $CONTAINER_NAME | ||
} | ||
|
||
# run xenial and then bionic integration tests | ||
_run_tests xenial | ||
_run_tests bionic |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.