Skip to content

test: process-level fault-injection harness and the contract tests that pass today - #1473

Open
duncanista wants to merge 4 commits into
jordan.gonzalez/test-fixtures/featurefrom
jordan.gonzalez/fault-harness/feature
Open

duncanista wants to merge 4 commits into
jordan.gonzalez/test-fixtures/featurefrom
jordan.gonzalez/fault-harness/feature

Conversation

@duncanista

@duncanista duncanista commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: Tests that run the real bottlecap binary against a fake Lambda API and an intake that fails on purpose. This PR adds the harness and the 10 checks that pass today.

Why: Our worst bugs (hangs past the invocation deadline, SIGKILL at shutdown, lost data on intake errors) show up only at the process level, so unit tests cannot catch them. Each later fix adds its own test here.

Overview

Jira: SVLS-9978

Stacked on #1472 (jordan.gonzalez/test-fixtures/feature).

Contract tests that run the real bottlecap binary against a fake Lambda control plane and a
Datadog intake that fails on demand. Each test asserts what Lambda or the customer sees:
/next before the deadline, exit on SHUTDOWN, no panic. See bottlecap/tests/HARNESS.md.

  • tests/common/: fake Extensions and Telemetry API, fault intake (blackhole, SYN blackhole,
    slow, 5xx, 429, close mid body, size limits), process wrapper with RSS and CPU, port guard.
  • 4 test binaries with the 10 tests that pass on main today: invoke then shutdown exits
    cleanly; a 503 storm does not hold /next; an oversized trace is dropped and later traces
    flow; an intake that closes mid body does not hold /next; 4 config fields with a wrong type
    cost only that field; ports 8124 and 8126 held by another process.
  • bottlecap/.config/nextest.toml: the 4 binaries run one test at a time (fixed-ports
    group), because the binary binds fixed ports.

No production code and no Cargo change. The tests for the open bugs come in a later PR, each
ignored with the backlog item that fixes it.

Size: 20 core lines, 2184 lines in total.

Testing

  • applies on the previous PR of the stack: pass
  • cargo fmt --all -- --check: pass
  • cargo clippy --workspace --all-targets --features default -- -D warnings: pass
  • cargo clippy --workspace --all-targets --features default,test-mode -- -D warnings: pass
  • cargo nextest run --workspace: pass
  • plain cargo test --test <binary> for the 4 harness binaries: pass
  • the 4 test files hold exactly the 10 passing tests, no #[ignore], no backlog reference: pass
  • Linux arm64 in Docker (rust 1.93.1), on the full harness at the end of the stack: the same 10 tests pass.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T20:34:46.844785Z 3e32723 New commits
🔒 Security Review ✅ Completed 2026-10-30T20:32:14.238010Z 3e32723 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0e4939146

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bottlecap/tests/fault_injection_test.rs Resolved
Comment thread bottlecap/tests/common/harness.rs Resolved
@datadog-datadog-prod-us1-2

This comment has been minimized.

@duncanista duncanista changed the title [SVLS-9978] test: process-level fault-injection harness and the contract tests that pass today test: process-level fault-injection harness and the contract tests that pass today Oct 28, 2026
- fault_injection_test: measure the /next budget from when the INVOKE was queued
- harness: shutdown_cleanly asserts the exit came within the SHUTDOWN deadline

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51f541581a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bottlecap/tests/fault_injection_test.rs Resolved
Comment thread bottlecap/tests/fault_injection_test.rs Resolved
- oversized trace: wait for /next against the 10 s INVOKE deadline, and assert
  the rejected trace is never sent again after the rejection is lifted
- lifecycle: read the intake before SHUTDOWN so the final flush cannot hide a
  missing end-of-invocation flush

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 399b90b8e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bottlecap/tests/fault_injection_test.rs Resolved
Comment thread bottlecap/tests/port_conflict_test.rs Resolved
Comment thread bottlecap/tests/common/fault_intake.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e32723992

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.unwrap();
deliver_runtime_done(&s.api, "req-1", true).await.unwrap();
assert!(
s.api.wait_for_next_calls(2, secs(10)).await,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Measure the lifecycle wait from the queued INVOKE

If either telemetry POST consumes part of the 10-second invocation window, this wait starts a fresh 10-second timer only after both POSTs finish, so /next may arrive after the event deadline and the test still passes. Capture the time when the INVOKE is queued and wait only for the remaining budget, or record /next arrival times; otherwise the PR summary's claim that this test asserts /next before the deadline is inaccurate.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment on lines +121 to +122
self.api.push_shutdown("spindown", SHUTDOWN_DEADLINE);
bc.wait_for_exit(bottlecap_process::EXIT_BUDGET).await

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Enforce the deadline for raw shutdown callers

When callers use shutdown directly, an exit between the advertised 2-second SHUTDOWN deadline and EXIT_BUDGET still returns a successful status. The current direct callers in the 503, truncated-response, and port-conflict tests only assert that status, so those tests can pass after Lambda would have killed the process; this remains fresh evidence despite shutdown_cleanly now checking its elapsed time.

Useful? React with 👍 / 👎.

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.

1 participant