def test_simple_success(self): func = self.god.create_mock_function('func') func.expect_call(3) subcommand.parallel_simple(func, (3, )) self.god.check_playback()
def upkeep(self, custom_repos=None): ''' Clean up custom upload/download areas ''' from autotest.server import subcommand if not custom_repos: # Not all package types necessarily require or allow custom repos try: custom_repos = settings.get_value( 'PACKAGES', 'custom_upload_location').split(',') except SettingsError: custom_repos = [] try: custom_download = settings.get_value( 'PACKAGES', 'custom_download_location') custom_repos += [custom_download] except SettingsError: pass if not custom_repos: return subcommand.parallel_simple(trim_custom_directories, custom_repos, log=False)
def test_simple_success(self): func = self.god.create_mock_function('func') func.expect_call(3) subcommand.parallel_simple(func, (3,)) self.god.check_playback()
def parallel_simple(self, function, machines, log=True, timeout=None, return_results=False): """ Run 'function' using parallel_simple, with an extra wrapper to handle the necessary setup for continuous parsing, if possible. If continuous parsing is already properly initialized then this should just work. :param function: A callable to run in parallel given each machine. :param machines: A list of machine names to be passed one per subcommand invocation of function. :param log: If True, output will be written to output in a subdirectory named after each machine. :param timeout: Seconds after which the function call should timeout. :param return_results: If True instead of an AutoServError being raised on any error a list of the results|exceptions from the function called on each arg is returned. [default: False] :raise error.AutotestError: If any of the functions failed. """ wrapper = self._make_parallel_wrapper(function, machines, log) return subcommand.parallel_simple(wrapper, machines, log=log, timeout=timeout, return_results=return_results)
def test_simple_return_value(self): func = self.god.create_mock_function('func') result = 1000 func.expect_call(3).and_return(result) self.assertEquals(subcommand.parallel_simple(func, (3,), return_results=True), [result]) self.god.check_playback()
def test_simple_return_value(self): func = self.god.create_mock_function('func') result = 1000 func.expect_call(3).and_return(result) self.assertEquals( subcommand.parallel_simple(func, (3, ), return_results=True), [result]) self.god.check_playback()
def upkeep(self, custom_repos=None): ''' Clean up custom upload/download areas ''' from autotest.server import subcommand if not custom_repos: # Not all package types necessarily require or allow custom repos try: custom_repos = settings.get_value('PACKAGES', 'custom_upload_location').split(',') except SettingsError: custom_repos = [] try: custom_download = settings.get_value('PACKAGES', 'custom_download_location') custom_repos += [custom_download] except SettingsError: pass if not custom_repos: return subcommand.parallel_simple(trim_custom_directories, custom_repos, log=False)
def parallel_simple(self, function, machines, log=True, timeout=None, return_results=False): """ Run 'function' using parallel_simple, with an extra wrapper to handle the necessary setup for continuous parsing, if possible. If continuous parsing is already properly initialized then this should just work. @param function: A callable to run in parallel given each machine. @param machines: A list of machine names to be passed one per subcommand invocation of function. @param log: If True, output will be written to output in a subdirectory named after each machine. @param timeout: Seconds after which the function call should timeout. @param return_results: If True instead of an AutoServError being raised on any error a list of the results|exceptions from the function called on each arg is returned. [default: False] @raises error.AutotestError: If any of the functions failed. """ wrapper = self._make_parallel_wrapper(function, machines, log) return subcommand.parallel_simple(wrapper, machines, log=log, timeout=timeout, return_results=return_results)
def test_nolog(self): func, args = self._setup_many(3, False) subcommand.parallel_simple(func, args, log=False) self.god.check_playback()
def test_passthrough(self): func, args = self._setup_many(4, True) subcommand.parallel_simple(func, args) self.god.check_playback()