Log nsenter command on container tests
This commit is contained in:
@@ -187,6 +187,22 @@ class Machine:
|
|||||||
if line_pattern.match(line)
|
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(
|
def execute(
|
||||||
self,
|
self,
|
||||||
command: str,
|
command: str,
|
||||||
@@ -231,20 +247,7 @@ class Machine:
|
|||||||
command = f"set -eo pipefail; source /etc/profile; set -u; {command}"
|
command = f"set -eo pipefail; source /etc/profile; set -u; {command}"
|
||||||
|
|
||||||
proc = subprocess.run(
|
proc = subprocess.run(
|
||||||
[
|
self.nsenter_command(command),
|
||||||
"nsenter",
|
|
||||||
"--target",
|
|
||||||
str(self.container_pid),
|
|
||||||
"--mount",
|
|
||||||
"--uts",
|
|
||||||
"--ipc",
|
|
||||||
"--net",
|
|
||||||
"--pid",
|
|
||||||
"--cgroup",
|
|
||||||
"/bin/sh",
|
|
||||||
"-c",
|
|
||||||
command,
|
|
||||||
],
|
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
check=False,
|
check=False,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@@ -465,6 +468,9 @@ class Driver:
|
|||||||
print(f"Starting {machine.name}")
|
print(f"Starting {machine.name}")
|
||||||
machine.start()
|
machine.start()
|
||||||
|
|
||||||
|
for machine in self.machines:
|
||||||
|
print(machine.nsenter_command("bash"))
|
||||||
|
|
||||||
def test_symbols(self) -> dict[str, Any]:
|
def test_symbols(self) -> dict[str, Any]:
|
||||||
general_symbols = {
|
general_symbols = {
|
||||||
"start_all": self.start_all,
|
"start_all": self.start_all,
|
||||||
|
|||||||
Reference in New Issue
Block a user