Skip to content

Commit 81ef571

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 2c7c363 commit 81ef571

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
@@ -92,6 +92,41 @@ fn test_base_disk_creation_and_reuse() -> Result<()> {
9292
"Should mention using base disk"
9393
);
9494

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

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

0 commit comments

Comments
 (0)