Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multihost tests #888

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/bluechi_test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ def exec_run(
LOGGER.debug(
f"Executed command '{command}' with result '{result}' and output '{output}' and error '{err}'"
)
return result, output

# concatenate stderr and stdout so exec_run of SSHClient
# outputs the same content as ContainerClient
return result, err + output
finally:
if stdin is not None:
stdin.close()
Expand Down
16 changes: 10 additions & 6 deletions tests/bluechi_test/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,20 @@ def copy_machine_lib(self):
# This message is relevant for `finish` phase, where code coverage report is being created
LOGGER.info("bluechilib directory not found, proceeding")
return
ret, _ = self.exec_run("mkdir /tmp/bluechi_machine_lib")
if ret == 0:
# If the directory was successfully created, then fill it with files
# If not - it must already exist

machine_lib_dir = "/tmp/bluechi_machine_lib"
_, output = self.client.exec_run(f"[ -d {machine_lib_dir} ] && echo 'exists'")
if output != "exists":
self.exec_run(f"mkdir {machine_lib_dir}")
for filename in os.listdir(source_dir):
source_path = os.path.join(source_dir, filename)
if os.path.isfile(source_path) and source_path.endswith(".py"):
content = read_file(source_path)
target_dir = os.path.join("/", "tmp", "bluechi_machine_lib")
self.create_file(target_dir, filename, content)
target_dir = os.path.join("/", "tmp", machine_lib_dir)

# Use client directly to bypass the tracking mechanism
# We don't want to clean up the bluechi_machine_lib files once created
self.client.create_file(target_dir, filename, content)

def wait_for_bluechi_agent(self):
should_wait = True
Expand Down
8 changes: 4 additions & 4 deletions tests/bluechi_test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,15 @@ def _cleanup(self, machine: BluechiMachine, other_tracked_service: List[str] = [
machine.systemctl.stop_unit(service, check_result=False)
machine.systemctl.reset_failed_for_unit(service, check_result=False)

LOGGER.info("Removing created files...")
cmd_rm_created_files = "rm " + " ".join(machine.created_files)
machine.client.exec_run(cmd_rm_created_files)

LOGGER.info("Restoring changed files...")
for changed_file in machine.changed_files:
backup_file = changed_file + BluechiMachine.backup_file_suffix
machine.client.exec_run(f"mv {backup_file} {changed_file}")

LOGGER.info("Removing created files...")
cmd_rm_created_files = "rm " + " ".join(machine.created_files)
machine.client.exec_run(cmd_rm_created_files)

# ensure changed systemd services are reloaded
machine.systemctl.daemon_reload()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def exec(ctrl: BluechiControllerMachine, _: Dict[str, BluechiAgentMachine]):
assert ctrl.wait_for_unit_state_to_be("bluechi-controller", "active")

original_cfg = ctrl.config.deep_copy()
original_cfg.file_name = "zzz-ctrl.conf"

# port contains an 'O' instead of a '0'
new_cfg = original_cfg.deep_copy()
Expand Down