aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / spark-supervisor / tests / status_cli.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | //! `spark-supervisor status` must refuse instead of printing a table that looks live. |
| 17 | |
| 18 | use std::process::Command; |
| 19 | |
| 20 | #[test] |
| 21 | fn status_refuses_with_nonzero_exit_and_writes_nothing() { |
| 22 | let dir = std::env::temp_dir().join(format!("spark-supervisor-status-{}", std::process::id())); |
| 23 | let config = dir.join("supervisor.toml"); |
| 24 | let _ = std::fs::remove_dir_all(&dir); |
| 25 | |
| 26 | let out = Command::new(env!("CARGO_BIN_EXE_spark-supervisor")) |
| 27 | .arg("--config") |
| 28 | .arg(&config) |
| 29 | .arg("status") |
| 30 | .output() |
| 31 | .expect("run binary"); |
| 32 | |
| 33 | let stdout = String::from_utf8_lossy(&out.stdout); |
| 34 | let stderr = String::from_utf8_lossy(&out.stderr); |
| 35 | assert_eq!( |
| 36 | out.status.code(), |
| 37 | Some(2), |
| 38 | "stdout={stdout} stderr={stderr}" |
| 39 | ); |
| 40 | assert!( |
| 41 | stderr.contains("live status is not available from a separate process"), |
| 42 | "stderr={stderr}" |
| 43 | ); |
| 44 | assert!(!stdout.contains("SERVICE"), "table printed: {stdout}"); |
| 45 | assert!(!stdout.contains("RUNNING") && !stdout.contains("STOPPED")); |
| 46 | assert!(!config.exists(), "status must not generate a config file"); |
| 47 | } |
| 48 | |
| 49 | #[test] |
| 50 | fn check_still_succeeds_on_valid_config() { |
| 51 | let dir = std::env::temp_dir().join(format!("spark-supervisor-check-{}", std::process::id())); |
| 52 | std::fs::create_dir_all(&dir).unwrap(); |
| 53 | let config = dir.join("supervisor.toml"); |
| 54 | std::fs::write( |
| 55 | &config, |
| 56 | "[services.a]\ncommand = \"sleep\"\nargs = [\"1\"]\n", |
| 57 | ) |
| 58 | .unwrap(); |
| 59 | |
| 60 | let out = Command::new(env!("CARGO_BIN_EXE_spark-supervisor")) |
| 61 | .arg("--config") |
| 62 | .arg(&config) |
| 63 | .arg("check") |
| 64 | .output() |
| 65 | .expect("run binary"); |
| 66 | assert!(out.status.success(), "{out:?}"); |
| 67 | assert!(String::from_utf8_lossy(&out.stdout).contains("is valid")); |
| 68 | let _ = std::fs::remove_dir_all(&dir); |
| 69 | } |