Skip to content

Commit ca5d511

Browse files
committed
test(integration): wire EventReporter to the gateway-fetch reporter
Adds a `GatewayQuery { id, op_id }` event recorded each time a gateway-query site asks `EventReporter::create_gateway_reporter`, where `op_id` is the started parent op the fetch belongs to and `id` is a fresh op id whose parent in the registry is `op_id`. The event-tree renderer adds a "Repodata fetch" node so the snapshot shows where every fetch lands relative to the surrounding pixi solve / backend-instantiate operations. The existing snapshot (e.g. `integration__simple_test.snap`) captures the pre-wiring tree and will need refreshing via `cargo insta review` once the slow integration tests are run in an environment that can host the git fixtures.
1 parent 0ece396 commit ca5d511

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

crates/pixi_command_dispatcher/tests/integration/event_reporter.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::{
66
use futures::{Stream, StreamExt};
77
use pixi_build_discovery::JsonRpcBackendSpec;
88
use pixi_command_dispatcher::{
9-
BackendSourceBuildSpec, BuildBackendMetadataInner, CondaSolveReporter, GitCheckoutReporter,
10-
InstallPixiEnvironmentSpec, PixiInstallReporter, PixiSolveEnvironmentSpec, PixiSolveReporter,
11-
SolveCondaEnvironmentSpec, SourceMetadataReporterSpec, SourceRecordReporterSpec,
12-
UrlCheckoutReporter,
9+
BackendSourceBuildSpec, BuildBackendMetadataInner, CondaSolveReporter, GatewayReporter,
10+
GitCheckoutReporter, InstallPixiEnvironmentSpec, PixiInstallReporter,
11+
PixiSolveEnvironmentSpec, PixiSolveReporter, SolveCondaEnvironmentSpec,
12+
SourceMetadataReporterSpec, SourceRecordReporterSpec, UrlCheckoutReporter,
1313
reporter::{
1414
BackendSourceBuildReporter, BuildBackendMetadataReporter, InstantiateBackendReporter,
1515
SourceMetadataReporter, SourceRecordReporter,
@@ -141,6 +141,15 @@ pub enum Event {
141141
InstantiateBackendFinished {
142142
id: OperationId,
143143
},
144+
145+
/// Recorded each time a gateway-query site requests a per-call
146+
/// repodata reporter. `id` is a fresh op id for the query itself;
147+
/// its parent in the registry is the started operation that
148+
/// triggered the fetch (carried in `op_id`).
149+
GatewayQuery {
150+
id: OperationId,
151+
op_id: OperationId,
152+
},
144153
}
145154

146155
pub struct EventReporter {
@@ -413,6 +422,17 @@ impl InstantiateBackendReporter for EventReporter {
413422
}
414423
}
415424

425+
impl GatewayReporter for EventReporter {
426+
fn create_gateway_reporter(
427+
&self,
428+
op_id: OperationId,
429+
) -> Option<Box<dyn rattler_repodata_gateway::Reporter>> {
430+
let id = self.alloc();
431+
self.record(Event::GatewayQuery { id, op_id });
432+
None
433+
}
434+
}
435+
416436
impl BackendSourceBuildReporter for EventReporter {
417437
fn on_queued(&self, spec: &BackendSourceBuildSpec) -> OperationId {
418438
let id = self.alloc();
@@ -462,6 +482,7 @@ impl EventReporter {
462482
.with_source_metadata_reporter(self.clone())
463483
.with_source_record_reporter(self.clone())
464484
.with_backend_source_build_reporter(self.clone())
485+
.with_gateway_reporter(self.clone())
465486
}
466487
}
467488

crates/pixi_command_dispatcher/tests/integration/event_tree.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ impl EventTree {
113113
}
114114
Event::InstantiateBackendStarted { id } => builder.alloc_pending(*id),
115115
Event::InstantiateBackendFinished { .. } => {}
116+
Event::GatewayQuery { id, .. } => {
117+
builder.alloc_node(*id, "Repodata fetch".to_owned());
118+
}
116119
Event::UrlCheckoutQueued { .. }
117120
| Event::UrlCheckoutStarted { .. }
118121
| Event::UrlCheckoutFinished { .. } => {

0 commit comments

Comments
 (0)