Skip to content

fix(top): leave saved_state unset in the sozu top e2e config - #1573

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/sozu-top-e2e-saved-state
Sep 26, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/sozu-top-e2e-saved-state

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes #1572

Cause

bin/tests/sozu_top_e2e.rs set saved_state = "". Config::load_from_path (command/src/config.rs:4176) replaces saved_state with saved_state_path(). For Some(""), metadata("") (:4375) reports NotFound, then File::create("") (:4378) fails with ENOENT, which becomes ConfigError::SaveStatePath. sozu start exits with StartMain(LoadConfig(SaveStatePath("failed to create state file '\"\"': No such file or directory (os error 2)"))) before the test reaches the command socket.

saved_state_path is unchanged since 2023-08-08 (9c2cbcc5) and the test landed on 2026-05-10 (8c430c21), so it has never passed.

Fix

The test config drops saved_state. The key is optional, and the config is meant to be minimal: command socket only, no listeners, no clusters, no state.

saved_state_path() is left alone. Neither doc/configure.md nor bin/config.toml describes an empty saved_state as a way to turn it off, and git grep 'saved_state = ""' finds only this test. Treating "" as None would add a new config contract to fix a test typo.

CI

The test stays out of CI. ci.yml already says why: no matrix cell enables tui. There is also a second reason: sozu top --snapshot still enters raw mode (render.rs, RawModeGuard::install → enable_raw_mode), and without a controlling terminal that fails with ResolvePath("sozu top render loop", … No such device or address (os error 6)). A CI step has no controlling terminal. This PR records that in the test doc and in the CI comment.

Follow-up, out of scope here: --snapshot is documented as "no terminal control" (bin/src/cli.rs), but it does take control of the terminal. Once snapshot mode stops touching the terminal, the test could run in CI.

Verification

Red, then green, both run under a Python pty.spawn wrapper that provides a controlling terminal:

  • before: cargo test -p sozu --features tui --test sozu_top_e2e -- --include-ignored → exit 101, SaveStatePath("failed to create state file '\"\"' …"), 2 passed / 1 failed
  • after: same command → exit 0, 3 passed

Also run, each checked for exit 0: build and clippy (--no-default-features --features crypto-ring,opentelemetry,splice,simd, --all-targets -D warnings), cargo clippy -p sozu --features tui --all-targets -- -D warnings, cargo +nightly fmt --all -- --check, tests for sozu / sozu-command-lib / sozu-lib, the three process-level e2e files with --ignored, the four check_doc_citations.py modes, and RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --locked.

Signed-off-by: Florentin Dubois [email protected]

`sozu_top_tick_once_against_real_master` configured `saved_state = ""`.
An empty `saved_state` is a path, not an opt-out: `load_from_path`
replaces it with `saved_state_path()`, whose `metadata("")` reports
NotFound and whose `File::create("")` then fails with ENOENT, so
`sozu start` exits with `SaveStatePath("failed to create state file
'\"\"'")` before the test reaches the command socket. That code is
unchanged since 2023, so the test has failed this way since it was
added. Its config is meant to be minimal and wants no saved state, so
the key is dropped; the configuration contract stays as documented.

The test also needs a controlling terminal: `sozu top --snapshot` still
enters raw mode and fails with ENXIO without one. The test doc and the
CI comment that keeps it out of the process-level e2e step now say so.

Closes #1572

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the fix/sozu-top-e2e-saved-state branch from 947c68b to 0648e57 Compare September 26, 2026 15:48
@FlorentinDUBOIS
FlorentinDUBOIS merged commit bbb78cb into main Sep 26, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the fix/sozu-top-e2e-saved-state branch September 26, 2026 16:53
FlorentinDUBOIS added a commit that referenced this pull request Sep 26, 2026
…#1575)

Closes #1574

## Cause

`sozu top --snapshot N` is documented in `bin/src/cli.rs` as a "test affordance, no terminal control", but `render::run` installed `RawModeGuard` unconditionally (`bin/src/ctl/top/render.rs`, `let _guard = RawModeGuard::install(cfg.mouse)?;`). Its `enable_raw_mode()` reaches crossterm 0.29's `tty_fd()`, which opens `/dev/tty` when stdin is not a terminal. Without a controlling terminal that open fails with ENXIO, and `ctl/top/mod.rs` wraps it as `ResolvePath("sozu top render loop", … os error 6)`.

Removing the guard alone would not be enough: `event::poll` lazily builds crossterm's event source, which calls `tty_fd()` too, and `Terminal::new` (a fullscreen viewport) asks the backend for the terminal size.

## Fix

Only when `--snapshot` is set, `render::run` now:

- enters neither raw mode nor the alternate screen, and captures no mouse (no `RawModeGuard`);
- installs no terminal-restoring panic hook, since there is nothing to restore;
- reads no input: the loop sleeps for its pacing interval instead of calling `poll`/`read`;
- draws into a fixed 80x24 `Viewport::Fixed`, which ratatui 0.30 neither sizes from nor resizes to the terminal (`Terminal::with_options` and `autoresize` both skip `backend.size()` for a fixed viewport). 80x24 is the smaller of the two sizes the `insta` tests render every pane at.

Frames go to stdout as ANSI escape sequences. Interactive mode and `--tick-once` are unchanged.

## CI

`sozu_top_e2e` now passes without a pty, so a new step runs it on the `msrv-full` cell only. That cell already resolves the `tui` feature for `cargo doc --all-features`, so the added cost is one build of the `sozu` binary with `tui`, once per pipeline. The step also runs the two non-ignored `sozu top` tests, which no cell ran before. The `.github/workflows/ci.yml` comment that kept the test out, the test's doc comment, and the last sentence of #1573's CHANGELOG entry now say it runs.

## Verification

Run outside a pty (`tty` reports "not a tty"):

- before the fix: `cargo test -p sozu --features tui --test sozu_top_e2e -- --include-ignored` exits 101, `sozu_top_tick_once_against_real_master` fails with `could not resolve path for sozu top render loop : No such device or address (os error 6)`;
- after the fix, the same command: exit 0, 3 passed. The new CI step's command, `cargo test -p sozu --locked --features opentelemetry,splice,simd --features tui --test sozu_top_e2e -- --include-ignored`, run with stdin at `/dev/null`: exit 0, 3 passed;
- `cargo build`, `cargo clippy --all-targets -D warnings` (`crypto-ring,opentelemetry,splice,simd`, and `-p sozu --features tui`), `cargo +nightly fmt --check`, `cargo test -p sozu` (ring features, 226 passed), the three other `bin/tests/*_e2e` with `--ignored`, `cargo test -p sozu-command-lib` (184 passed), the four `check_doc_citations.py` invocations and `RUSTDOCFLAGS="-D warnings" cargo doc --all-features`: all exit 0.

## Out of scope

- `cargo test -p sozu --features tui` fails on `snapshot_h2_120x40`: the H2 pane now lists `rst_stream_dropped` (since #1434) but the `.snap` file does not. It fails identically with this PR's `render.rs` reverted, `origin/main`'s snapshot lacks the row too, and no CI cell runs that suite.
- The e2e takes about 30 s both before and after this change. It already did when the render loop failed on its first call, so the time is spent outside the loop; its cause was not investigated here.

Signed-off-by: Florentin Dubois <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sozu_top_e2e fails on main: an empty saved_state is rejected at config load

1 participant