def test_keyboard_interrupt(self): processor_keyboard_interrupt = _instantiate(MockResultProcessor3) # adding the results processor to the result manager manager = ResultManager() assert_false(manager.processors) # adding the results processor to the result manager manager.install(processor_keyboard_interrupt) assert_equal(len(manager.processors), 1) assert_raises(KeyboardInterrupt, manager.add_result, None, None)
def test_add_result(self): processor_generic_exception = _instantiate(MockResultProcessor1) processor_wa_error = _instantiate(MockResultProcessor2) processor = _instantiate(MockResultProcessor4) # adding the results processor to the result manager manager = ResultManager() assert_false(manager.processors) # adding the results processor to the result manager manager.install(processor_generic_exception) manager.install(processor_wa_error) manager.install(processor) assert_equal(len(manager.processors), 3) manager.add_result(None, None) assert_true(processor.is_invoked)
def execute(self, agenda, selectors=None): # NOQA """ Execute the run specified by an agenda. Optionally, selectors may be used to only selecute a subset of the specified agenda. Params:: :agenda: an ``Agenda`` instance to be executed. :selectors: A dict mapping selector name to the coresponding values. **Selectors** Currently, the following seectors are supported: ids The value must be a sequence of workload specfication IDs to be executed. Note that if sections are specified inthe agenda, the workload specifacation ID will be a combination of the section and workload IDs. """ signal.connect(self._error_signalled_callback, signal.ERROR_LOGGED) signal.connect(self._warning_signalled_callback, signal.WARNING_LOGGED) self.logger.info('Initializing') self.ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) self.logger.debug('Loading run configuration.') self.config = RunConfiguration(self.ext_loader) for filepath in settings.get_config_paths(): self.config.load_config(filepath) self.config.set_agenda(agenda, selectors) self.config.finalize() config_outfile = os.path.join(settings.meta_directory, 'run_config.json') with open(config_outfile, 'w') as wfh: self.config.serialize(wfh) self.logger.debug('Initialising device configuration.') if not self.config.device: raise ConfigError('Make sure a device is specified in the config.') self.device = self.ext_loader.get_device(self.config.device, **self.config.device_config) self.device.validate() self.context = ExecutionContext(self.device, self.config) self.logger.debug('Loading resource discoverers.') self.context.initialize() self.context.resolver.load() self.context.add_artifact('run_config', config_outfile, 'meta') self.logger.debug('Installing instrumentation') for name, params in self.config.instrumentation.iteritems(): instrument = self.ext_loader.get_instrument( name, self.device, **params) instrumentation.install(instrument) instrumentation.validate() self.logger.debug('Installing result processors') result_manager = ResultManager() for name, params in self.config.result_processors.iteritems(): processor = self.ext_loader.get_result_processor(name, **params) result_manager.install(processor) result_manager.validate() self.logger.debug('Loading workload specs') for workload_spec in self.config.workload_specs: workload_spec.load(self.device, self.ext_loader) workload_spec.workload.init_resources(self.context) workload_spec.workload.validate() if self.config.flashing_config: if not self.device.flasher: msg = 'flashing_config specified for {} device that does not support flashing.' raise ConfigError(msg.format(self.device.name)) self.logger.debug('Flashing the device') self.device.flasher.flash(self.device) self.logger.info('Running workloads') runner = self._get_runner(result_manager) runner.init_queue(self.config.workload_specs) runner.run() self.execute_postamble()
def execute(self, agenda, selectors=None): # NOQA """ Execute the run specified by an agenda. Optionally, selectors may be used to only selecute a subset of the specified agenda. Params:: :agenda: an ``Agenda`` instance to be executed. :selectors: A dict mapping selector name to the coresponding values. **Selectors** Currently, the following seectors are supported: ids The value must be a sequence of workload specfication IDs to be executed. Note that if sections are specified inthe agenda, the workload specifacation ID will be a combination of the section and workload IDs. """ signal.connect(self._error_signalled_callback, signal.ERROR_LOGGED) signal.connect(self._warning_signalled_callback, signal.WARNING_LOGGED) self.logger.info('Initializing') self.ext_loader = ExtensionLoader(packages=settings.extension_packages, paths=settings.extension_paths) self.logger.debug('Loading run configuration.') self.config = RunConfiguration(self.ext_loader) for filepath in settings.get_config_paths(): self.config.load_config(filepath) self.config.set_agenda(agenda, selectors) self.config.finalize() config_outfile = os.path.join(settings.meta_directory, 'run_config.json') with open(config_outfile, 'w') as wfh: self.config.serialize(wfh) self.logger.debug('Initialising device configuration.') if not self.config.device: raise ConfigError('Make sure a device is specified in the config.') self.device = self.ext_loader.get_device(self.config.device, **self.config.device_config) self.device.validate() self.context = ExecutionContext(self.device, self.config) self.logger.debug('Loading resource discoverers.') self.context.initialize() self.context.resolver.load() self.context.add_artifact('run_config', config_outfile, 'meta') self.logger.debug('Installing instrumentation') for name, params in self.config.instrumentation.iteritems(): instrument = self.ext_loader.get_instrument(name, self.device, **params) instrumentation.install(instrument) instrumentation.validate() self.logger.debug('Installing result processors') result_manager = ResultManager() for name, params in self.config.result_processors.iteritems(): processor = self.ext_loader.get_result_processor(name, **params) result_manager.install(processor) result_manager.validate() self.logger.debug('Loading workload specs') for workload_spec in self.config.workload_specs: workload_spec.load(self.device, self.ext_loader) workload_spec.workload.init_resources(self.context) workload_spec.workload.validate() if self.config.flashing_config: if not self.device.flasher: msg = 'flashing_config specified for {} device that does not support flashing.' raise ConfigError(msg.format(self.device.name)) self.logger.debug('Flashing the device') self.device.flasher.flash(self.device) self.logger.info('Running workloads') runner = self._get_runner(result_manager) runner.init_queue(self.config.workload_specs) runner.run() self.execute_postamble()