Commit 9ba40ae1 authored by Ramon Nou's avatar Ramon Nou
Browse files

fix(ci): align formatting and expose daemon startup errors

parent 3579650e
Loading
Loading
Loading
Loading
Loading
+6 −3
Changes for scripts/check_format.sh: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ optional arguments:
                        (default: 'pwd/include')
    -c <CLANG_FORMAT_BIN>, --clang_format_path <CLANG_FORMAT_BIN>
                        path to clang-format binary
                        (default: looks for 'clang-format', 'clang-format-22', or 'clang-format-19')
                        (default: prefers CI's 'clang-format-22', then 'clang-format' or 'clang-format-19')
    -r, --run_format    run clang-formatter before formatting check
                        DISCLAIMER: FILES ARE MODIFIED IN PLACE!
    -v, --verbose       shows the diff of all files
@@ -114,10 +114,10 @@ done
set -- "${POSITIONAL[@]}" # restore positional parameters

# check for clang-format executable if it hasn't been set by the user
if [[ -z $CLANG_FORMAT_BIN ]]; then
    CLANG_FORMAT_BIN=$(command -v clang-format)
if [[ -z $CLANG_FORMAT_BIN ]]; then
    CLANG_FORMAT_BIN=$(command -v clang-format-22)
    if [[ -z $CLANG_FORMAT_BIN ]]; then
        CLANG_FORMAT_BIN=$(command -v clang-format)
        if [[ -z $CLANG_FORMAT_BIN ]]; then
            CLANG_FORMAT_BIN=$(command -v clang-format-19)
            # if it still doesn't exist exit
@@ -130,6 +130,9 @@ if [[ -z $CLANG_FORMAT_BIN ]]; then
fi
echo "* Using clang-format binary: $CLANG_FORMAT_BIN"
echo "* Using version: $($CLANG_FORMAT_BIN --version)"
if ! "$CLANG_FORMAT_BIN" --version | grep -Eq 'version 22\.'; then
    echo "*** WARNING: CI uses clang-format 22; other versions can produce different formatting."
fi

FAIL=false

+10 −1
Changes for tests/integration/harness/gkfs.py: 10 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -461,7 +461,15 @@ class Daemon:

        while perf_counter() - init_time < timeout:
            if self._proc.poll() is not None:
                 raise RuntimeError(f"process {self._proc.pid} exited with {self._proc.returncode}")
                log_path = self.logdir / gkfs_daemon_log_file
                try:
                    content = log_path.read_text(errors='replace')
                except OSError as ex:
                    content = f"Failed to read daemon log: {ex}"
                raise RuntimeError(
                    f"process {self._proc.pid} exited with {self._proc.returncode}"
                    f"\nDaemon log ({log_path}):\n{content}"
                )
            if read_daemon_readiness(readiness_path, pid) is not None:
                return
            if not _process_exists(pid):
@@ -488,6 +496,7 @@ class Daemon:
        except subprocess.TimeoutExpired:
            if self._proc:
                self._proc.kill()
                self._proc.wait()
        except Exception:
            raise
        finally:
+41 −0
Changes for tests/integration/startup/test_daemon_harness.py: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
"""Regression tests for startup diagnostics and forced daemon cleanup."""

import subprocess
from types import SimpleNamespace
from unittest.mock import Mock, call

import pytest

from harness.gkfs import Daemon, gkfs_daemon_log_file


@pytest.mark.parametrize("with_log", [True, False])
def test_daemon_early_exit_diagnostics(tmp_path, with_log):
    daemon = Daemon.__new__(Daemon)
    daemon._workspace = SimpleNamespace(logdir=tmp_path)
    daemon._hostfile = str(tmp_path / 'hosts')
    daemon._proc = Mock(pid=123, returncode=1)
    daemon._proc.poll.return_value = 1
    if with_log:
        (tmp_path / gkfs_daemon_log_file).write_text('Address already in use')

    with pytest.raises(RuntimeError, match='process 123 exited with 1') as error:
        daemon.wait_until_active(123, 1)

    assert str(tmp_path / gkfs_daemon_log_file) in str(error.value)
    expected = 'Address already in use' if with_log else 'Failed to read daemon log'
    assert expected in str(error.value)


def test_daemon_forced_shutdown_reaps_process():
    daemon = Daemon.__new__(Daemon)
    daemon._stdout = Mock()
    daemon._proc = Mock()
    daemon._proc.wait.side_effect = [subprocess.TimeoutExpired('daemon', 5), 0]

    daemon.shutdown()

    assert daemon._proc.mock_calls == [
        call.terminate(), call.wait(timeout=5), call.kill(), call.wait()
    ]
    daemon._stdout.close.assert_called_once_with()
 No newline at end of file
+2 −2

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.