def deploy(bundle, model, wait=True, model_ctxt=None, force=False): """Run all steps to complete deployment. :param bundle: Path to bundle file :type bundle: str :param model: Name of model to deploy bundle in :type model: str :param wait: Whether to wait until deployment completes :type wait: bool :param model_ctxt: Additional context to be used when rendering bundle templates. :type model_ctxt: {} :param force: Pass the force parameter if True :type force: Boolean """ run_report.register_event_start('Deploy Bundle') deploy_bundle(bundle, model, model_ctxt=model_ctxt, force=force) run_report.register_event_finish('Deploy Bundle') if wait: run_report.register_event_start('Wait for Deployment') test_config = utils.get_charm_config() logging.info("Waiting for environment to settle") zaza.model.set_juju_model(model) zaza.model.wait_for_application_states( model, test_config.get('target_deploy_status', {})) run_report.register_event_finish('Wait for Deployment')
def run_configure_list(functions): """Run the configure scripts. Run the configure scripts as defined in the list of configuration methods in series. :param functions: List of configure functions functions :type tests: ['zaza.charms_tests.svc.setup', ...] """ for func in functions: run_report.register_event_start('Configure {}'.format(func)) utils.get_class(func)() run_report.register_event_finish('Configure {}'.format(func))
def run_before_deploy_list(functions): """Run the pre-deploy scripts. Run the pre-deploy scripts as defined in the list of methods in series. :param functions: List of pre-deploy functions functions :type tests: ['zaza.charms_tests.svc.setup', ...] """ for func in functions: run_report.register_event_start('Before Deploy {}'.format(func)) utils.get_class(func)() run_report.register_event_finish('Before Deploy {}'.format(func))
def run_configure_list(functions): """Run the configure scripts. Run the configure scripts as defined in the list of configuration methods in series. :param functions: List of configure functions functions :type tests: ['zaza.charms_tests.svc.setup', ...] """ for func in functions: with notify_around(NotifyEvents.CONFIGURE_FUNCTION, function=func): # TODO: change run_report to use zaza.notifications run_report.register_event_start('Configure {}'.format(func)) utils.get_class(func)() run_report.register_event_finish('Configure {}'.format(func))
def run_before_deploy_list(functions): """Run the pre-deploy scripts. Run the pre-deploy scripts as defined in the list of methods in series. :param functions: List of pre-deploy functions functions :type tests: ['zaza.charms_tests.svc.setup', ...] """ for func in functions: with notify_around(NotifyEvents.BEFORE_DEPLOY_FUNCTION, function=func): # TODO: change run_report to use zaza.notifications run_report.register_event_start('Before Deploy {}'.format(func)) utils.get_class(func)() run_report.register_event_finish('Before Deploy {}'.format(func))
def run_test_list(tests): """Run the tests as defined in the list of test classes in series. :param tests: List of test class strings :type tests: ['zaza.charms_tests.svc.TestSVCClass1', ...] :raises: AssertionError if test run fails """ for _testcase in tests: run_report.register_event_start('Test {}'.format(_testcase)) logging.info('## Running Test {} ##'.format(_testcase)) testcase = utils.get_class(_testcase) suite = unittest.TestLoader().loadTestsFromTestCase(testcase) test_result = unittest.TextTestRunner(stream=Stream2Logger(), verbosity=2).run(suite) run_report.register_event_finish('Test {}'.format(_testcase)) assert test_result.wasSuccessful(), "Test run failed"
def run_test_list(tests): """Run each test in the list using the appropriate test runner. Test classes should declare the class viariable 'test_runner' which will indicate which runner should be used. If none is provided then the unittest runner is used. :param tests: List of tests to be run. :type tests: List """ for _testcase in tests: run_report.register_event_start('Test {}'.format(_testcase)) logging.info('## Running Test {} ##'.format(_testcase)) testcase = utils.get_class(_testcase) try: runner = testcase.test_runner except AttributeError: runner = UNITTEST get_test_runners()[runner](testcase, _testcase)
def deploy(bundle, model, wait=True): """Run all steps to complete deployment. :param bundle: Path to bundle file :type bundle: str :param model: Name of model to deploy bundle in :type model: str :param wait: Whether to wait until deployment completes :type model: bool """ run_report.register_event_start('Deploy Bundle') deploy_bundle(bundle, model) run_report.register_event_finish('Deploy Bundle') if wait: run_report.register_event_start('Wait for Deployment') test_config = utils.get_charm_config() logging.info("Waiting for environment to settle") zaza.model.set_juju_model(model) zaza.model.wait_for_application_states( model, test_config.get('target_deploy_status', {})) run_report.register_event_finish('Wait for Deployment')
def deploy(bundle, model, wait=True, model_ctxt=None, force=False, test_directory=None): """Run all steps to complete deployment. :param bundle: Path to bundle file :type bundle: str :param model: Name of model to deploy bundle in :type model: str :param wait: Whether to wait until deployment completes :type wait: bool :param model_ctxt: Additional context to be used when rendering bundle templates. :type model_ctxt: {} :param force: Pass the force parameter if True :type force: Boolean :param test_directory: Set the directory containing tests.yaml and bundles. :type test_directory: str """ utils.set_base_test_dir(test_dir=test_directory) run_report.register_event_start('Deploy Bundle') deploy_bundle(bundle, model, model_ctxt=model_ctxt, force=force) run_report.register_event_finish('Deploy Bundle') if wait: run_report.register_event_start('Wait for Deployment') test_config = utils.get_charm_config() logging.info("Waiting for environment to settle") zaza.model.set_juju_model(model) deploy_ctxt = deployment_env.get_deployment_context() timeout = int(deploy_ctxt.get('TEST_DEPLOY_TIMEOUT', '3600')) logging.info( "Timeout for deployment to settle set to: {}".format(timeout)) zaza.model.wait_for_application_states(model, test_config.get( 'target_deploy_status', {}), timeout=timeout) run_report.register_event_finish('Wait for Deployment')