Unverified Commit 4c907dbb authored by Maximilian Bosch's avatar Maximilian Bosch
Browse files

Revert "nixos-test-driver: use info/error/debug log feature more"

parent 90c63c24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ class Driver:
        vlan_symbols = {
            f"vlan{v.nr}": self.vlans[idx] for idx, v in enumerate(self.vlans)
        }
        self.logger.debug(
        print(
            "additionally exposed symbols:\n    "
            + ", ".join(map(lambda m: m.name, self.machines))
            + ",\n    "
+2 −2
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ class TerminalLogger(AbstractLogger):
        tic = time.time()
        yield
        toc = time.time()
        self.info(f"(finished: {message}, in {toc - tic:.2f} seconds)", attributes)
        self.log(f"(finished: {message}, in {toc - tic:.2f} seconds)", attributes)

    def debug(self, *args, **kwargs) -> None:
        if self._log_level <= LogLevel.DEBUG:
@@ -379,6 +379,6 @@ class XMLLogger(AbstractLogger):
        yield
        self.drain_log_queue()
        toc = time.time()
        self.info(f"(finished: {message}, in {toc - tic:.2f} seconds)")
        self.log(f"(finished: {message}, in {toc - tic:.2f} seconds)")

        self.xml.endElement("nest")
+10 −22
Original line number Diff line number Diff line
@@ -271,18 +271,6 @@ class BaseMachine(ABC):
        """
        self.logger.log(msg, {"machine": self.name})

    def debug(self, msg: str) -> None:
        """
        Log a message to console with log level for debug.
        """
        self.logger.debug(msg, {"machine": self.name})

    def error(self, msg: str) -> None:
        """
        Log a message to console with log level for error.
        """
        self.logger.error(msg, {"machine": self.name})

    def log_serial(self, msg: str) -> None:
        self.logger.log_serial(msg, self.name)

@@ -867,7 +855,7 @@ class QemuMachine(BaseMachine):
        def tty_matches(last_try: bool) -> bool:
            text = self.get_tty_text(tty)
            if last_try:
                self.debug(
                self.log(
                    f"Last chance to match /{regexp}/ on TTY{tty}, "
                    f"which currently contains: {text}"
                )
@@ -1073,8 +1061,8 @@ class QemuMachine(BaseMachine):

            toc = time.time()

            self.debug("connected to guest root shell")
            self.debug(f"(connecting took {toc - tic:.2f} seconds)")
            self.log("connected to guest root shell")
            self.log(f"(connecting took {toc - tic:.2f} seconds)")
            self.connected = True

    @contextmanager
@@ -1237,7 +1225,7 @@ class QemuMachine(BaseMachine):
        if self.booted:
            return

        self.debug("starting vm")
        self.log("starting vm")

        def clear(path: Path) -> Path:
            if path.exists():
@@ -1311,7 +1299,7 @@ class QemuMachine(BaseMachine):
        self.pid = self.process.pid
        self.booted = True

        self.debug(f"QEMU running (pid {self.pid})")
        self.log(f"QEMU running (pid {self.pid})")

    def shutdown(self) -> None:
        """
@@ -1414,7 +1402,7 @@ class QemuMachine(BaseMachine):
    def release(self) -> None:
        if self.pid is None:
            return
        self.logger.debug(f"kill QemuMachine (pid {self.pid})")
        self.logger.info(f"kill QemuMachine (pid {self.pid})")
        assert self.process
        assert self.shell
        assert self.monitor
@@ -1504,7 +1492,7 @@ class NspawnMachine(BaseMachine):
        if self.machine_sock:
            self.machine_sock.close()

        self.logger.debug(f"kill NspawnMachine (pid {self.pid})")
        self.logger.info(f"kill NspawnMachine (pid {self.pid})")
        assert self.process is not None
        self.process.terminate()
        self.process = None
@@ -1622,7 +1610,7 @@ class NspawnMachine(BaseMachine):
        proc = self.process

        # 1. Wait for the directory to actually be created by the container
        self.debug(f"Waiting for journal at {journal_path}...")
        self.log(f"Waiting for journal at {journal_path}...")
        max_attempts = 10
        attempts = 0
        while not journal_path.exists() and attempts < max_attempts:
@@ -1659,7 +1647,7 @@ class NspawnMachine(BaseMachine):
                        if proc.poll() is not None:
                            break
                except Exception as e:
                    self.error(f"Error while reading journalctl output: {e}")
                    self.log(f"Error while reading journalctl output: {e}")
                finally:
                    log_proc.terminate()
                    log_proc.wait()
@@ -1697,7 +1685,7 @@ class NspawnMachine(BaseMachine):

        self.pid = self.process.pid

        self.debug(f"systemd-nspawn running (pid {self.pid})")
        self.log(f"systemd-nspawn running (pid {self.pid})")

        journal_thread = threading.Thread(target=self._stream_journal, daemon=True)
        journal_thread.start()