Skip to content

Commit

Permalink
fix(stress_thread): stop assuming current path
Browse files Browse the repository at this point in the history
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
```

(cherry picked from commit da6e8bb)
  • Loading branch information
fruch committed Dec 17, 2024
1 parent d0d629f commit 0dde12d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions sdcm/stress_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -287,14 +290,17 @@ 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
elif self.params.get("use_prepared_loaders"):
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 = ""
Expand All @@ -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'):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0dde12d

Please sign in to comment.