Log nsenter command on container tests

This commit is contained in:
pinpox
2025-05-05 12:57:30 +02:00
parent 23d19f1a52
commit 1708176dce

View File

@@ -187,6 +187,22 @@ class Machine:
if line_pattern.match(line)
)
def nsenter_command(self, command: str) -> list[str]:
return [
"nsenter",
"--target",
str(self.container_pid),
"--mount",
"--uts",
"--ipc",
"--net",
"--pid",
"--cgroup",
"/bin/sh",
"-c",
command,
]
def execute(
self,
command: str,
@@ -231,20 +247,7 @@ class Machine:
command = f"set -eo pipefail; source /etc/profile; set -u; {command}"
proc = subprocess.run(
[
"nsenter",
"--target",
str(self.container_pid),
"--mount",
"--uts",
"--ipc",
"--net",
"--pid",
"--cgroup",
"/bin/sh",
"-c",
command,
],
self.nsenter_command(command),
timeout=timeout,
check=False,
stdout=subprocess.PIPE,
@@ -465,6 +468,9 @@ class Driver:
print(f"Starting {machine.name}")
machine.start()
for machine in self.machines:
print(machine.nsenter_command("bash"))
def test_symbols(self) -> dict[str, Any]:
general_symbols = {
"start_all": self.start_all,