Skip to content

Commit b7cb29b

Browse files
committed
ephemeral: Add test-basic subcommand
Add `bcvk ephemeral test-basic <image>` which boots an ephemeral VM and verifies systemd reached a healthy state via `systemctl is-system-running`. This provides a quick smoke test for bootc container images. Assisted-by: Claude Code (Opus 4.6) Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent f4dd05a commit b7cb29b

File tree

5 files changed

+97
-1
lines changed

5 files changed

+97
-1
lines changed

crates/integration-tests/src/tests/run_ephemeral_ssh.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ fn build_broken_image() -> anyhow::Result<String> {
7070
Ok(image_name)
7171
}
7272

73+
/// Test the `ephemeral test-basic` subcommand
74+
///
75+
/// Verifies that `bcvk ephemeral test-basic` boots a VM and confirms
76+
/// systemd reached a healthy "running" state via `systemctl is-system-running`.
77+
fn test_ephemeral_test_basic() -> TestResult {
78+
let sh = shell()?;
79+
let bck = get_bck_command()?;
80+
let image = get_test_image();
81+
let label = INTEGRATION_TEST_LABEL;
82+
83+
cmd!(sh, "{bck} ephemeral test-basic --label {label} {image}").run()?;
84+
85+
Ok(())
86+
}
87+
integration_test!(test_ephemeral_test_basic);
88+
7389
/// Test running a non-interactive command via SSH
7490
fn test_run_ephemeral_ssh_command() -> TestResult {
7591
let sh = shell()?;

crates/kit/src/ephemeral.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ pub struct ContainerListEntry {
6262
pub command: Vec<String>,
6363
}
6464

65+
/// Options for the test-basic subcommand
66+
#[derive(clap::Parser, Debug)]
67+
pub struct TestBasicOpts {
68+
#[command(flatten)]
69+
pub run_opts: run_ephemeral::RunEphemeralOpts,
70+
}
71+
6572
/// Ephemeral VM operations
6673
#[derive(Debug, Subcommand)]
6774
pub enum EphemeralCommands {
@@ -73,6 +80,10 @@ pub enum EphemeralCommands {
7380
#[clap(name = "run-ssh")]
7481
RunSsh(run_ephemeral_ssh::RunEphemeralSshOpts),
7582

83+
/// Boot an ephemeral VM and verify systemd is healthy
84+
#[clap(name = "test-basic")]
85+
TestBasic(TestBasicOpts),
86+
7687
/// Connect to running VMs via SSH
7788
#[clap(name = "ssh")]
7889
Ssh(SshOpts),
@@ -100,6 +111,18 @@ impl EphemeralCommands {
100111
match self {
101112
EphemeralCommands::Run(opts) => run_ephemeral::run(opts),
102113
EphemeralCommands::RunSsh(opts) => run_ephemeral_ssh::run_ephemeral_ssh(opts),
114+
EphemeralCommands::TestBasic(opts) => {
115+
let ssh_opts = run_ephemeral_ssh::RunEphemeralSshOpts {
116+
run_opts: opts.run_opts,
117+
ssh_args: vec![
118+
"--".to_string(),
119+
"systemctl".to_string(),
120+
"is-system-running".to_string(),
121+
"--wait".to_string(),
122+
],
123+
};
124+
run_ephemeral_ssh::run_ephemeral_ssh(ssh_opts)
125+
}
103126
EphemeralCommands::Ssh(opts) => {
104127
// Create progress bar if stderr is a terminal
105128
let progress_bar = crate::boot_progress::create_boot_progress_bar();

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [ephemeral run](./man/bcvk-ephemeral-run.md)
1515
- [ephemeral ssh](./man/bcvk-ephemeral-ssh.md)
1616
- [ephemeral run-ssh](./man/bcvk-ephemeral-run-ssh.md)
17+
- [ephemeral test-basic](./man/bcvk-ephemeral-test-basic.md)
1718
- [to-disk](./man/bcvk-to-disk.md)
1819
- [images](./man/bcvk-images.md)
1920
- [images list](./man/bcvk-images-list.md)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# NAME
2+
3+
bcvk-ephemeral-test-basic - Boot an ephemeral VM and verify systemd is healthy
4+
5+
# SYNOPSIS
6+
7+
**bcvk ephemeral test-basic** \[*OPTIONS*\] *IMAGE*
8+
9+
# DESCRIPTION
10+
11+
Boot an ephemeral VM from **IMAGE** and verify that systemd reached a healthy
12+
state by running **systemctl is-system-running --wait** via SSH.
13+
14+
This is a quick smoke test for bootc container images. The **--wait** flag
15+
ensures systemd has finished booting before reporting status. The command
16+
exits 0 if systemd reports "running" (all units healthy), or non-zero if
17+
the system is degraded or failed.
18+
19+
Internally this is equivalent to:
20+
21+
bcvk ephemeral run-ssh IMAGE -- systemctl is-system-running --wait
22+
23+
The VM is automatically cleaned up after the check completes.
24+
25+
# OPTIONS
26+
27+
<!-- BEGIN GENERATED OPTIONS -->
28+
Accepts the same options as **bcvk-ephemeral-run**(8).
29+
<!-- END GENERATED OPTIONS -->
30+
31+
# EXAMPLES
32+
33+
Smoke test a Fedora bootc image:
34+
35+
bcvk ephemeral test-basic quay.io/fedora/fedora-bootc:42
36+
37+
Test a locally built image:
38+
39+
podman build -t localhost/mybootc .
40+
bcvk ephemeral test-basic localhost/mybootc
41+
42+
Test with custom resources:
43+
44+
bcvk ephemeral test-basic --memory 4096 --vcpus 2 localhost/mybootc
45+
46+
# SEE ALSO
47+
48+
**bcvk-ephemeral**(8), **bcvk-ephemeral-run-ssh**(8)
49+
50+
# VERSION
51+
52+
<!-- VERSION PLACEHOLDER -->

docs/src/man/bcvk-ephemeral.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ bcvk-ephemeral-ps(8)
5454

5555
: List running ephemeral VMs
5656

57+
bcvk-ephemeral-test-basic(8)
58+
59+
: Boot an ephemeral VM and verify systemd is healthy
60+
5761
bcvk-ephemeral-rm-all(8)
5862

5963
: Remove all ephemeral VM containers
@@ -123,7 +127,7 @@ Or use instance types:
123127
# SEE ALSO
124128

125129
**bcvk**(8), **bcvk-ephemeral-run**(8), **bcvk-ephemeral-run-ssh**(8),
126-
**bcvk-ephemeral-ssh**(8), **bcvk-libvirt**(8)
130+
**bcvk-ephemeral-test-basic**(8), **bcvk-ephemeral-ssh**(8), **bcvk-libvirt**(8)
127131

128132
# VERSION
129133

0 commit comments

Comments
 (0)