def test_cluster_client_config_path(self, tmpdir, reactor_config_map, extra_config, fallback, error): config = 'version: 1' if extra_config: config += '\n' + extra_config if reactor_config_map and config: os.environ['REACTOR_CONFIG'] = config else: filename = os.path.join(str(tmpdir), 'config.yaml') with open(filename, 'w') as fp: fp.write(config) tasker, workflow = self.prepare() plugin = ReactorConfigPlugin(tasker, workflow, config_path=str(tmpdir)) assert plugin.run() is None os.environ.pop('REACTOR_CONFIG', None) if error: with pytest.raises(error): get_clusters_client_config_path(workflow, fallback) else: path = get_clusters_client_config_path(workflow, fallback) assert path == '/the/path/osbs.conf'
def test_cluster_client_config_path(self, tmpdir, reactor_config_map, extra_config, fallback, error): config = 'version: 1' if extra_config: config += '\n' + extra_config if reactor_config_map and config: os.environ['REACTOR_CONFIG'] = config else: filename = os.path.join(str(tmpdir), 'config.yaml') with open(filename, 'w') as fp: fp.write(config) tasker, workflow = self.prepare() plugin = ReactorConfigPlugin(tasker, workflow, config_path=str(tmpdir)) assert plugin.run() is None os.environ.pop('REACTOR_CONFIG', None) if error: with pytest.raises(error): get_clusters_client_config_path(workflow, fallback) else: path = get_clusters_client_config_path(workflow, fallback) assert path == '/the/path/osbs.conf'
def get_cluster_info(self, cluster, platform): kwargs = deepcopy(self.config_kwargs) kwargs['conf_section'] = cluster.name kwargs['conf_file'] = get_clusters_client_config_path(self.workflow, self.osbs_client_config_fallback) if platform in self.build_image_digests: kwargs['build_image'] = self.build_image_digests[platform] else: raise RuntimeError("build_image for platform '%s' not available" % platform) osbs = self._get_openshift_session(kwargs) current_builds = self.get_current_builds(osbs) load = current_builds / cluster.max_concurrent_builds self.log.debug('enabled cluster %s for platform %s has load %s and active builds %s/%s', cluster.name, platform, load, current_builds, cluster.max_concurrent_builds) return ClusterInfo(cluster, platform, osbs, load)
def get_cluster_info(self, cluster, platform): kwargs = deepcopy(self.config_kwargs) kwargs['conf_section'] = cluster.name kwargs['conf_file'] = get_clusters_client_config_path(self.workflow, self.osbs_client_config_fallback) if platform in self.build_image_digests: kwargs['build_image'] = self.build_image_digests[platform] else: raise RuntimeError("build_image for platform '%s' not available" % platform) osbs = self._get_openshift_session(kwargs) current_builds = self.get_current_builds(osbs) load = current_builds / cluster.max_concurrent_builds self.log.debug('enabled cluster %s for platform %s has load %s and active builds %s/%s', cluster.name, platform, load, current_builds, cluster.max_concurrent_builds) return ClusterInfo(cluster, platform, osbs, load)