Fix lint
This commit is contained in:
@@ -3,6 +3,7 @@ import logging
|
||||
|
||||
import zaza.charm_testing.utils as utils
|
||||
|
||||
|
||||
def run_configure_list(functions):
|
||||
"""Run the configure scripts as defined in the list of test classes in
|
||||
series.
|
||||
@@ -13,6 +14,7 @@ def run_configure_list(functions):
|
||||
for func in functions:
|
||||
utils.get_class(func)()
|
||||
|
||||
|
||||
def configure(functions):
|
||||
"""Run all post-deployment configuration steps
|
||||
|
||||
@@ -20,15 +22,16 @@ def configure(functions):
|
||||
:type tests: ['zaza.charms_tests.svc.setup', ...]"""
|
||||
run_configure_list(functions)
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the configuration defined by the command line args or if none were
|
||||
provided read the configuration functions from the charms tests.yaml
|
||||
config file"""
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c','--configfuncs', nargs='+',
|
||||
parser.add_argument('-c', '--configfuncs', nargs='+',
|
||||
help='Space sperated list of config functions',
|
||||
required=False)
|
||||
args = parser.parse_args()
|
||||
funcs = args.configfuncs or get_test_config()['configure']
|
||||
funcs = args.configfuncs or utils.get_charm_config()['configure']
|
||||
configure(funcs)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import argparse
|
||||
import logging
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import juju_wait
|
||||
|
||||
@@ -25,10 +24,10 @@ def main():
|
||||
"""Deploy bundle"""
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-m','--model',
|
||||
parser.add_argument('-m', '--model',
|
||||
help='Model to deploy to',
|
||||
required=True)
|
||||
parser.add_argument('-b','--bundle',
|
||||
parser.add_argument('-b', '--bundle',
|
||||
help='Bundle name (excluding file ext)',
|
||||
required=True)
|
||||
parser.add_argument('--no-wait', dest='wait',
|
||||
|
||||
@@ -2,6 +2,7 @@ import argparse
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
|
||||
def destroy_model(model_name):
|
||||
"""Remove a model with the given name
|
||||
|
||||
@@ -11,6 +12,7 @@ def destroy_model(model_name):
|
||||
logging.info("Remove model {}".format(model_name))
|
||||
subprocess.check_call(['juju', 'destroy-model', '--yes', model_name])
|
||||
|
||||
|
||||
def clean_up(model_name):
|
||||
"""Run all steps to cleaup after a test run
|
||||
|
||||
@@ -19,11 +21,12 @@ def clean_up(model_name):
|
||||
"""
|
||||
destroy_model(model_name)
|
||||
|
||||
|
||||
def main():
|
||||
"""Cleanup after test run"""
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-m','--model-name', help='Name of model to remove',
|
||||
parser.add_argument('-m', '--model-name', help='Name of model to remove',
|
||||
required=True)
|
||||
args = parser.parse_args()
|
||||
clean_up(args.model_name)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
import zaza.charm_testing.configure as configure
|
||||
@@ -9,6 +8,7 @@ import zaza.charm_testing.prepare as prepare
|
||||
import zaza.charm_testing.deploy as deploy
|
||||
import zaza.charm_testing.test as test
|
||||
|
||||
|
||||
def func_test_runner():
|
||||
"""Deploy the bundles and run the tests as defined by the charms tests.yaml
|
||||
"""
|
||||
@@ -29,5 +29,6 @@ def func_test_runner():
|
||||
# Destroy
|
||||
destroy.clean_up(model_name)
|
||||
|
||||
|
||||
def main():
|
||||
func_test_runner()
|
||||
|
||||
@@ -2,6 +2,7 @@ import argparse
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
|
||||
def add_model(model_name):
|
||||
"""Add a model with the given name
|
||||
|
||||
@@ -11,6 +12,7 @@ def add_model(model_name):
|
||||
logging.info("Adding model {}".format(model_name))
|
||||
subprocess.check_call(['juju', 'add-model', model_name])
|
||||
|
||||
|
||||
def prepare(model_name):
|
||||
"""Run all steps to prepare the environment before a functional test run
|
||||
|
||||
@@ -19,11 +21,12 @@ def prepare(model_name):
|
||||
"""
|
||||
add_model(model_name)
|
||||
|
||||
|
||||
def main():
|
||||
"""Add a new model"""
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-m','--model-name', help='Name of new model',
|
||||
parser.add_argument('-m', '--model-name', help='Name of new model',
|
||||
required=True)
|
||||
args = parser.parse_args()
|
||||
prepare(args.model_name)
|
||||
|
||||
@@ -4,6 +4,7 @@ import unittest
|
||||
|
||||
import zaza.charm_testing.utils as utils
|
||||
|
||||
|
||||
def run_test_list(tests):
|
||||
"""Run the tests as defined in the list of test classes in series.
|
||||
|
||||
@@ -17,18 +18,20 @@ def run_test_list(tests):
|
||||
test_result = unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
assert test_result.wasSuccessful(), "Test run failed"
|
||||
|
||||
|
||||
def test(tests):
|
||||
"""Run all steps to execute tests against the model"""
|
||||
run_test_list(tests)
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the tests defined by the command line args or if none were provided
|
||||
read the tests from the charms tests.yaml config file"""
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-t','--tests', nargs='+',
|
||||
parser.add_argument('-t', '--tests', nargs='+',
|
||||
help='Space sperated list of test classes',
|
||||
required=False)
|
||||
args = parser.parse_args()
|
||||
tests = args.tests or get_test_config()['tests']
|
||||
tests = args.tests or utils.get_charm_config()['tests']
|
||||
test(tests)
|
||||
|
||||
@@ -4,6 +4,7 @@ import yaml
|
||||
BUNDLE_DIR = "./tests/bundles/"
|
||||
DEFAULT_TEST_CONFIG = "./tests/tests.yaml"
|
||||
|
||||
|
||||
def get_charm_config():
|
||||
"""Read the yaml test config file and return the resulting config
|
||||
|
||||
@@ -13,6 +14,7 @@ def get_charm_config():
|
||||
with open(DEFAULT_TEST_CONFIG, 'r') as stream:
|
||||
return yaml.load(stream)
|
||||
|
||||
|
||||
def get_class(class_str):
|
||||
"""Get the class represented by the given string
|
||||
|
||||
@@ -28,4 +30,3 @@ def get_class(class_str):
|
||||
class_name = class_str.split('.')[-1]
|
||||
module = importlib.import_module(module_name)
|
||||
return getattr(module, class_name)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import unittest
|
||||
import zaza.model
|
||||
|
||||
|
||||
@@ -9,7 +8,8 @@ def skipIfNotHA(service_name):
|
||||
if len(zaza.model.get_app_ips(service_name)) > 1:
|
||||
return f(*args, **kwargs)
|
||||
else:
|
||||
logging.warn("Skipping HA test for non-ha service {}".format(service_name))
|
||||
logging.warn("Skipping HA test for non-ha service {}".format(
|
||||
service_name))
|
||||
return _skipIfNotHA_inner_2
|
||||
|
||||
return _skipIfNotHA_inner_1
|
||||
|
||||
Reference in New Issue
Block a user