diff --git a/.travis.yml b/.travis.yml index 3089dc7..df1e8ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,28 @@ -sudo: false +sudo: true language: python -dist: xenial python: - "3.6" install: pip install tox-travis +env: + - ENV=pep8 + - ENV=py3 + - ENV=func-travis +comment: | + install dependencies in script phase saving time on simpler test environments + sudo back to ourself to activate lxd group membership executable search path script: - - tox -c tox.ini -e pep8 - - tox -c tox.ini -e py3 + - if [ $ENV = 'func-travis' ]; then + sudo apt-get -qq update; + sudo apt-get -y install snapd; + 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'; + fi + - tox -c tox.ini -e $ENV + - if [ $ENV = 'func-travis' ]; then + sudo su travis -c 'juju status -m $(juju models --format yaml|grep "^- name:.*zaza"|cut -f2 -d/)'; + fi diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..e5095d0 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,2 @@ +This directory contains functional test definition for functional test of Zaza +itself. diff --git a/tests/bundles/magpie.yaml b/tests/bundles/magpie.yaml new file mode 100644 index 0000000..eb065fd --- /dev/null +++ b/tests/bundles/magpie.yaml @@ -0,0 +1,5 @@ +series: bionic +applications: + magpie: + charm: cs:~admcleod/magpie + num_units: 2 diff --git a/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/tests/bundles/overlays/local-charm-overlay.yaml.j2 new file mode 100644 index 0000000..185df30 --- /dev/null +++ b/tests/bundles/overlays/local-charm-overlay.yaml.j2 @@ -0,0 +1 @@ +comment: this bundle overlay intentionally left blank diff --git a/tests/tests.yaml b/tests/tests.yaml new file mode 100644 index 0000000..b3abec1 --- /dev/null +++ b/tests/tests.yaml @@ -0,0 +1,11 @@ +charm_name: none +gate_bundles: +- magpie +target_deploy_status: + magpie: + workload-status: active + workload-status-message: icmp ok, local hostname ok, dns ok +configure: +- zaza.charm_tests.noop.setup.basic_setup +tests: +- zaza.charm_tests.noop.tests.NoopTest diff --git a/tox.ini b/tox.ini index 8e5f4a2..4ce2bb5 100644 --- a/tox.ini +++ b/tox.ini @@ -34,3 +34,20 @@ changedir = doc/source deps = -r{toxinidir}/requirements.txt commands = sphinx-build -W -b html -d {toxinidir}/doc/build/doctrees . {toxinidir}/doc/build/html + +[testenv:func] +basepython = python3 +deps = -r{toxinidir}/requirements.txt +commands = + {envdir}/bin/python3 setup.py install + functest-run-suite --keep-model + +[testenv:func-travis] +basepython = python3 +deps = -r{toxinidir}/requirements.txt +# sudo back to ourself to activate lxd group membership executable search path +whitelist_externals = sudo +passenv = USER +commands = + {envdir}/bin/python3 setup.py install + sudo su {env:USER} -c 'source {envdir}/bin/activate && functest-run-suite --keep-model' diff --git a/zaza/charm_tests/noop/__init__.py b/zaza/charm_tests/noop/__init__.py new file mode 100644 index 0000000..2a9f771 --- /dev/null +++ b/zaza/charm_tests/noop/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2018 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Collection of code for validating Zaza.""" diff --git a/zaza/charm_tests/noop/setup.py b/zaza/charm_tests/noop/setup.py new file mode 100644 index 0000000..494b715 --- /dev/null +++ b/zaza/charm_tests/noop/setup.py @@ -0,0 +1,22 @@ +# Copyright 2018 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Code for validating Zaza configure function loader.""" + +import logging + + +def basic_setup(): + """Run setup.""" + logging.info('OK') diff --git a/zaza/charm_tests/noop/tests.py b/zaza/charm_tests/noop/tests.py new file mode 100644 index 0000000..1fb9b34 --- /dev/null +++ b/zaza/charm_tests/noop/tests.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# Copyright 2018 Canonical Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Code for validating Zaza test class loader.""" + +import logging +import unittest + + +class NoopTest(unittest.TestCase): + """Code for validating Zaza test class loader.""" + + @classmethod + def setUpClass(cls): + """Run class setup for noop tests.""" + super(NoopTest, cls).setUpClass() + + def test_foo(self): + """foo.""" + logging.info('bar')