Merge pull request #146512 from DeterminateSystems/better-visibility

nixos/test-driver: more context when step finishes, give more functions nested labels
This commit is contained in:
Jacek Galowicz 2021-12-02 09:26:21 +00:00 committed by GitHub
commit 58371472fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,7 +171,7 @@ class Logger:
yield
self.drain_log_queue()
toc = time.time()
self.log("({:.2f} seconds)".format(toc - tic))
self.log("(finished: {}, in {:.2f} seconds)".format(message, toc - tic))
self.xml.endElement("nest")
@ -490,6 +490,7 @@ class Machine:
return rootlog.nested(msg, my_attrs)
def wait_for_monitor_prompt(self) -> str:
with self.nested("waiting for monitor prompt"):
assert self.monitor is not None
answer = ""
while True:
@ -502,8 +503,8 @@ class Machine:
return answer
def send_monitor_command(self, command: str) -> str:
with self.nested("sending monitor command: {}".format(command)):
message = ("{}\n".format(command)).encode()
self.log("sending monitor command: {}".format(command))
assert self.monitor is not None
self.monitor.send(message)
return self.wait_for_monitor_prompt()
@ -533,6 +534,11 @@ class Machine:
return state == "active"
with self.nested(
"waiting for unit {}{}".format(
unit, f" with user {user}" if user is not None else ""
)
):
retry(check_active)
def get_unit_info(self, unit: str, user: Optional[str] = None) -> Dict[str, str]:
@ -757,6 +763,7 @@ class Machine:
status, _ = self.execute("nc -z localhost {}".format(port))
return status != 0
with self.nested("waiting for TCP port {} to be closed"):
retry(port_is_closed)
def start_job(self, jobname: str, user: Optional[str] = None) -> Tuple[int, str]:
@ -891,7 +898,7 @@ class Machine:
retry(screen_matches)
def wait_for_console_text(self, regex: str) -> None:
self.log("waiting for {} to appear on console".format(regex))
with self.nested("waiting for {} to appear on console".format(regex)):
# Buffer the console output, this is needed
# to match multiline regexes.
console = io.StringIO()
@ -1019,7 +1026,7 @@ class Machine:
)
return any(pattern.search(name) for name in names)
with self.nested("Waiting for a window to appear"):
with self.nested("waiting for a window to appear"):
retry(window_is_visible)
def sleep(self, secs: int) -> None: