def test_validation(self): with open("sahara/tests/scenario_unit/vanilla2_6_0.yaml", "r") as yaml_file: config = yaml.load(yaml_file) self.assertIsNone(validation.validate(config))
def main(): # parse args parser = argparse.ArgumentParser(description="Scenario tests runner.") parser.add_argument('scenario_arguments', help="Path to scenario files", nargs='+') args = parser.parse_args() scenario_arguments = args.scenario_arguments # parse config config = {'credentials': {}, 'network': {}, 'clusters': [], 'edp_jobs_flow': {}} files = [] for scenario_argument in scenario_arguments: if os.path.isdir(scenario_argument): files += recursive_walk(scenario_argument) if os.path.isfile(scenario_argument): files.append(scenario_argument) for scenario_argument in files: with open(scenario_argument, 'r') as yaml_file: test_scenario = yaml.load(yaml_file) config = _merge_dicts_sections(test_scenario, config, 'credentials') config = _merge_dicts_sections(test_scenario, config, 'network') if test_scenario.get('clusters') is not None: config['clusters'] += test_scenario['clusters'] if test_scenario.get('edp_jobs_flow') is not None: for key in test_scenario['edp_jobs_flow']: if key not in config['edp_jobs_flow']: config['edp_jobs_flow'][key] = ( test_scenario['edp_jobs_flow'][key]) else: raise ValueError('Job flow exist') # validate config validation.validate(config) set_defaults(config) credentials = config['credentials'] network = config['network'] testcases = config['clusters'] # create testcase file test_template = mako_template.Template(filename=TEST_TEMPLATE_PATH) testcase_data = test_template.render(testcases=testcases, credentials=credentials, network=network) test_dir_path = tempfile.mkdtemp() print("The generated test file located at: %s" % test_dir_path) fileutils.write_to_tempfile(testcase_data, prefix='test_', suffix='.py', path=test_dir_path) # run tests concurrency = config.get('concurrency') os.environ['DISCOVER_DIRECTORY'] = test_dir_path command = 'bash tools/pretty_tox.sh' if concurrency: command = command + ' -- --concurrency %d' % concurrency return_code = os.system(command) sys.exit(return_code)
def main(): # parse args parser = argparse.ArgumentParser(description="Scenario tests runner.") parser.add_argument('scenario_arguments', help="Path to scenario files", nargs='+') parser.add_argument('--variable_file', '-V', default='', nargs='?', help='Path to the file with template variables') parser.add_argument('--verbose', default=False, action='store_true', help='Increase output verbosity') args = parser.parse_args() scenario_arguments = args.scenario_arguments variable_file = args.variable_file verbose_run = args.verbose # parse config config = {'credentials': {}, 'network': {}, 'clusters': [], 'edp_jobs_flow': {}} files = [] for scenario_argument in scenario_arguments: if os.path.isdir(scenario_argument): files += recursive_walk(scenario_argument) if os.path.isfile(scenario_argument): files.append(scenario_argument) template_variables = {} if any(is_template_file(config_file) for config_file in files): template_variables = read_template_variables(variable_file, verbose_run) for scenario_argument in files: test_scenario = read_scenario_config(scenario_argument, template_variables, verbose_run) config = _merge_dicts_sections(test_scenario, config, 'credentials') config = _merge_dicts_sections(test_scenario, config, 'network') if test_scenario.get('clusters') is not None: config['clusters'] += test_scenario['clusters'] if test_scenario.get('edp_jobs_flow') is not None: for key in test_scenario['edp_jobs_flow']: if key not in config['edp_jobs_flow']: config['edp_jobs_flow'][key] = ( test_scenario['edp_jobs_flow'][key]) else: raise ValueError('Job flow exist') # validate config validation.validate(config) set_defaults(config) credentials = config['credentials'] network = config['network'] testcases = config['clusters'] # create testcase file test_template = mako_template.Template(filename=TEST_TEMPLATE_PATH) testcase_data = test_template.render(testcases=testcases, credentials=credentials, network=network) test_dir_path = tempfile.mkdtemp() print("The generated test file located at: %s" % test_dir_path) fileutils.write_to_tempfile(testcase_data, prefix='test_', suffix='.py', path=test_dir_path) # run tests concurrency = config.get('concurrency') os.environ['DISCOVER_DIRECTORY'] = test_dir_path command = 'bash tools/pretty_tox.sh' if concurrency: command = command + ' -- --concurrency %d' % concurrency return_code = subprocess.call(command, shell=True) sys.exit(return_code)
def main(): # parse args parser = argparse.ArgumentParser(description="Scenario tests runner.") parser.add_argument('scenario_arguments', help="Path to scenario files", nargs='+') args = parser.parse_args() scenario_arguments = args.scenario_arguments # parse config config = { 'credentials': {}, 'network': {}, 'clusters': [], 'edp_jobs_flow': {} } files = [] for scenario_argument in scenario_arguments: if os.path.isdir(scenario_argument): files += recursive_walk(scenario_argument) if os.path.isfile(scenario_argument): files.append(scenario_argument) for scenario_argument in files: with open(scenario_argument, 'r') as yaml_file: test_scenario = yaml.load(yaml_file) config = _merge_dicts_sections(test_scenario, config, 'credentials') config = _merge_dicts_sections(test_scenario, config, 'network') if test_scenario.get('clusters') is not None: config['clusters'] += test_scenario['clusters'] if test_scenario.get('edp_jobs_flow') is not None: for key in test_scenario['edp_jobs_flow']: if key not in config['edp_jobs_flow']: config['edp_jobs_flow'][key] = ( test_scenario['edp_jobs_flow'][key]) else: raise ValueError('Job flow exist') # validate config validation.validate(config) set_defaults(config) credentials = config['credentials'] network = config['network'] testcases = config['clusters'] # create testcase file test_template = mako_template.Template(filename=TEST_TEMPLATE_PATH) testcase_data = test_template.render(testcases=testcases, credentials=credentials, network=network) test_dir_path = tempfile.mkdtemp() print("The generated test file located at: %s" % test_dir_path) fileutils.write_to_tempfile(testcase_data, prefix='test_', suffix='.py', path=test_dir_path) # run tests concurrency = config.get('concurrency') os.environ['DISCOVER_DIRECTORY'] = test_dir_path command = 'bash tools/pretty_tox.sh' if concurrency: command = command + ' -- --concurrency %d' % concurrency return_code = os.system(command) sys.exit(return_code)
def main(): # parse args parser = argparse.ArgumentParser(description="Scenario tests runner.") parser.add_argument('scenario_arguments', help="Path to scenario files", nargs='+') parser.add_argument('--variable_file', '-V', default='', nargs='?', help='Path to the file with template variables') parser.add_argument('--verbose', default=False, action='store_true', help='Increase output verbosity') parser.add_argument('--validate', default=False, action='store_true', help='Validate yaml-files, tests will not be runned') args = parser.parse_args() scenario_arguments = args.scenario_arguments variable_file = args.variable_file verbose_run = args.verbose # parse config config = { 'credentials': {}, 'network': {}, 'clusters': [], 'edp_jobs_flow': {} } files = [] for scenario_argument in scenario_arguments: if os.path.isdir(scenario_argument): files += recursive_walk(scenario_argument) if os.path.isfile(scenario_argument): files.append(scenario_argument) template_variables = {} if any(is_template_file(config_file) for config_file in files): template_variables = read_template_variables(variable_file, verbose_run) for scenario_argument in files: test_scenario = read_scenario_config(scenario_argument, template_variables, verbose_run) config = _merge_dicts_sections(test_scenario, config, 'credentials') config = _merge_dicts_sections(test_scenario, config, 'network') if test_scenario.get('clusters') is not None: config['clusters'] += test_scenario['clusters'] if test_scenario.get('edp_jobs_flow') is not None: for key in test_scenario['edp_jobs_flow']: if key not in config['edp_jobs_flow']: config['edp_jobs_flow'][key] = ( test_scenario['edp_jobs_flow'][key]) else: raise ValueError('Job flow exist') # validate config validation.validate(config) if args.validate: return set_defaults(config) credentials = config['credentials'] network = config['network'] testcases = config['clusters'] # create testcase file test_template = mako_template.Template(filename=TEST_TEMPLATE_PATH) testcase_data = test_template.render(testcases=testcases, credentials=credentials, network=network) test_dir_path = tempfile.mkdtemp() print("The generated test file located at: %s" % test_dir_path) fileutils.write_to_tempfile(testcase_data, prefix='test_', suffix='.py', path=test_dir_path) # run tests concurrency = config.get('concurrency') os.environ['DISCOVER_DIRECTORY'] = test_dir_path command = 'bash tools/pretty_tox.sh' if concurrency: command = command + ' -- --concurrency %d' % concurrency return_code = subprocess.call(command, shell=True) sys.exit(return_code)