Files
zaza-openstack-tests/zaza/charm_lifecycle/func_test_runner.py
T
Liam Young cb5d9caf66 Misc fixes to functional testing code
* Add calls to asyncio.get_event_loop().close() to close loop. libjuju does
  not do this for you and needs to be done just before exiting.
* Require model to be explicitly set when running command line tools. This is
  part of the drive to ensure that eventually multiple runs can be performed
  concurrently.
* Add set_juju_model/get_juju_model functions to manage which model is in
  focus
2018-03-28 11:48:53 +00:00

39 lines
1.2 KiB
Python

import datetime
import os
import zaza.charm_lifecycle.configure as configure
import zaza.charm_lifecycle.destroy as destroy
import zaza.charm_lifecycle.utils as utils
import zaza.charm_lifecycle.prepare as prepare
import zaza.charm_lifecycle.deploy as deploy
import zaza.charm_lifecycle.test as test
def generate_model_name(charm_name, bundle_name):
timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
return '{}{}{}'.format(charm_name, bundle_name, timestamp)
def func_test_runner():
"""Deploy the bundles and run the tests as defined by the charms tests.yaml
"""
test_config = utils.get_charm_config()
for t in test_config['gate_bundles']:
model_name = generate_model_name(test_config['charm_name'], t)
# Prepare
prepare.prepare(model_name)
# Deploy
deploy.deploy(
os.path.join(utils.BUNDLE_DIR, '{}.yaml'.format(t)),
model_name)
# Configure
configure.configure(model_name, test_config['configure'])
# Test
test.test(model_name, test_config['tests'])
# Destroy
destroy.destroy(model_name)
def main():
func_test_runner()