def stop_all_clusters(self) -> None: """Stop all cluster instances.""" self._log("called `stop_all_clusters`") for instance_num in range(self.num_of_instances): instance_dir = self.lock_dir / f"{CLUSTER_DIR_TEMPLATE}{instance_num}" if (not (instance_dir / CLUSTER_RUNNING_FILE).exists() or (instance_dir / CLUSTER_STOPPED_FILE).exists()): self._log(f"cluster instance {instance_num} not running") continue startup_files = cluster_nodes.get_cluster_type( ).cluster_scripts.prepare_scripts_files( destdir=self._create_startup_files_dir(instance_num), instance_num=instance_num, ) cluster_nodes.set_cluster_env(instance_num) self._log( f"stopping cluster instance {instance_num} with `{startup_files.stop_script}`" ) state_dir = cluster_nodes.get_cluster_env().state_dir try: cluster_nodes.stop_cluster(cmd=str(startup_files.stop_script)) except Exception as exc: LOGGER.error(f"While stopping cluster: {exc}") cli_coverage.save_start_script_coverage( log_file=state_dir / CLUSTER_START_CMDS_LOG, pytest_config=self.pytest_config, ) cluster_nodes.save_cluster_artifacts( artifacts_dir=self.pytest_tmp_dir, clean=True) open(instance_dir / CLUSTER_STOPPED_FILE, "a").close() self._log(f"stopped cluster instance {instance_num}")
def _restart_save_cluster_artifacts(self, clean: bool = False) -> None: """Save cluster artifacts (logs, certs, etc.) to pytest temp dir before cluster restart.""" cluster_obj = self.cm.cache.cluster_obj if not cluster_obj: return cluster_nodes.save_cluster_artifacts( artifacts_dir=self.cm.pytest_tmp_dir, clean=clean)