From 0fead9d96b64216702c17281b156ab1efa990520 Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Mon, 16 Dec 2024 09:56:39 +0200 Subject: [PATCH] fix(stress_thread): stop assuming current path cause code assumed HDR to be located on `$HOME`, in some situations like in the intergation tests of c-s, it wasn't finding it and failing like the following: ``` FAILED unit_tests/test_cassandra_stress_thread.py::test_01_cassandra_stress - invoke.exceptions.UnexpectedExit: Encountered a bad command exit code! Command: 'cp cs-hdr-write-l1-c0-k1-4bf4051d-abc0-4c0d-840d-f0af5c6b6e8a.hdr /home/ubuntu/scylla-cluster-tests/unit_tests/ cs-hdr-write-l1-c0-k1-4bf4051d-abc0-4c0d-840d-f0af5c6b6e8a.hdr' Exit code: 1 Stdout: Stderr: cp: cannot stat 'cs-hdr-write-l1-c0-k1-4bf4051d-abc0-4c0d-840d-f0af5c6b6e8a.hdr': No such file or directory ``` --- sdcm/stress_thread.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sdcm/stress_thread.py b/sdcm/stress_thread.py index 7d366ec153..49dbdfdb1c 100644 --- a/sdcm/stress_thread.py +++ b/sdcm/stress_thread.py @@ -98,9 +98,12 @@ def validate_and_collect_hdr_file(self): if not result.ok: HDRFileMissed(message=f"'{self._remote_log_file}' HDR file was not created on the loader {self._node.name}", severity=Severity.ERROR).publish() - - LOGGER.debug("The '%s' file found on the loader %s", self._remote_log_file, self._node.name) - self._node.remoter.receive_files(src=self._remote_log_file, dst=self._target_log_file) + try: + LOGGER.debug("The '%s' file found on the loader %s", self._remote_log_file, self._node.name) + self._node.remoter.receive_files(src=self._remote_log_file, dst=self._target_log_file) + except Exception: # noqa: BLE001 + HDRFileMissed(message=f"'{self._remote_log_file}' HDR file couldn't copied from loader {self._node.name}", + severity=Severity.ERROR).publish() def __enter__(self): self.start() @@ -287,6 +290,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: local_hdr_file_name = os.path.join(loader.logdir, remote_hdr_file_name) LOGGER.debug("cassandra-stress HDR local file %s", local_hdr_file_name) + remote_hdr_file_name_full_path = remote_hdr_file_name if "k8s" in self.params.get("cluster_backend"): cmd_runner = loader.remoter cmd_runner_name = loader.remoter.pod_name @@ -294,7 +298,9 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: cmd_runner = loader.remoter cmd_runner_name = loader.ip_address else: - loader.remoter.run(f"touch $HOME/{remote_hdr_file_name}", ignore_status=True, verbose=False) + loader.remoter.run(f"touch $HOME/{remote_hdr_file_name}", ignore_status=False, verbose=False) + remote_hdr_file_name_full_path = loader.remoter.run( + f"realpath $HOME/{remote_hdr_file_name}", ignore_status=False, verbose=False).stdout.strip() cmd_runner_name = loader.ip_address cpu_options = "" @@ -306,7 +312,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: f'--label shell_marker={self.shell_marker}' f' --entrypoint /bin/bash' f' -w /' - f' -v $HOME/{remote_hdr_file_name}:/{remote_hdr_file_name}') + f' -v {remote_hdr_file_name_full_path}:/{remote_hdr_file_name}') stress_cmd = self.create_stress_cmd(cmd_runner, keyspace_idx, loader) if self.params.get('cs_debug'): @@ -337,7 +343,7 @@ def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: stress_cmd = self._add_hdr_log_option(stress_cmd, remote_hdr_file_name) hdr_logger_context = CSHDRFileLogger( node=loader, - remote_log_file=remote_hdr_file_name, + remote_log_file=remote_hdr_file_name_full_path, target_log_file=os.path.join(loader.logdir, remote_hdr_file_name), ) else: