Skip to content

Add an automated graceful-shutdown test for extenddb serve --foreground #137

@marvelefe

Description

@marvelefe

Problem or use case

PR #126 added --foreground for running extenddb serve under a process supervisor. The supervisor scenario relies on graceful SIGTERM shutdown: the process must drain in-flight connections, remove its PID file, and exit non-zero only on actual failure.

Today, this is verified manually (the PR description shows kill -TERM against a foreground process), but there's no automated coverage. A regression in the signal-handling path would not be caught by CI.

The reviewer on #126 explicitly suggested cutting this as a follow-up because the current test framework is not yet set up for whole-process lifecycle tests, so the work likely involves harness changes too.

Proposed solution

Add a Python integration test (or rust integration test under tests/) that:

  1. Spawns extenddb serve --foreground as a subprocess with stdout/stderr piped.
  2. Waits for the listener to come up (poll /health until 200, with a timeout).
  3. Optionally drives a PutItem through the AWS SDK to confirm a real request path is open.
  4. Sends SIGTERM to the child.
  5. Asserts the process exits with status 0 within a graceful-shutdown deadline (e.g., 10s).
  6. Asserts the PID file at ~/.extenddb/run/extenddb-<port>.pid was removed.
  7. Asserts stderr contains the expected Shutdown signal received, draining connections... log line.

This will probably require small additions to the test harness:

  • A way to launch extenddb with isolated ~/.extenddb/ (e.g., via HOME override or a --run-dir option).
  • A way to grep child stderr without racing the test runner.

Context

  • PR [Feature] Non-daemonized serve command #126 review comment by pdf-amzn, item 3.
  • Current foreground code path: crates/bin/src/cmd_serve.rs::run (skips daemonize block) and crates/server/src/lib.rs::start_server (existing graceful-shutdown handler).

Checklist

  • I have searched existing issues and the roadmap for duplicates
  • I have described the use case, not just the desired implementation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions