Skip to content

Commit 954fc07

Browse files
committed
xtask: Pass image name as required argument
Removes .bcvk/config.toml reading logic in favor of explicit image argument. The image name is now required as the first argument to run-tmt, with optional test plan filters following. Usage: cargo xtask run-tmt <image> [filters...] Example: cargo xtask run-tmt localhost/bootc-integration readonly Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <[email protected]>
1 parent dca272d commit 954fc07

File tree

2 files changed

+28
-39
lines changed

2 files changed

+28
-39
lines changed

Justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ build-disk *ARGS:
6565
#
6666
# This task runs *all* of the tmt-based tests using bcvk VMs
6767
test-tmt *ARGS: build-integration-test-image
68-
cargo xtask run-tmt {{ARGS}}
68+
cargo xtask run-tmt localhost/bootc-integration {{ARGS}}
6969

7070
# Like test-tmt but assumes that the integration image is already built
7171
test-tmt-nobuild *ARGS:
72-
cargo xtask run-tmt {{ARGS}}
72+
cargo xtask run-tmt localhost/bootc-integration {{ARGS}}
7373

7474
# Run just one tmt test: `just test-tmt-one readonly-tests`
7575
test-tmt-one PLAN: build-integration-test-image
76-
cargo xtask run-tmt {{PLAN}}
76+
cargo xtask run-tmt localhost/bootc-integration {{PLAN}}
7777

7878
# Run tests (unit and integration) that are containerized
7979
test-container: build-units build-integration-test-image

crates/xtask/src/xtask.rs

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -361,32 +361,6 @@ fn update_generated(sh: &Shell, _args: &[String]) -> Result<()> {
361361
Ok(())
362362
}
363363

364-
/// Read the bcvk image configuration from .bcvk/config.toml
365-
/// Defaults to localhost/bootc-integration which includes testing utilities like rsync
366-
#[context("Reading bcvk config")]
367-
fn read_bcvk_image() -> Result<String> {
368-
let config_path = Utf8Path::new(".bcvk/config.toml");
369-
if !config_path.exists() {
370-
return Ok("localhost/bootc-integration".to_string());
371-
}
372-
373-
let config_content = std::fs::read_to_string(config_path)
374-
.context("Reading .bcvk/config.toml")?;
375-
376-
let config: toml::Value = toml::from_str(&config_content)
377-
.context("Parsing .bcvk/config.toml")?;
378-
379-
if let Some(vm) = config.get("vm") {
380-
if let Some(image) = vm.get("image") {
381-
if let Some(image_str) = image.as_str() {
382-
return Ok(image_str.to_string());
383-
}
384-
}
385-
}
386-
387-
Ok("localhost/bootc-integration".to_string())
388-
}
389-
390364
/// Wait for a bcvk VM to be ready and return SSH connection info
391365
#[context("Waiting for VM to be ready")]
392366
fn wait_for_vm_ready(sh: &Shell, vm_name: &str) -> Result<(u16, String)> {
@@ -446,7 +420,10 @@ fn verify_ssh_connectivity(sh: &Shell, port: u16, key_path: &Utf8Path) -> Result
446420
}
447421

448422
if attempt % 10 == 0 {
449-
println!("Waiting for SSH... attempt {}/{}", attempt, SSH_CONNECTIVITY_MAX_ATTEMPTS);
423+
println!(
424+
"Waiting for SSH... attempt {}/{}",
425+
attempt, SSH_CONNECTIVITY_MAX_ATTEMPTS
426+
);
450427
}
451428

452429
if attempt < SSH_CONNECTIVITY_MAX_ATTEMPTS {
@@ -491,13 +468,23 @@ fn check_dependencies(sh: &Shell) -> Result<()> {
491468

492469
/// Run TMT tests using bcvk for VM management
493470
/// This spawns a separate VM per test plan to avoid state leakage between tests.
471+
///
472+
/// Arguments:
473+
/// - First arg (required): Image name (e.g. "localhost/bootc-integration")
474+
/// - Remaining args (optional): Test plan filters (e.g. "readonly")
494475
#[context("Running TMT tests")]
495476
fn run_tmt(sh: &Shell, args: &[String]) -> Result<()> {
496477
// Check dependencies first
497478
check_dependencies(sh)?;
498479

499-
// Read bcvk configuration to get the image name
500-
let image = read_bcvk_image()?;
480+
// First arg is the image name, remaining args are test plan filters
481+
if args.is_empty() {
482+
anyhow::bail!("Image name is required as first argument");
483+
}
484+
485+
let image = &args[0];
486+
let filter_args = &args[1..];
487+
501488
println!("Using bcvk image: {}", image);
502489

503490
// Create tmt-workdir and copy tmt bits to it
@@ -527,13 +514,16 @@ fn run_tmt(sh: &Shell, args: &[String]) -> Result<()> {
527514
.collect();
528515

529516
// Filter plans based on user arguments
530-
if !args.is_empty() {
517+
if !filter_args.is_empty() {
531518
let original_count = plans.len();
532-
plans.retain(|plan| {
533-
args.iter().any(|arg| plan.contains(arg.as_str()))
534-
});
519+
plans.retain(|plan| filter_args.iter().any(|arg| plan.contains(arg.as_str())));
535520
if plans.len() < original_count {
536-
println!("Filtered from {} to {} plan(s) based on arguments: {:?}", original_count, plans.len(), args);
521+
println!(
522+
"Filtered from {} to {} plan(s) based on arguments: {:?}",
523+
original_count,
524+
plans.len(),
525+
filter_args
526+
);
537527
}
538528
}
539529

@@ -608,8 +598,7 @@ fn run_tmt(sh: &Shell, args: &[String]) -> Result<()> {
608598
println!("VM ready, SSH port: {}", ssh_port);
609599

610600
// Save SSH private key to a temporary file
611-
let key_file = tempfile::NamedTempFile::new()
612-
.context("Creating temporary SSH key file");
601+
let key_file = tempfile::NamedTempFile::new().context("Creating temporary SSH key file");
613602

614603
let key_file = match key_file {
615604
Ok(f) => f,

0 commit comments

Comments
 (0)