From c4f3095553dd7fb832260710d8f478cc8e0eaf64 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Fri, 11 Oct 2019 16:02:40 +0200 Subject: [PATCH] Add functional tests --- .travis.yml | 26 +++++++++++++++++++++++-- src/test-requirements.txt | 11 +++++++++++ src/tests/bundles/bionic.yaml | 30 +++++++++++++++++++++++++++++ src/tests/bundles/disco.yaml | 28 +++++++++++++++++++++++++++ src/tests/tests.yaml | 20 +++++++++++++++++++ src/tox.ini | 36 +++++++++++++++++++++++++++++++++++ 6 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 src/test-requirements.txt create mode 100644 src/tests/bundles/bionic.yaml create mode 100644 src/tests/bundles/disco.yaml create mode 100644 src/tests/tests.yaml create mode 100644 src/tox.ini diff --git a/.travis.yml b/.travis.yml index 7534783..075be87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ sudo: true dist: xenial language: python -install: pip install tox-travis +install: + - pip install tox-travis matrix: include: - name: "Python 3.6" @@ -10,5 +11,26 @@ matrix: - name: "Python 3.7" python: 3.7 env: ENV=pep8,py3 + - name: "Functional test" + env: ENV=func-smoke script: - - tox -c tox.ini -e $ENV + - if [ $ENV = 'func-smoke' ]; then + sudo apt update; + sudo apt install -y distro-info; + sudo apt remove -y --purge lxd lxd-client; + sudo snap install lxd; + sudo snap install juju --classic; + sudo sh -c 'echo PATH=/snap/bin:$PATH >> /etc/environment'; + sudo lxd waitready; + sudo lxd init --auto; + sudo usermod -a -G lxd travis; + sudo su travis -c 'juju bootstrap --no-gui localhost'; + echo "export PATH=$PATH;cd $(pwd)" > $HOME/saved_path; + sudo su - travis -c "source $HOME/saved_path; tox -e build"; + sudo su - travis -c "source $HOME/saved_path; tox -c build/builds/ovn-chassis/tox.ini -e $ENV -- --log DEBUG"; + else + tox -c tox.ini -e $ENV; + fi + - if [ $ENV = 'func-smoke' ]; then + sudo su travis -c 'juju status -m $(juju models --format yaml|grep "^- name:.*zaza"|cut -f2 -d/)'; + fi diff --git a/src/test-requirements.txt b/src/test-requirements.txt new file mode 100644 index 0000000..5a78c3e --- /dev/null +++ b/src/test-requirements.txt @@ -0,0 +1,11 @@ +# This file is managed centrally. If you find the need to modify this as a +# one-off, please don't. Intead, consult #openstack-charms and ask about +# requirements management in charms via bot-control. Thank you. +charm-tools>=2.4.4 +coverage>=3.6 +mock>=1.2 +flake8>=2.2.4,<=2.4.1 +stestr>=2.2.0 +requests>=2.18.4 +git+https://github.com/openstack-charmers/zaza.git#egg=zaza +git+https://github.com/openstack-charmers/zaza-openstack-tests.git@add-ovn#egg=zaza.openstack diff --git a/src/tests/bundles/bionic.yaml b/src/tests/bundles/bionic.yaml new file mode 100644 index 0000000..9b9821b --- /dev/null +++ b/src/tests/bundles/bionic.yaml @@ -0,0 +1,30 @@ +series: bionic +relations: +- - vault:shared-db + - mysql:shared-db +- - ovn-central:certificates + - vault:certificates +- - ubuntu + - ovn-chassis +- - ovn-chassis:ovsdb + - ovn-central:ovsdb +- - ovn-chassis:certificates + - vault:certificates +applications: + mysql: + charm: cs:~openstack-charmers-next/percona-cluster + num_units: 1 + vault: + charm: cs:~openstack-charmers-next/vault + num_units: 1 + ovn-central: + charm: cs:~openstack-charmers-next/ovn-central + num_units: 3 + options: + source: cloud:bionic-stein + ubuntu: + charm: cs:ubuntu + num_units: 1 + ovn-chassis: + series: bionic + charm: cs:~openstack-charmers-next/ovn-chassis diff --git a/src/tests/bundles/disco.yaml b/src/tests/bundles/disco.yaml new file mode 100644 index 0000000..1298f18 --- /dev/null +++ b/src/tests/bundles/disco.yaml @@ -0,0 +1,28 @@ +series: disco +relations: +- - vault:shared-db + - mysql:shared-db +- - ovn-central:certificates + - vault:certificates +- - ubuntu + - ovn-chassis +- - ovn-chassis:ovsdb + - ovn-central:ovsdb +- - ovn-chassis:certificates + - vault:certificates +applications: + mysql: + charm: cs:~openstack-charmers-next/percona-cluster + num_units: 1 + vault: + charm: cs:~openstack-charmers-next/vault + num_units: 1 + ovn-central: + charm: cs:~openstack-charmers-next/ovn-central + num_units: 3 + ubuntu: + charm: cs:ubuntu + num_units: 1 + ovn-chassis: + series: disco + charm: cs:~openstack-charmers-next/ovn-chassis diff --git a/src/tests/tests.yaml b/src/tests/tests.yaml new file mode 100644 index 0000000..2611f40 --- /dev/null +++ b/src/tests/tests.yaml @@ -0,0 +1,20 @@ +charm_name: ovn-chassis +gate_bundles: +- disco +- bionic +smoke_bundles: +- bionic +target_deploy_status: + ovn-central: + workload-status: blocked + workload-status-message: "'certificates' missing" + ovn-chassis: + workload-status: blocked + workload-status-message: "'certificates' missing" + vault: + workload-status: blocked + workload-status-message: Vault needs to be initialized +configure: +- zaza.openstack.charm_tests.vault.setup.auto_initialize_no_validation +tests: +- zaza.charm_tests.noop.tests.NoopTest diff --git a/src/tox.ini b/src/tox.ini new file mode 100644 index 0000000..69685b0 --- /dev/null +++ b/src/tox.ini @@ -0,0 +1,36 @@ +[tox] +envlist = pep8 +skipsdist = True + +[testenv] +download = true +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +whitelist_externals = juju +passenv = HOME TERM CS_API_* OS_* AMULET_* +deps = -r{toxinidir}/test-requirements.txt +install_command = + pip install {opts} {packages} + +[testenv:pep8] +basepython = python3 +deps=charm-tools +commands = charm-proof + +[testenv:func-noop] +basepython = python3 +commands = + true + +[testenv:func] +basepython = python3 +commands = + functest-run-suite {posargs} --keep-model + +[testenv:func-smoke] +basepython = python3 +commands = + functest-run-suite {posargs} --keep-model --smoke + +[testenv:venv] +commands = {posargs}