40 lines
1.2 KiB
Rust
40 lines
1.2 KiB
Rust
//! Operator-to-agent exec over Core NATS request/reply.
|
|
|
|
use harmony_fleet_e2e::{StackOptions, shared_stack};
|
|
use harmony_fleet_operator::commands::{CommandError, FleetCommandsClient};
|
|
|
|
const E2E_ENV: &str = "HARMONY_FLEET_E2E";
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
|
async fn operator_can_execute_a_bounded_agent_command() -> anyhow::Result<()> {
|
|
if !matches!(std::env::var(E2E_ENV).as_deref(), Ok("1" | "true")) {
|
|
eprintln!("skipping {E2E_ENV}-gated exec e2e test");
|
|
return Ok(());
|
|
}
|
|
|
|
let stack = shared_stack(StackOptions::default()).await?;
|
|
let client = FleetCommandsClient::new(stack.nats_client.clone());
|
|
let reply = client
|
|
.exec(
|
|
&stack.device_ids[0],
|
|
"printf stdout; printf stderr >&2; exit 7",
|
|
)
|
|
.await?;
|
|
|
|
assert_eq!(reply.exit_code, 7);
|
|
assert_eq!(reply.stdout, "stdout");
|
|
assert_eq!(reply.stderr, "stderr");
|
|
assert!(!reply.truncated);
|
|
|
|
let delayed = client
|
|
.exec(&stack.device_ids[0], "sleep 11; printf delayed")
|
|
.await?;
|
|
assert_eq!(delayed.stdout, "delayed");
|
|
|
|
assert!(matches!(
|
|
client.exec("missing-device", "true").await,
|
|
Err(CommandError::DeviceOffline)
|
|
));
|
|
Ok(())
|
|
}
|