test(gui): ALKANE_BENCH_FLOW -- full user flow incl. the scan step
Adds a headless GUI-flow driver that exercises the same code a user's clicks trigger, including the scan: scan -> (restore to stock if on alkane) -> scan -> install -> scan -> verify the board serves the HTTP API and shows as alkane. bench_sequence::scan_report runs the real scan::start_scan and prints how each board classifies (brand/model/control-board/install/alkane); run_flow chains the scan + restore + install with liveness verification. Wired as ALKANE_BENCH_FLOW="<host> <afw> [scan-range]" in main.rs. Per Noah's rule: test toolkit fixes by automating the real GUI flow including scanning, not just the engine in isolation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -216,6 +216,136 @@ fn wait_for(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Run the real fleet scan over `range` and report how each board classifies --
|
||||||
|
/// the scan step a user performs before acting. Returns the rows found.
|
||||||
|
fn scan_report(range: &str) -> Vec<crate::model::MinerRow> {
|
||||||
|
use crate::scan::{self, ScanMsg};
|
||||||
|
println!(" [scan] scanning {range} ...");
|
||||||
|
let handle = scan::start_scan(vec![range.to_string()], 10);
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
loop {
|
||||||
|
match handle.rx.recv() {
|
||||||
|
Ok(ScanMsg::Row(r)) => rows.push(r),
|
||||||
|
Ok(ScanMsg::Done(_)) | Ok(ScanMsg::Failed(_)) => break,
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_) => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows.sort_by(|a, b| a.ip.cmp(&b.ip));
|
||||||
|
if rows.is_empty() {
|
||||||
|
println!(" [scan] no boards found");
|
||||||
|
}
|
||||||
|
for r in &rows {
|
||||||
|
let installable = crate::alkane_detect::install_supported(r)
|
||||||
|
|| crate::alkane_detect::is_unidentified_stock_antminer(r);
|
||||||
|
println!(
|
||||||
|
" [scan] {:<15} brand={:<10} model={:<22} fw={:<7} board={:<10} install={} alkane={}",
|
||||||
|
r.ip,
|
||||||
|
r.brand,
|
||||||
|
r.model,
|
||||||
|
r.firmware,
|
||||||
|
r.control_board,
|
||||||
|
installable,
|
||||||
|
crate::alkane_detect::is_alkane(r),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
rows
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A full user-flow test driven headlessly through the GUI engine, including the
|
||||||
|
/// scan step a user performs: scan -> restore to stock -> scan -> install ->
|
||||||
|
/// scan -> verify the board serves the API and shows as alkane. Spec:
|
||||||
|
/// `<host> <afw> [scan-range]`.
|
||||||
|
pub fn run_flow(spec: &str) -> i32 {
|
||||||
|
let mut it = spec.split_whitespace();
|
||||||
|
let host = it.next().unwrap_or("").to_string();
|
||||||
|
let afw = PathBuf::from(it.next().unwrap_or(""));
|
||||||
|
let range = it.next().unwrap_or("10.255.1.0/24").to_string();
|
||||||
|
if host.is_empty() || afw.as_os_str().is_empty() {
|
||||||
|
eprintln!("ALKANE_BENCH_FLOW=\"<host> <afw> [scan-range]\"");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if !afw.exists() {
|
||||||
|
eprintln!("afw not found: {}", afw.display());
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
let stock_password = credentials::load_ssh_credentials().map(|(_, p)| p);
|
||||||
|
let alkane_password = std::env::var("ALKANE_ROOT_PASSWORD")
|
||||||
|
.ok()
|
||||||
|
.or_else(|| Some("alkane".to_string()));
|
||||||
|
let boot_timeout = Duration::from_secs(300);
|
||||||
|
|
||||||
|
println!("== A113D full GUI-flow test (scan -> restore -> scan -> install -> scan) ==");
|
||||||
|
let mac = mac_of(&host);
|
||||||
|
|
||||||
|
println!("\n[1/6] initial scan (as a user would)");
|
||||||
|
scan_report(&range);
|
||||||
|
|
||||||
|
let (desc, is_stock) = classify(&host);
|
||||||
|
println!("\n[2/6] target {host}: {desc}");
|
||||||
|
if is_stock != Some(true) {
|
||||||
|
println!("[3/6] restore {host} -> stock (flag flip)");
|
||||||
|
if !drive(
|
||||||
|
"restore",
|
||||||
|
stock_ops::start_restore_flag(vec![host.clone()], alkane_password.clone()),
|
||||||
|
) {
|
||||||
|
println!("[3/6] restore FAILED; aborting");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
let (_ip, d, ok) = wait_for(mac.as_deref(), &host, true, boot_timeout);
|
||||||
|
println!(
|
||||||
|
" {d} => {}",
|
||||||
|
if ok { "STOCK" } else { "NOT STOCK (fail)" }
|
||||||
|
);
|
||||||
|
if !ok {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("[3/6] already stock; skipping restore");
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("\n[4/6] scan after restore (board should appear as a stock Antminer)");
|
||||||
|
scan_report(&range);
|
||||||
|
|
||||||
|
println!("\n[5/6] install alkane from stock");
|
||||||
|
let h = stock_ops::start_install(
|
||||||
|
vec![host.clone()],
|
||||||
|
"a113d".to_string(),
|
||||||
|
AfwSource::Local(afw.clone()),
|
||||||
|
true,
|
||||||
|
stock_password.clone(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
if !drive("install", h) {
|
||||||
|
println!("[5/6] install FAILED");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
let (alkane_ip, d, ok) = wait_for(mac.as_deref(), &host, false, boot_timeout);
|
||||||
|
println!(
|
||||||
|
" {d} => {}",
|
||||||
|
if ok { "ALKANE" } else { "NOT ALKANE (fail)" }
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("\n[6/6] scan after install (board should appear as ALKANE via the HTTP API)");
|
||||||
|
let rows = scan_report(&range);
|
||||||
|
let seen_alkane = rows
|
||||||
|
.iter()
|
||||||
|
.any(|r| crate::alkane_detect::is_alkane(r) && (r.ip == alkane_ip || r.ip == host));
|
||||||
|
println!(
|
||||||
|
"\n== FLOW RESULT: {} ==",
|
||||||
|
if ok && seen_alkane {
|
||||||
|
"PASS (installed, serves API, visible in scan)"
|
||||||
|
} else {
|
||||||
|
"INCOMPLETE (see the scan lines above)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if ok && seen_alkane {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run(spec: &str) -> i32 {
|
pub fn run(spec: &str) -> i32 {
|
||||||
let mut it = spec.split_whitespace();
|
let mut it = spec.split_whitespace();
|
||||||
let host = match it.next() {
|
let host = match it.next() {
|
||||||
|
|||||||
@@ -50,6 +50,12 @@ fn main() {
|
|||||||
std::process::exit(bench_sequence::run(&spec.to_string_lossy()));
|
std::process::exit(bench_sequence::run(&spec.to_string_lossy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Full GUI-flow test (scan -> restore -> scan -> install -> scan -> verify),
|
||||||
|
// exercising the scan step a user performs. See bench_sequence::run_flow.
|
||||||
|
if let Some(spec) = std::env::var_os("ALKANE_BENCH_FLOW") {
|
||||||
|
std::process::exit(bench_sequence::run_flow(&spec.to_string_lossy()));
|
||||||
|
}
|
||||||
|
|
||||||
// Headless access-probe check: `ALKANE_ACCESS_PROBE="<ip> <make>"` prints the
|
// Headless access-probe check: `ALKANE_ACCESS_PROBE="<ip> <make>"` prints the
|
||||||
// lock state the real access probe computes (no GUI, no wx), so the WhatsMiner
|
// lock state the real access probe computes (no GUI, no wx), so the WhatsMiner
|
||||||
// :4028 token check and the Antminer digest check can be verified directly.
|
// :4028 token check and the Antminer digest check can be verified directly.
|
||||||
|
|||||||
Reference in New Issue
Block a user