Skip to content

Commit ffd9870

Browse files
committed
integration-tests: Consolidate tests to reduce disk image creation
The integration tests were creating separate disk images for tests that could share the same VM, causing unnecessary duplication of expensive `to-disk` operations. Changes: - Merged `test_base_disks_list_shows_timestamp` into `test_base_disk_creation_and_reuse` - the timestamp test no longer needs its own VM, it can verify the list output after the reuse test creates VMs - Created `test_libvirt_comprehensive_workflow` that consolidates multiple separate tests (`test_libvirt_run_list_json_ssh_metadata`, `test_libvirt_run_with_instancetype`, and `test_libvirt_run_label_functionality`) into a single test that creates one VM and verifies: - Instance type configuration - Label metadata and filtering - JSON output with SSH metadata - VM lifecycle This reduces the number of expensive disk image creations in CI, improving test performance while maintaining the same test coverage. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 255e554 commit ffd9870

2 files changed

Lines changed: 155 additions & 355 deletions

File tree

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

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,41 @@ fn test_base_disk_creation_and_reuse() -> Result<()> {
9191
"Should mention using base disk"
9292
);
9393

94+
// Test base-disks list shows creation timestamp
95+
println!("Testing that base-disks list shows creation timestamp...");
96+
let bck = get_bck_command()?;
97+
let list_output = std::process::Command::new(&bck)
98+
.args(["libvirt", "base-disks", "list"])
99+
.output()
100+
.expect("Failed to run base-disks list");
101+
102+
let list_stdout = String::from_utf8_lossy(&list_output.stdout);
103+
let list_stderr = String::from_utf8_lossy(&list_output.stderr);
104+
105+
if list_output.status.success() {
106+
println!("base-disks list output:\n{}", list_stdout);
107+
108+
// Should have CREATED column in header
109+
assert!(
110+
list_stdout.contains("CREATED"),
111+
"Should show CREATED column in header"
112+
);
113+
114+
// Should show timestamp values (either a date or "unknown")
115+
// Timestamp format is YYYY-MM-DD HH:MM
116+
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}|unknown").unwrap();
117+
let has_timestamp = re.is_match(&list_stdout);
118+
assert!(
119+
has_timestamp,
120+
"Should show timestamp values in CREATED column"
121+
);
122+
123+
println!("✓ base-disks list shows creation timestamp");
124+
} else {
125+
println!("base-disks list failed: {}", list_stderr);
126+
panic!("Failed to run base-disks list: {}", list_stderr);
127+
}
128+
94129
println!("✓ Base disk creation and reuse test passed");
95130
Ok(())
96131
}
@@ -137,76 +172,6 @@ fn test_base_disks_list_command() -> Result<()> {
137172
}
138173
integration_test!(test_base_disks_list_command);
139174

140-
/// Test base-disks list shows creation timestamp
141-
fn test_base_disks_list_shows_timestamp() -> Result<()> {
142-
let test_image = get_test_image();
143-
let bck = get_bck_command()?;
144-
145-
println!("Testing base-disks list shows creation timestamp");
146-
147-
let timestamp = std::time::SystemTime::now()
148-
.duration_since(std::time::UNIX_EPOCH)
149-
.unwrap()
150-
.as_secs();
151-
let vm_name = format!("test-base-timestamp-{}", timestamp);
152-
153-
cleanup_domain(&vm_name);
154-
155-
// Create a VM to ensure we have at least one base disk
156-
println!("Creating VM to generate base disk...");
157-
let vm_output = run_bcvk(&[
158-
"libvirt",
159-
"run",
160-
"--name",
161-
&vm_name,
162-
"--filesystem",
163-
"ext4",
164-
&test_image,
165-
])?;
166-
167-
if !vm_output.success() {
168-
cleanup_domain(&vm_name);
169-
panic!("Failed to create VM: {}", vm_output.stderr);
170-
}
171-
172-
// Run base-disks list
173-
let output = Command::new(&bck)
174-
.args(["libvirt", "base-disks", "list"])
175-
.output()
176-
.expect("Failed to run base-disks list");
177-
178-
let stdout = String::from_utf8_lossy(&output.stdout);
179-
let stderr = String::from_utf8_lossy(&output.stderr);
180-
181-
cleanup_domain(&vm_name);
182-
183-
if output.status.success() {
184-
println!("base-disks list output:\n{}", stdout);
185-
186-
// Should have CREATED column in header
187-
assert!(
188-
stdout.contains("CREATED"),
189-
"Should show CREATED column in header"
190-
);
191-
192-
// Should show timestamp values (either a date or "unknown")
193-
// Timestamp format is YYYY-MM-DD HH:MM
194-
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}|unknown").unwrap();
195-
let has_timestamp = re.is_match(&stdout);
196-
assert!(
197-
has_timestamp,
198-
"Should show timestamp values in CREATED column"
199-
);
200-
201-
println!("✓ base-disks list shows creation timestamp");
202-
} else {
203-
println!("base-disks list failed: {}", stderr);
204-
panic!("Failed to run base-disks list: {}", stderr);
205-
}
206-
Ok(())
207-
}
208-
integration_test!(test_base_disks_list_shows_timestamp);
209-
210175
/// Test base-disks prune command with dry-run
211176
fn test_base_disks_prune_dry_run() -> Result<()> {
212177
let bck = get_bck_command()?;

0 commit comments

Comments
 (0)