The idea of this change is to put together helpers for including
functional tests for charms in a central location. The charm
declares the tests and bundles to be run to complete a
functional tests but the tests themselves live here in zaza.
To use this code the charm should have the following:
1) zaza in the test-requirements.txt
2) tox.ini should include a target like:
```
[testenv:func35]
basepython = python3
commands =
functest-bundle-deploy
```
3) Bundles which are to be used for the tests:
```
ls -1 tests/bundles/*
tests/bundles/xenial.yaml
```
4) A tests/tests.yaml file that describes the bundles to be run and
the tests
```
charm_name: vault
tests:
- zaza.charms_tests.vault.VaultTest
gate_bundles:
- xenial
dev_bundles:
- bionic
```
Tests can be run without running a deployment using functest-run-tests
with the list of test classes to be run:
```
functest-run-tests -t zaza.charms_tests.vault.VaultTest
```
Known Issues:
- The deploy_bundle and add_model methods should be using libjuju
- DEV_BUNDLES is currently ignored
- VaultUtils and VaultTest should probably be in separate files.
- When skipIfNotHA skips a test unittest does not pick up it has
been skipped
- A new model is created for each bundle even if an existing empty
model exists
- No model cleanup is performed.
96 lines
2.6 KiB
Python
96 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import print_function
|
|
|
|
import os
|
|
import sys
|
|
from setuptools import setup, find_packages
|
|
from setuptools.command.test import test as TestCommand
|
|
|
|
version = "0.0.1.dev1"
|
|
install_require = [
|
|
'juju',
|
|
'juju-wait',
|
|
'hvac'
|
|
]
|
|
|
|
tests_require = [
|
|
'tox >= 2.3.1',
|
|
]
|
|
|
|
|
|
class Tox(TestCommand):
|
|
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
|
|
|
|
def initialize_options(self):
|
|
TestCommand.initialize_options(self)
|
|
self.tox_args = None
|
|
|
|
def finalize_options(self):
|
|
TestCommand.finalize_options(self)
|
|
self.test_args = []
|
|
self.test_suite = True
|
|
|
|
def run_tests(self):
|
|
#import here, cause outside the eggs aren't loaded
|
|
import tox
|
|
import shlex
|
|
args = self.tox_args
|
|
# remove the 'test' arg from argv as tox passes it to ostestr which
|
|
# breaks it.
|
|
sys.argv.pop()
|
|
if args:
|
|
args = shlex.split(self.tox_args)
|
|
errno = tox.cmdline(args=args)
|
|
sys.exit(errno)
|
|
|
|
|
|
if sys.argv[-1] == 'publish':
|
|
os.system("python setup.py sdist upload")
|
|
os.system("python setup.py bdist_wheel upload")
|
|
sys.exit()
|
|
|
|
|
|
if sys.argv[-1] == 'tag':
|
|
os.system("git tag -a %s -m 'version %s'" % (version, version))
|
|
os.system("git push --tags")
|
|
sys.exit()
|
|
|
|
|
|
setup(
|
|
name='zaza',
|
|
version=version,
|
|
description='Provides test automation for Openstack Charms',
|
|
classifiers=[
|
|
"Development Status :: 2 - Pre-Alpha",
|
|
"Intended Audience :: Developers",
|
|
"Topic :: System",
|
|
"Topic :: System :: Installation/Setup",
|
|
"Topic :: System :: Software Distribution",
|
|
"Programming Language :: Python :: 2",
|
|
"Programming Language :: Python :: 2.7",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.5",
|
|
"License :: OSI Approved :: Apache Software License",
|
|
],
|
|
entry_points={
|
|
'console_scripts': [
|
|
'functest-run-tests = zaza.functests.deploy:run_tests',
|
|
'functest-bundle-deploy = zaza.functests.deploy:deploy',
|
|
'current-apps = zaza.model:main',
|
|
'tempest-config = zaza.tempest_config:main',
|
|
]
|
|
},
|
|
url='https://github.com/openstack-charmers/zaza',
|
|
author='Chris MacNaughton',
|
|
author_email='chris.macnaughton@canonical.com',
|
|
license='Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0',
|
|
packages=find_packages(exclude=["unit_tests"]),
|
|
zip_safe=False,
|
|
cmdclass={'test': Tox},
|
|
install_requires=install_require,
|
|
extras_require={
|
|
'testing': tests_require,
|
|
},
|
|
tests_require=tests_require,
|
|
)
|