From ce51ea65f8f6c66f80e0f4a4928e5b991733a54b Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Wed, 8 Nov 2017 15:22:55 -0500 Subject: [PATCH] Update the Travis CI infrastructure to run integration tests This change updates the Travis CI configuration to support running the PyKMIP integation test suite. A custom run.sh script is added which conditionally runs tox based on an environment flag set in .travis.yml. If integration tests are activated, the test VM will be prepped for running the PyKMIP server; this includes creating /etc/pykmip content, like pykmip.conf and server.conf, along with a basic certificate to use for both the client and server. --- .travis.yml | 64 ++++++++++++++++++++++++++++++++++----------- .travis/pykmip.conf | 12 +++++++++ .travis/run.sh | 20 ++++++++++++++ .travis/server.conf | 8 ++++++ 4 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 .travis/pykmip.conf create mode 100755 .travis/run.sh create mode 100644 .travis/server.conf diff --git a/.travis.yml b/.travis.yml index 12ae813..aff2b58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,67 +1,101 @@ +sudo: true language: python matrix: include: - python: 2.7 os: linux dist: precise - env: TOXENV=py27 + env: TOXENV=py27 RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: trusty - env: TOXENV=py27 + env: TOXENV=py27 RUN_INTEGRATION_TESTS=0 + - python: 2.7 + os: linux + dist: precise + env: TOXENV=py27 RUN_INTEGRATION_TESTS=1 + - python: 2.7 + os: linux + dist: trusty + env: TOXENV=py27 RUN_INTEGRATION_TESTS=1 - python: 3.4 os: linux dist: precise - env: TOXENV=py34 + env: TOXENV=py34 RUN_INTEGRATION_TESTS=0 - python: 3.4 os: linux dist: trusty - env: TOXENV=py34 + env: TOXENV=py34 RUN_INTEGRATION_TESTS=0 + - python: 3.4 + os: linux + dist: precise + env: TOXENV=py34 RUN_INTEGRATION_TESTS=1 + - python: 3.4 + os: linux + dist: trusty + env: TOXENV=py34 RUN_INTEGRATION_TESTS=1 - python: 3.5 os: linux dist: precise - env: TOXENV=py35 + env: TOXENV=py35 RUN_INTEGRATION_TESTS=0 - python: 3.5 os: linux dist: trusty - env: TOXENV=py35 + env: TOXENV=py35 RUN_INTEGRATION_TESTS=0 + - python: 3.5 + os: linux + dist: precise + env: TOXENV=py35 RUN_INTEGRATION_TESTS=1 + - python: 3.5 + os: linux + dist: trusty + env: TOXENV=py35 RUN_INTEGRATION_TESTS=1 - python: 3.6 os: linux dist: precise - env: TOXENV=py36 + env: TOXENV=py36 RUN_INTEGRATION_TESTS=0 - python: 3.6 os: linux dist: trusty - env: TOXENV=py36 + env: TOXENV=py36 RUN_INTEGRATION_TESTS=0 + - python: 3.6 + os: linux + dist: precise + env: TOXENV=py36 RUN_INTEGRATION_TESTS=1 + - python: 3.6 + os: linux + dist: trusty + env: TOXENV=py36 RUN_INTEGRATION_TESTS=1 - python: 2.7 os: linux dist: precise - env: TOXENV=pep8 + env: TOXENV=pep8 RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: trusty - env: TOXENV=pep8 + env: TOXENV=pep8 RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: precise - env: TOXENV=bandit + env: TOXENV=bandit RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: trusty - env: TOXENV=bandit + env: TOXENV=bandit RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: precise - env: TOXENV=docs + env: TOXENV=docs RUN_INTEGRATION_TESTS=0 - python: 2.7 os: linux dist: trusty - env: TOXENV=docs + env: TOXENV=docs RUN_INTEGRATION_TESTS=0 install: - pip install tox - pip install bandit - pip install codecov + - python setup.py install script: - - tox + - ./.travis/run.sh after_success: - codecov diff --git a/.travis/pykmip.conf b/.travis/pykmip.conf new file mode 100644 index 0000000..beac5a6 --- /dev/null +++ b/.travis/pykmip.conf @@ -0,0 +1,12 @@ +[client] +host=127.0.0.1 +port=5696 +keyfile=/etc/pykmip/certs/key.pem +certfile=/etc/pykmip/certs/cert.pem +cert_reqs=CERT_REQUIRED +ssl_version=PROTOCOL_SSLv23 +ca_certs=/etc/pykmip/certs/cert.pem +do_handshake_on_connect=True +suppress_ragged_eofs=True +username= +password= diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100755 index 0000000..77e2b03 --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e +set -x + +if [[ "${RUN_INTEGRATION_TESTS}" == "1" ]]; then + sudo mkdir -p /etc/pykmip/certs + cd /etc/pykmip/certs + sudo openssl req -x509 -subj "/CN=test" -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes + cd - + sudo cp ./.travis/pykmip.conf /etc/pykmip/pykmip.conf + sudo cp ./.travis/server.conf /etc/pykmip/server.conf + sudo mkdir /var/log/pykmip + sudo chmod 777 /var/log/pykmip + python ./bin/run_server.py & + tox -e integration -- --config client +else + tox +fi + diff --git a/.travis/server.conf b/.travis/server.conf new file mode 100644 index 0000000..f0ddd68 --- /dev/null +++ b/.travis/server.conf @@ -0,0 +1,8 @@ +[server] +hostname=127.0.0.1 +port=5696 +certificate_path=/etc/pykmip/certs/cert.pem +key_path=/etc/pykmip/certs/key.pem +ca_path=/etc/pykmip/certs/cert.pem +auth_suite=Basic +enable_tls_client_auth=False