From aaba1c643a89f8d212634e681a9c57ae7bc19e3b Mon Sep 17 00:00:00 2001 From: Damian Gerow Date: Thu, 4 May 2017 01:08:11 -0400 Subject: [PATCH] More thorough tests against Docker This doubles the number of LXC containers in use, but does provide a more thorough test of the Docker image. --- .travis.yml | 7 +++---- tests/local-deploy.sh | 12 ++++++++++++ tests/update-users.sh | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100755 tests/local-deploy.sh diff --git a/.travis.yml b/.travis.yml index 8e331e9b..5017a245 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,9 +35,10 @@ before_cache: env: - LXC_NAME=ubuntu1604 LXC_DISTRO=ubuntu LXC_RELEASE=xenial - LXC_NAME=ubuntu1710 LXC_DISTRO=ubuntu LXC_RELEASE=artful + - LXC_NAME=docker LXC_DISTRO=ubuntu LXC_RELEASE=artful before_install: - - docker build -t travis/algo . + - test "${LXC_NAME}" != "docker" || docker build -t travis/algo . install: - sudo tar xf $HOME/lxc/cache.tar -C / || echo "Didn't extract cache." @@ -53,15 +54,13 @@ install: - sudo apt-get install build-essential libssl-dev libffi-dev python-dev && sudo pip install -r requirements.txt - pip install ansible-lint - gem install awesome_bot - - export DEPLOY_ARGS="server_ip=$LXC_IP server_user=root IP_subject_alt_name=$LXC_IP local_dns=Y" script: # - awesome_bot --allow-dupe --skip-save-results *.md docs/*.md --white-list paypal.com,do.co,microsoft.com,https://github.com/trailofbits/algo/archive/master.zip,https://github.com/trailofbits/algo/issues/new # - shellcheck algo # - ansible-lint deploy.yml users.yml deploy_client.yml - ansible-playbook deploy.yml --syntax-check - - ansible-playbook deploy.yml -t local,vpn,dns,ssh_tunneling,tests -e "${DEPLOY_ARGS}" - - docker run -it -v $(pwd)/config.cfg:/algo/config.cfg -v ~/.ssh:/root/.ssh -e "DEPLOY_ARGS=${DEPLOY_ARGS}" travis/algo /bin/sh -c "chown -R 0:0 /root/.ssh && ls -l /root/.ssh && source env/bin/activate && ansible-playbook deploy.yml -t local,vpn,dns,ssh_tunneling,security,tests -e \"${DEPLOY_ARGS}\"" + - ./tests/local-deploy.sh after_script: - ./tests/update-users.sh diff --git a/tests/local-deploy.sh b/tests/local-deploy.sh new file mode 100755 index 00000000..ddd58e92 --- /dev/null +++ b/tests/local-deploy.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +DEPLOY_ARGS="server_ip=$LXC_IP server_user=root IP_subject_alt_name=$LXC_IP local_dns=Y" + +if [ "${LXC_NAME}" == "docker" ] +then + docker run -it -v $(pwd)/config.cfg:/algo/config.cfg -v ~/.ssh:/root/.ssh -e "DEPLOY_ARGS=${DEPLOY_ARGS}" travis/algo /bin/sh -c "chown -R 0:0 /root/.ssh && source env/bin/activate && ansible-playbook deploy.yml -t local,vpn,dns,ssh_tunneling,security,tests -e \"${DEPLOY_ARGS}\"" +else + ansible-playbook deploy.yml -t local,vpn,dns,ssh_tunneling,tests -e "${DEPLOY_ARGS}" +fi diff --git a/tests/update-users.sh b/tests/update-users.sh index 8777c82a..df7066d1 100755 --- a/tests/update-users.sh +++ b/tests/update-users.sh @@ -3,10 +3,16 @@ set -ex CAPW=`cat /tmp/ca_password` +USER_ARGS="server_ip=$LXC_IP server_user=root ssh_tunneling_enabled=y IP_subject=$LXC_IP easyrsa_CA_password=$CAPW" sed -i 's/- jack$/- jack_test/' config.cfg -ansible-playbook users.yml -e "server_ip=$LXC_IP server_user=root ssh_tunneling_enabled=y IP_subject=$LXC_IP easyrsa_CA_password=$CAPW" +if [ "${LXC_NAME}" == "docker" ] +then + docker run -it -v $(pwd)/config.cfg:/algo/config.cfg -v ~/.ssh:/root/.ssh -e "USER_ARGS=${USER_ARGS}" travis/algo /bin/sh -c "chown -R 0:0 /root/.ssh && source env/bin/activate && ansible-playbook users.yml -e \"${USER_ARGS}\"" +else + ansible-playbook users.yml -e "${USER_ARGS}" +fi cd configs/$LXC_IP/pki/