Stream live MXAccess advice events from the Rust worker
This commit is contained in:
@@ -9,13 +9,13 @@ use tokio::io::{split, AsyncRead, AsyncWrite};
|
||||
use tokio::net::windows::named_pipe::ServerOptions;
|
||||
use tokio::time::{sleep, timeout};
|
||||
use wire::mxaccess_gateway::v1::{
|
||||
mx_command, mx_command_reply, AddItemCommand, MxCommand, MxCommandKind, MxCommandReply,
|
||||
ProtocolStatusCode, RegisterCommand, RemoveItemCommand, UnregisterCommand,
|
||||
mx_command, mx_command_reply, AddItemCommand, AdviseCommand, MxCommand, MxCommandKind,
|
||||
MxCommandReply, ProtocolStatusCode, RegisterCommand, RemoveItemCommand, UnregisterCommand,
|
||||
};
|
||||
use wire::mxaccess_worker::v1::{GatewayHello, WorkerCommand, WorkerShutdown};
|
||||
use wire::{Body, Writer, DEFAULT_MAX, VERSION};
|
||||
|
||||
const DEADLINE: Duration = Duration::from_secs(20);
|
||||
const DEADLINE: Duration = Duration::from_secs(40);
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore = "requires a registered 32-bit System Platform MXAccess installation"]
|
||||
@@ -141,8 +141,9 @@ async fn activates_registers_and_shuts_down_over_a_windows_pipe() {
|
||||
)
|
||||
.await;
|
||||
|
||||
// Leave a registration active to exercise the worker's shutdown cleanup.
|
||||
invoke(
|
||||
// Leave a registration and, when a live item is configured, an advice
|
||||
// active to check that the shutdown acknowledgement is sent after cleanup.
|
||||
let cleanup_registration = invoke(
|
||||
&mut reader,
|
||||
&mut writer,
|
||||
session,
|
||||
@@ -153,6 +154,40 @@ async fn activates_registers_and_shuts_down_over_a_windows_pipe() {
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
if let Ok(definition) = std::env::var("MXGATEWAY_RUST_SMOKE_ITEM") {
|
||||
let Some(mx_command_reply::Payload::Register(registration)) =
|
||||
cleanup_registration.payload
|
||||
else {
|
||||
panic!("missing cleanup registration handle");
|
||||
};
|
||||
let added = invoke(
|
||||
&mut reader,
|
||||
&mut writer,
|
||||
session,
|
||||
"add-for-cleanup",
|
||||
MxCommandKind::AddItem,
|
||||
mx_command::Payload::AddItem(AddItemCommand {
|
||||
server_handle: registration.server_handle,
|
||||
item_definition: definition,
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
let Some(mx_command_reply::Payload::AddItem(item)) = added.payload else {
|
||||
panic!("missing live item handle");
|
||||
};
|
||||
invoke(
|
||||
&mut reader,
|
||||
&mut writer,
|
||||
session,
|
||||
"advise-for-cleanup",
|
||||
MxCommandKind::Advise,
|
||||
mx_command::Payload::Advise(AdviseCommand {
|
||||
server_handle: registration.server_handle,
|
||||
item_handle: item.item_handle,
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
writer
|
||||
.send(
|
||||
session,
|
||||
@@ -164,7 +199,7 @@ async fn activates_registers_and_shuts_down_over_a_windows_pipe() {
|
||||
.unwrap();
|
||||
loop {
|
||||
match read_body(&mut reader, session).await {
|
||||
Body::WorkerHeartbeat(_) => {}
|
||||
Body::WorkerHeartbeat(_) | Body::WorkerEvent(_) => {}
|
||||
Body::WorkerShutdownAck(ack) => {
|
||||
let status = ack.status.unwrap();
|
||||
assert_eq!(status.code(), ProtocolStatusCode::Ok);
|
||||
|
||||
Reference in New Issue
Block a user