Skip to content

test infra: use shared datadog-mock-intake crate and add standalone mock-intake binary - #1392

Open
lucaspimentel wants to merge 12 commits into
mainfrom
lpimentel/mock-intake-consume
Open

lucaspimentel wants to merge 12 commits into
mainfrom
lpimentel/mock-intake-consume

Conversation

@lucaspimentel

@lucaspimentel lucaspimentel commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Overview

Consumes the datadog-mock-intake crate from DataDog/serverless-components (#174, now merged to main; pinned to the merged commit b3e6a032f00a29a34ce61b50138677991d43c1e5):

  • The APM and DSM integration tests now use the shared crate as an ungated dev-dependency; the 317-line test-local intake fixture (tests/common/fake_intake.rs) is deleted.
  • Adds a standalone mock-intake binary behind a new mock-intake feature for local APM debugging: it runs the shared crate with request summaries, stats failure injection (MOCK_INTAKE_FAIL_STATS_FIRST_N), and JSON dumps (MOCK_INTAKE_DUMP_DIR). See bottlecap/src/bin/mock-intake/README.md for the workflow. The smoke procedure uses the bottlecap-test-mode binary from [APMSVLS-501] feat(bottlecap): add bottlecap-test-mode binary #1216 (not yet merged).
  • CI clippy now compiles the mock-intake feature so the binary stays checked, and GitLab clippy now lints all targets (matching GitHub CI). Test runs are unchanged: the integration tests run in every feature set, as before.

Supersedes #1385, which introduced the intake as a bottlecap library module; that implementation now lives in the shared crate.

Testing

  • cargo test -p bottlecap (default): suite passes, including apm_integration_test and dsm_integration_test.
  • cargo build -p bottlecap --features mock-intake: clean. cargo clippy --workspace --all-targets across default / fips / mock-intake feature sets: no lint warnings.
  • dd-rust-license-tool check: passes (no new third-party dependencies; the crate is first-party).
  • Manual smoke: ran the mock-intake binary with failure injection and a dump directory, POSTed a gzip msgpack StatsPayload to /api/v0.2/stats: 202 Accepted, mock-intake: summary line with grouped hits and normalized aggregation key, and a JSON dump containing the decoded payload; SIGINT shutdown clean.

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

Bottlecap (Rust) | Audit

View more details · View in GitHub Actions

DataDog/datadog-lambda-extension | e2e-test-status (amd64)

View more details · View in GitLab

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 68e033e | Docs | View more details | Give us feedback!

@lucaspimentel lucaspimentel changed the title Use shared datadog-mock-intake crate and add standalone fake-intake binary Use shared datadog-mock-intake crate and add standalone fake-intake binary Sep 25, 2026
@lucaspimentel

Copy link
Copy Markdown
Member Author

Note to self: rename fake-intake to mock-intake

@lucaspimentel

Copy link
Copy Markdown
Member Author

@DataDog review

@datadog-prod-us1-3 datadog-prod-us1-3 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.

Bits Code Review: PASS

More details

The shared intake preserves the migrated integration-test contract, and the standalone binary remains gated from production builds.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 6826b1f · @DataDog review to ask questions

@lucaspimentel lucaspimentel changed the title Use shared datadog-mock-intake crate and add standalone fake-intake binary Use shared datadog-mock-intake crate and add standalone mock-intake binary Sep 29, 2026
@lucaspimentel
lucaspimentel force-pushed the lpimentel/mock-intake-consume branch 2 times, most recently from b1d9813 to 86483e6 Compare October 21, 2026 21:35
@lucaspimentel
lucaspimentel marked this pull request as ready for review October 21, 2026 22:22
@lucaspimentel
lucaspimentel requested review from a team as code owners October 21, 2026 22:22
@lucaspimentel
lucaspimentel requested review from lym953 and a balanced review from Copilot October 21, 2026 22:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-26T14:06:23.383397Z 68e033e New commits
🔒 Security Review ✅ Completed 2026-10-26T14:05:11.343811Z 68e033e 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.

@lucaspimentel lucaspimentel changed the title Use shared datadog-mock-intake crate and add standalone mock-intake binary test infra: use shared datadog-mock-intake crate and add standalone mock-intake binary Oct 21, 2026
@lucaspimentel

Copy link
Copy Markdown
Member Author

@DataDog review

@datadog-prod-us1-3 datadog-prod-us1-3 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.

Bits Code Review: PASS

More details

The completed static review found that the shared intake preserves existing integration-test assertions and the standalone binary remains gated behind the opt-in mock-intake feature. No actionable regressions were identified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 86483e6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The standalone intake retains traffic without bounds and silently treats SIGINT-handler errors as successful shutdowns.

2 open issues
What changed in this PR

Replaces Bottlecap’s test-local intake fixture with the shared datadog-mock-intake crate and adds a feature-gated binary for local APM debugging.

Changes:

  • Migrates APM and DSM integration tests to the shared crate without feature-gating the tests.
  • Adds a standalone intake with request summaries, stats failure injection, JSON dumps, and usage documentation.
  • Updates dependency metadata and CI lint coverage for the new binary.
File Description
bottlecap/​tests/​dsm_integration_test.rs Uses the shared intake for DSM payload tests.
bottlecap/​tests/​common/​mod.rs Removes the obsolete common-module file.
bottlecap/​tests/​common/​fake_intake.rs Deletes the test-local intake implementation.
bottlecap/​tests/​apm_integration_test.rs Migrates APM tests and helpers to MockIntake.
bottlecap/​src/​bin/​mock-intake/​README.md Documents configuration, endpoints, and the smoke workflow.
bottlecap/​src/​bin/​mock-intake/​main.rs Adds the standalone intake launcher and signal handling.
bottlecap/​README.md Introduces local debugging and links detailed instructions.
bottlecap/​LICENSE-3rdparty.csv Records the shared crate’s license.
bottlecap/​Cargo.toml Declares the dependency, feature, and binary target.
bottlecap/​Cargo.lock Locks the shared crate and updates dependency references.
.gitlab/​templates/​pipeline.yaml.tpl Lints all targets and includes the new feature.
.github/​workflows/​rs_ci.yml Includes the new feature in Clippy coverage.

Review effort: Balanced

Comment on lines +39 to +41
let intake = MockIntake::start_with_options(options)
.await
.context("mock-intake: failed to start")?;
let mut sigterm = signal(SignalKind::terminate())
.context("mock-intake: failed to register SIGTERM handler")?;
tokio::select! {
_ = tokio::signal::ctrl_c() => {}
@lucaspimentel
lucaspimentel force-pushed the lpimentel/mock-intake-consume branch 2 times, most recently from a1e2866 to 3435d00 Compare October 22, 2026 22:05
…inary

Replace the test-local APM intake fixture with the datadog-mock-intake
crate from serverless-components (pinned to its first published
revision). The APM and DSM integration tests use it as an ungated
dev-dependency and run in every test build; the previous fixture is
deleted.

Add a standalone fake-intake binary behind a new fake-intake feature for
local APM debugging: it runs the shared crate with request summaries,
stats failure injection (FAKE_INTAKE_FAIL_STATS_FIRST_N), and JSON dumps
(FAKE_INTAKE_DUMP_DIR). CI clippy now compiles the feature so the binary
stays checked.
The standalone binary is now mock-intake, gated by the mock-intake
feature, configured with MOCK_INTAKE_PORT, MOCK_INTAKE_FAIL_STATS_FIRST_N,
and MOCK_INTAKE_DUMP_DIR. This aligns the binary with the
datadog-mock-intake crate it wraps, whose summaries already used the
mock-intake prefix. The mock-intake crate is now a git dependency, so
LICENSE-3rdparty.csv gains its first-party record.
Dedupe the duplicated env-var parsing in the mock-intake binary into
a generic parse_env_or helper with identical error messages, and drop
the rmp-serde/flate2 dev-dependencies left over from when the harness
decoded stats payloads itself; the shared datadog-mock-intake crate
handles that now.
@lucaspimentel
lucaspimentel force-pushed the lpimentel/mock-intake-consume branch from 3435d00 to 68e033e Compare October 26, 2026 14:01

@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: 68e033eee6

ℹ️ 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 on lines +49 to +52
cd ../<test-mode-worktree>/bottlecap
cargo build --bin bottlecap-test-mode --features test-mode

cd ../<this-checkout>/bottlecap

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 Build both binaries from the same checkout

When a developer follows this smoke procedure, bottlecap-test-mode is built under <test-mode-worktree>, but the instructions then switch to <this-checkout> and later execute ./target/debug/bottlecap-test-mode there, where that artifact was never built. The binary already exists in this commit's parent, so build it from the current checkout and remove the obsolete separate-worktree steps.

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.

2 participants