def take_action(self, parsed_args): if parsed_args.config_file: self._set_env(parsed_args.config_file) else: self._set_env() # Workspace execution mode if parsed_args.workspace: workspace_mgr = workspace.WorkspaceManager( parsed_args.workspace_path) path = workspace_mgr.get_workspace(parsed_args.workspace) if not path: sys.exit("The %r workspace isn't registered in " "%r. Use 'tempest init' to " "register the workspace." % (parsed_args.workspace, workspace_mgr.path)) os.chdir(path) if not os.path.isfile('.stestr.conf'): self._create_stestr_conf() # local execution with config file mode elif parsed_args.config_file and not os.path.isfile('.stestr.conf'): self._create_stestr_conf() elif not os.path.isfile('.stestr.conf'): print("No .stestr.conf file was found for local execution") sys.exit(2) if parsed_args.state: self._init_state() else: pass regex = self._build_regex(parsed_args) return_code = 0 if parsed_args.list_tests: return_code = commands.list_command( filters=regex, whitelist_file=parsed_args.whitelist_file, blacklist_file=parsed_args.blacklist_file, black_regex=parsed_args.black_regex) else: serial = not parsed_args.parallel return_code = commands.run_command( filters=regex, subunit_out=parsed_args.subunit, serial=serial, concurrency=parsed_args.concurrency, blacklist_file=parsed_args.blacklist_file, whitelist_file=parsed_args.whitelist_file, black_regex=parsed_args.black_regex, load_list=parsed_args.load_list, combine=parsed_args.combine) if return_code > 0: sys.exit(return_code) return return_code
def take_action(self, parsed_args): returncode = 0 if parsed_args.config_file: self._set_env(parsed_args.config_file) else: self._set_env() # Workspace execution mode if parsed_args.workspace: workspace_mgr = workspace.WorkspaceManager( parsed_args.workspace_path) path = workspace_mgr.get_workspace(parsed_args.workspace) if not path: sys.exit( "The %r workspace isn't registered in " "%r. Use 'tempest init' to " "register the workspace." % (parsed_args.workspace, workspace_mgr.path)) os.chdir(path) # NOTE(mtreinish): tempest init should create a .testrepository dir # but since workspaces can be imported let's sanity check and # ensure that one is created self._create_testrepository() # Local execution mode elif os.path.isfile('.testr.conf'): # If you're running in local execution mode and there is not a # testrepository dir create one self._create_testrepository() # local execution with config file mode elif parsed_args.config_file: self._create_testr_conf() self._create_testrepository() else: print("No .testr.conf file was found for local execution") sys.exit(2) regex = self._build_regex(parsed_args) if parsed_args.list_tests: argv = ['tempest', 'list-tests', regex] returncode = run_argv(argv, sys.stdin, sys.stdout, sys.stderr) else: options = self._build_options(parsed_args) returncode = self._run(regex, options) sys.exit(returncode)
def take_action(self, parsed_args): if parsed_args.config_file: self._set_env(parsed_args.config_file) else: self._set_env() # Workspace execution mode if parsed_args.workspace: workspace_mgr = workspace.WorkspaceManager( parsed_args.workspace_path) path = workspace_mgr.get_workspace(parsed_args.workspace) if not path: sys.exit( "The %r workspace isn't registered in " "%r. Use 'tempest init' to " "register the workspace." % (parsed_args.workspace, workspace_mgr.path)) os.chdir(path) if not os.path.isfile('.stestr.conf'): self._create_stestr_conf() # local execution with config file mode elif parsed_args.config_file and not os.path.isfile('.stestr.conf'): self._create_stestr_conf() elif not os.path.isfile('.stestr.conf'): print("No .stestr.conf file was found for local execution") sys.exit(2) if parsed_args.state: self._init_state() regex = self._build_regex(parsed_args) # temporary method for parsing deprecated and new stestr options # and showing warning messages in order to make the transition # smoother for all tempest consumers # TODO(kopecmartin) remove this after stestr>=3.1.0 is used # in all supported OpenStack releases def parse_dep(old_o, old_v, new_o, new_v): ret = '' if old_v: LOG.warning("'%s' option is deprecated, use '%s' instead " "which is functionally equivalent. Right now " "Tempest still supports this option for " "backward compatibility, however, it will be " "removed soon.", old_o, new_o) ret = old_v if old_v and new_v: # both options are specified LOG.warning("'%s' and '%s' are specified at the same time, " "'%s' takes precedence over '%s'", new_o, old_o, new_o, old_o) if new_v: ret = new_v return ret ex_regex = parse_dep('--black-regex', parsed_args.black_regex, '--exclude-regex', parsed_args.exclude_regex) ex_list = parse_dep('--blacklist-file', parsed_args.blacklist_file, '--exclude-list', parsed_args.exclude_list) in_list = parse_dep('--whitelist-file', parsed_args.whitelist_file, '--include-list', parsed_args.include_list) return_code = 0 if parsed_args.list_tests: try: return_code = commands.list_command( filters=regex, include_list=in_list, exclude_list=ex_list, exclude_regex=ex_regex) except TypeError: # exclude_list, include_list and exclude_regex are defined only # in stestr >= 3.1.0, this except block catches the case when # tempest is executed with an older stestr return_code = commands.list_command( filters=regex, whitelist_file=in_list, blacklist_file=ex_list, black_regex=ex_regex) else: serial = not parsed_args.parallel params = { 'filters': regex, 'subunit_out': parsed_args.subunit, 'serial': serial, 'concurrency': parsed_args.concurrency, 'worker_path': parsed_args.worker_file, 'load_list': parsed_args.load_list, 'combine': parsed_args.combine } try: return_code = commands.run_command( **params, exclude_list=ex_list, include_list=in_list, exclude_regex=ex_regex) except TypeError: # exclude_list, include_list and exclude_regex are defined only # in stestr >= 3.1.0, this except block catches the case when # tempest is executed with an older stestr return_code = commands.run_command( **params, blacklist_file=ex_list, whitelist_file=in_list, black_regex=ex_regex) if return_code > 0: sys.exit(return_code) return return_code