Skip to content

test(ads-client): assert shutdown is idempotent - #7558

Merged
Almaju merged 1 commit into
mozilla:mainfrom
Almaju:ads-client-shutdown-idempotent
Aug 20, 2026
Merged

test(ads-client): assert shutdown is idempotent#7558
Almaju merged 1 commit into
mozilla:mainfrom
Almaju:ads-client-shutdown-idempotent

Conversation

@Almaju

@Almaju Almaju commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Adds a regression test covering repeated shutdown() calls on the ads client.

MozAdsClient::shutdown takes &self and goes through a lock, so a double shutdown is reachable from the foreign side. Both pieces of state it tears down are already Option::take()MozAdsTelemetryWrapper::shutdown (ffi/telemetry.rs) and MARSTransport::shutdown_db (mars/transport.rs) — so the behaviour is correct today; this test pins it down.

The test builds the client with a real HttpCache, since that's where a regression would bite: HttpCache::shutdown_db(self) consumes and calls conn.close(), so replacing the take() with a borrow would make the second close error.

Pull Request checklist

  • Breaking changes: no API changes; test-only.
  • Quality: cargo test -p ads-client passes (96 passed, 1 ignored, 0 failed); cargo fmt --check and cargo clippy -p ads-client --all-targets are clean.
  • Tests: this PR is the test. Mutation-checked it: temporarily making MARSTransport::shutdown_db return Err(InvalidQuery) on an already-shut-down cache makes it fail; restored and re-verified green.
  • Changelog: not needed — no consumer-visible change.
  • Dependencies: no new dependencies.

@Almaju
Almaju requested a review from a team as a code owner August 20, 2026 19:51
@Almaju
Almaju requested review from copyrighthero and removed request for a team August 20, 2026 19:51

@thesuzerain thesuzerain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me

@Almaju
Almaju enabled auto-merge August 20, 2026 21:14
@Almaju
Almaju added this pull request to the merge queue Aug 20, 2026
Merged via the queue into mozilla:main with commit 6cc5bde Aug 20, 2026
15 checks passed
@Almaju
Almaju deleted the ads-client-shutdown-idempotent branch August 20, 2026 21:39
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