def test_construct_from_dict_for_valid_conf_with_only_required_fields(self): config_dict = { 'commands': ['shell command 1', 'shell command 2;'], 'atomizers': [{'TESTPATH': 'atomizer command'}], } job_config = JobConfig.construct_from_dict('some_job_name', config_dict) self.assertEquals(job_config.command, 'shell command 1 && shell command 2') self.assertEquals(job_config.name, 'some_job_name')
def test_construct_from_dict_for_valid_conf_with_only_required_fields( self): config_dict = { 'commands': ['shell command 1', 'shell command 2;'], 'atomizers': [{ 'TESTPATH': 'atomizer command' }], } job_config = JobConfig.construct_from_dict('some_job_name', config_dict) self.assertEquals(job_config.command, 'shell command 1 && shell command 2') self.assertEquals(job_config.name, 'some_job_name')
def job_config(self): """ Return the job config found in this project_type and matching any job_name parameter passed in :rtype: JobConfig """ if not self._job_config: # If the config was specified in the POST request, then there is no need to parse clusterrunner.yaml if self._config is not None: self._job_config = JobConfig.construct_from_dict(self._job_name, self._config) return self._job_config # Get job configuration from clusterrunner.yaml in repo. config = ClusterRunnerConfig(self._get_clusterrunner_config_file_contents()) self._job_config = config.get_job_config(self._job_name) return self._job_config
def test_construct_from_dict_for_valid_conf_with_all_fields(self): config_dict = { 'commands': ['shell command 1', 'shell command 2;'], 'atomizers': [{'TESTPATH': 'atomizer command'}], 'setup_build': ['setup command 1;', 'setup command 2;'], 'teardown_build': ['teardown command 1;', 'teardown command 2;'], 'max_executors': 100, 'max_executors_per_slave': 2, } job_config = JobConfig.construct_from_dict('some_job_name', config_dict) self.assertEquals(job_config.command, 'shell command 1 && shell command 2') self.assertEquals(job_config.name, 'some_job_name') self.assertEquals(job_config.setup_build, 'setup command 1 && setup command 2') self.assertEquals(job_config.teardown_build, 'teardown command 1 && teardown command 2') self.assertEquals(job_config.max_executors, 100) self.assertEquals(job_config.max_executors_per_slave, 2)
def _parse_raw_config(self): """ Validate the parsed yaml structure. This method raises on validation errors. If validation is successful, add the job configs to this class instance. :param config: The parsed yaml data :type config: dict """ config = yaml.safe_load(self._raw_yaml_contents) if not isinstance(config, dict): raise ConfigParseError('The yaml config file could not be parsed to a dictionary') self._job_configs = {} for job_name, job_config_sections in config.items(): self._job_configs[job_name] = JobConfig.construct_from_dict(job_name, job_config_sections) if len(self._job_configs) == 0: raise ConfigParseError('No jobs found in the config.')
def test_construct_from_dict_for_valid_conf_with_all_fields(self): config_dict = { 'commands': ['shell command 1', 'shell command 2;'], 'atomizers': [{ 'TESTPATH': 'atomizer command' }], 'setup_build': ['setup command 1;', 'setup command 2;'], 'teardown_build': ['teardown command 1;', 'teardown command 2;'], 'max_executors': 100, 'max_executors_per_slave': 2, } job_config = JobConfig.construct_from_dict('some_job_name', config_dict) self.assertEquals(job_config.command, 'shell command 1 && shell command 2') self.assertEquals(job_config.name, 'some_job_name') self.assertEquals(job_config.setup_build, 'setup command 1 && setup command 2') self.assertEquals(job_config.teardown_build, 'teardown command 1 && teardown command 2') self.assertEquals(job_config.max_executors, 100) self.assertEquals(job_config.max_executors_per_slave, 2)
def test_construct_from_dict_raise_error_without_requried_fields( self, config_dict): with self.assertRaises(ConfigValidationError): JobConfig.construct_from_dict('some_job_name', config_dict)
def test_construct_from_dict_raise_error_without_requried_fields(self, config_dict): with self.assertRaises(ConfigValidationError): JobConfig.construct_from_dict('some_job_name', config_dict)