Skip to content

Migrate from Trillium [part 9B]: Rewrite test infrastructure + remove all trillium deps#2266

Merged
jcjones merged 8 commits into
mainfrom
jcj/axum-migration-part9b
May 21, 2026
Merged

Migrate from Trillium [part 9B]: Rewrite test infrastructure + remove all trillium deps#2266
jcjones merged 8 commits into
mainfrom
jcj/axum-migration-part9b

Conversation

@jcjones
Copy link
Copy Markdown
Contributor

@jcjones jcjones commented May 18, 2026

Replace the entire trillium-based test harness with axum-native equivalents and remove every trillium dependency from the workspace. Are you ready for a PARTY? This one removes Trillium. Say goodnight.

test-support/* rewrite:

  • TestRequest/TestResponse types using tower::ServiceExt::oneshot()
  • ClientLogs rewritten as axum middleware capturing request/response bodies
  • ApiMocks rewritten with host-based axum::Router dispatch
  • User injection by smooshing them into parts.extensions which acts like the PermissionsActor was cached

src/ crate cleanup:

  • Delete handler::origin_router, handler::proxy, ErrorHandler, and the DivviupApi trillium Handler struct
  • Delete inject_integration_testing_user and inject_test_header_user middleware
  • Rewrote src/api_mocks/*

tests/integration/*:

  • All response_json() calls are now synchronous

Here we see the final destruction of the trillium alliance, and the end of its insignificant rebellion against our dependency tree.

I've left some more cleanup for Part 10, including refactoring 'with_state' to 'with_user' in ~100 callsites, and the restoration of remaining HTTP metrics.

@jcjones jcjones force-pushed the jcj/axum-migration-part9b branch from 4f82852 to a49b10e Compare May 18, 2026 22:15
@divergentdave
Copy link
Copy Markdown
Collaborator

User injection via X-Integration-Testing-User header (was in the trillium conn state)

I think we may need to go the other direction instead. Currently when doing a workspace-wide build, the test-header-injection feature on divviup-api is enabled, since test-support uses it. It would be easy to accidentally build and deploy this. If we instead use existing state methods to inject a user for in-process unit tests and integration tests, then we can rely on existing Axum APIs, before calling oneshot() to set up fixtures. We should only use the #[cfg]-gated user injection approach, header or no, for the out-of-process Docker integration tests.

… all trillium deps

Replace the entire trillium-based test harness with axum-native equivalents and remove every
trillium dependency from the workspace. Are you ready for a PARTY? This one removes Trillium.
Say goodnight.

test-support/* rewrite:
- TestRequest/TestResponse types using tower::ServiceExt::oneshot()
- ClientLogs rewritten as axum middleware capturing request/response bodies
- ApiMocks rewritten with host-based axum::Router dispatch
- User injection via X-Integration-Testing-User header (was in the trillium conn state)

src/ crate cleanup:
- Delete handler::origin_router, handler::proxy, ErrorHandler, and the DivviupApi trillium
  Handler struct
- Delete inject_integration_testing_user middleware (the header-based inject_test_header_user is
  sufficient)
- Rewrote src/api_mocks/*

tests/integration/*:
- All response_json() calls are now synchronous (body eagerly consumed)

Here we see the final destruction of the trillium alliance, and the end of its insignificant
rebellion against our dependency tree.

I've left some more cleanup for Part 10, including refactoring 'with_state' to 'with_user' in
~100 callsites, and the restoration of remaining HTTP metrics.
@jcjones jcjones force-pushed the jcj/axum-migration-part9b branch from a49b10e to 6f37148 Compare May 18, 2026 22:25
@jcjones
Copy link
Copy Markdown
Contributor Author

jcjones commented May 18, 2026

User injection via X-Integration-Testing-User header (was in the trillium conn state)

I think we may need to go the other direction instead. Currently when doing a workspace-wide build, the test-header-injection feature on divviup-api is enabled, since test-support uses it. It would be easy to accidentally build and deploy this. If we instead use existing state methods to inject a user for in-process unit tests and integration tests, then we can rely on existing Axum APIs, before calling oneshot() to set up fixtures. We should only use the #[cfg]-gated user injection approach, header or no, for the out-of-process Docker integration tests.

I intended to finangle this in Part 10, but there's no reason not to do it now and be rid of inject_test_header_user here, good call. The final form of what I wanted is now in 59da00f.

@jcjones jcjones marked this pull request as ready for review May 19, 2026 15:51
@jcjones jcjones requested a review from a team as a code owner May 19, 2026 15:51
Copy link
Copy Markdown
Contributor

@tgeoghegan tgeoghegan left a comment

Choose a reason for hiding this comment

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

Might have more to say, but here's some comments to start.

Comment thread client/tests/integration/harness.rs
Comment thread src/queue/job.rs
Comment thread test-support/src/api_mocks.rs Outdated
Comment thread test-support/src/client_logs.rs Outdated
Comment thread test-support/src/fixtures.rs Outdated
Comment thread test-support/src/lib.rs
Comment thread tests/integration/aggregator_client.rs Outdated
Comment thread tests/integration/tasks.rs
Comment thread test-support/src/lib.rs
@jcjones jcjones requested a review from tgeoghegan May 20, 2026 17:06
Comment thread client/tests/integration/harness.rs Outdated
Comment thread test-support/src/fixtures.rs Outdated
Comment thread test-support/src/lib.rs Outdated
Comment thread test-support/src/lib.rs Outdated
Comment thread tests/integration/tls_smoke_test.rs Outdated
Comment thread test-support/src/client_logs.rs Outdated
Comment thread test-support/src/client_logs.rs Outdated
};
use rand::random;
use uuid::Uuid;

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.

nit: we should keep a blank line between the imports and this function

@jcjones jcjones merged commit c8b97e2 into main May 21, 2026
8 checks passed
@jcjones jcjones deleted the jcj/axum-migration-part9b branch May 21, 2026 22:21
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.

3 participants