2026-06-24 09:30:29 +00:00
|
|
|
use datastream::{ChannelKind, Record};
|
|
|
|
|
use mvp_system::observability_surface as obs;
|
2026-06-25 12:30:18 +00:00
|
|
|
use mvp_system::provisioning::{
|
|
|
|
|
ProvisionEvent, ProvisionEventKind, ProvisionLogLine, ProvisionLogStream,
|
|
|
|
|
};
|
2026-06-28 18:54:02 +00:00
|
|
|
use mvp_system::telemetry::{
|
|
|
|
|
self, MvpLifecycleRecord, MvpProvisionEventRecord, MvpProvisionLogRecord,
|
|
|
|
|
};
|
2026-06-24 09:30:29 +00:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn mvp_lifecycle_record_round_trips_on_owned_datastream_channel() {
|
|
|
|
|
let record = MvpLifecycleRecord::new(obs::Event::StageScoped {
|
|
|
|
|
kind: obs::EventKind::StageFaulted,
|
|
|
|
|
run_id: obs::RunId(7),
|
|
|
|
|
stage_index: obs::StageIndex(2),
|
|
|
|
|
reason: Some(obs::FaultReason::WorkerCrashed),
|
|
|
|
|
component: obs::Component::StageController,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert_eq!(MvpLifecycleRecord::CHANNEL, telemetry::MVP_LIFECYCLE);
|
2026-07-12 06:14:34 +00:00
|
|
|
assert_eq!(MvpLifecycleRecord::channel_name(), "mvp.lifecycle");
|
2026-06-24 09:30:29 +00:00
|
|
|
assert_eq!(record.kind(), obs::EventKind::StageFaulted);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
MvpLifecycleRecord::decode(&record.encode()).unwrap(),
|
|
|
|
|
record
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn mvp_channel_registry_marks_lifecycle_payloads_as_typed() {
|
|
|
|
|
let registry = telemetry::channel_registry();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
2026-07-12 06:14:34 +00:00
|
|
|
registry.classify_name(MvpLifecycleRecord::channel_name()),
|
2026-06-24 09:30:29 +00:00
|
|
|
ChannelKind::Typed
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-06-25 12:30:18 +00:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn provisioning_records_round_trip_on_owned_datastream_channels() {
|
|
|
|
|
let event = MvpProvisionEventRecord::new(ProvisionEvent {
|
|
|
|
|
run_id: 77,
|
|
|
|
|
node_id: 11,
|
|
|
|
|
kind: ProvisionEventKind::NodeLive,
|
2026-07-05 09:59:51 +00:00
|
|
|
provider: Some("docker".to_owned()),
|
2026-06-25 12:30:18 +00:00
|
|
|
message: None,
|
|
|
|
|
});
|
2026-07-05 09:59:51 +00:00
|
|
|
let event_without_provider = MvpProvisionEventRecord::new(ProvisionEvent {
|
|
|
|
|
run_id: 77,
|
|
|
|
|
node_id: 12,
|
|
|
|
|
kind: ProvisionEventKind::ProvisionStart,
|
|
|
|
|
provider: None,
|
|
|
|
|
message: Some("queued".to_owned()),
|
|
|
|
|
});
|
2026-06-25 12:30:18 +00:00
|
|
|
let log = MvpProvisionLogRecord::new(ProvisionLogLine {
|
|
|
|
|
run_id: 77,
|
|
|
|
|
node_id: 11,
|
|
|
|
|
stream: ProvisionLogStream::Stdout,
|
|
|
|
|
line: "{\"type\":\"ready\"}".to_owned(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
MvpProvisionEventRecord::CHANNEL,
|
|
|
|
|
telemetry::MVP_PROVISIONING_EVENTS
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
MvpProvisionLogRecord::CHANNEL,
|
|
|
|
|
telemetry::MVP_PROVISIONING_LOGS
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
|
|
|
|
MvpProvisionEventRecord::decode(&event.encode()).unwrap(),
|
|
|
|
|
event
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(MvpProvisionLogRecord::decode(&log.encode()).unwrap(), log);
|
2026-07-05 09:59:51 +00:00
|
|
|
assert_eq!(
|
|
|
|
|
MvpProvisionEventRecord::decode(&event_without_provider.encode()).unwrap(),
|
|
|
|
|
event_without_provider
|
|
|
|
|
);
|
2026-06-28 18:54:02 +00:00
|
|
|
assert_eq!(
|
|
|
|
|
telemetry::mvp_provision_log_channel(11, ProvisionLogStream::Stdout).as_str(),
|
|
|
|
|
"mvp.provisioning.logs.node.11.stdout"
|
|
|
|
|
);
|
2026-06-25 12:30:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn mvp_channel_registry_marks_provisioning_payloads_as_typed() {
|
|
|
|
|
let registry = telemetry::channel_registry();
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
2026-07-12 06:14:34 +00:00
|
|
|
registry.classify_name(MvpProvisionEventRecord::channel_name()),
|
2026-06-25 12:30:18 +00:00
|
|
|
ChannelKind::Typed
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(
|
2026-07-12 06:14:34 +00:00
|
|
|
registry.classify_name(MvpProvisionLogRecord::channel_name()),
|
2026-06-25 12:30:18 +00:00
|
|
|
ChannelKind::Typed
|
|
|
|
|
);
|
|
|
|
|
}
|