def test_get_presto_conf(self, config_mock, props_mock, listdir_mock, isdir_mock): isdir_mock.return_value = True listdir_mock.return_value = ['log.properties', 'jvm.config', ] config_mock.return_value = ['prop1', 'prop2'] props_mock.return_value = {'a': '1', 'b': '2'} conf = get_presto_conf('dummy/dir') config_mock.assert_called_with('dummy/dir/jvm.config') props_mock.assert_called_with('dummy/dir/log.properties') self.assertEqual(conf, {'log.properties': {'a': '1', 'b': '2'}, 'jvm.config': ['prop1', 'prop2']})
def get_conf(self): conf = get_presto_conf(self._get_conf_dir()) for name in presto_conf.REQUIRED_FILES: if name not in conf: _LOGGER.debug('%s configuration for %s not found. ' 'Default configuration will be deployed', type(self).__name__, name) conf_value = self.default_config(name) conf[name] = conf_value file_path = os.path.join(self._get_conf_dir(), name) config.write_conf_to_file(conf_value, file_path) self.validate(conf) return conf
def test_get_presto_conf(self, config_mock, props_mock, listdir_mock, isdir_mock): isdir_mock.return_value = True listdir_mock.return_value = [ 'log.properties', 'jvm.config', ] config_mock.return_value = ['prop1', 'prop2'] props_mock.return_value = {'a': '1', 'b': '2'} conf = get_presto_conf('dummy/dir') config_mock.assert_called_with('dummy/dir/jvm.config') props_mock.assert_called_with('dummy/dir/log.properties') self.assertEqual( conf, { 'log.properties': { 'a': '1', 'b': '2' }, 'jvm.config': ['prop1', 'prop2'] })
def test_conf_not_exists_is_empty(self): self.assertEqual(get_presto_conf('/does/not/exist'), {})
def _get_conf(): return get_presto_conf(constants.COORDINATOR_DIR)
def _get_conf(): return get_presto_conf(constants.WORKERS_DIR)
def _get_conf(): return get_presto_conf(constants.COORDINATOR_DIR)
def test_conf_not_exists_is_empty(self): self.assertEqual(get_presto_conf('/does/not/exist'), {})