Skip to content

Commit 1fd9fac

Browse files
committed
update VM tests
Added gpu_passthrough field to all VMConfig instances A real GPU ID was used for GPU testing None value assigned in other tests
1 parent eda99fc commit 1fd9fac

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/vm_tests.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,43 @@ fn test_vm_config() -> VMConfig {
2424
vcpus: 2,
2525
disk_path: PathBuf::from(format!("/var/lib/gpu-share/images/test-{}.qcow2", uuid)),
2626
disk_size_gb: 10,
27+
gpu_passthrough: None,
28+
}
29+
}
30+
31+
// GPU test config
32+
async fn create_gpu_vm_config() -> VMConfig {
33+
VMConfig {
34+
name: "gpu-test-vm".into(),
35+
memory_kb: 8 * 1024 * 1024,
36+
vcpus: 4,
37+
disk_path: PathBuf::from("/var/lib/libvirt/images/gpu-test.qcow2"),
38+
disk_size_gb: 40,
39+
gpu_passthrough: Some("0000:01:00.0".into()),
40+
}
41+
}
42+
43+
// Big Scale VM Test
44+
fn create_large_vm_config() -> VMConfig {
45+
VMConfig {
46+
name: "large-test-vm".into(),
47+
memory_kb: 16 * 1024 * 1024,
48+
vcpus: 8,
49+
disk_path: PathBuf::from("/var/lib/libvirt/images/large-test.qcow2"),
50+
disk_size_gb: 100,
51+
gpu_passthrough: None,
52+
}
53+
}
54+
55+
// Minimum Resources Test
56+
fn create_minimal_vm_config() -> VMConfig {
57+
VMConfig {
58+
name: "minimal-test-vm".into(),
59+
memory_kb: 512 * 1024,
60+
vcpus: 1,
61+
disk_path: PathBuf::from("/var/lib/libvirt/images/minimal-test.qcow2"),
62+
disk_size_gb: 10,
63+
gpu_passthrough: None,
2764
}
2865
}
2966

@@ -74,6 +111,7 @@ async fn test_concurrent_vm_creation() -> Result<()> {
74111
vcpus: 1,
75112
disk_path: PathBuf::from(format!("/var/lib/gpu-share/images/stress-{}.qcow2", i)),
76113
disk_size_gb: 5,
114+
gpu_passthrough: None,
77115
};
78116

79117
handles.push(tokio::spawn(async move {
@@ -104,6 +142,7 @@ async fn test_invalid_vm_configurations() -> Result<()> {
104142
vcpus: 2,
105143
disk_path: PathBuf::from("/invalid/path.qcow2"),
106144
disk_size_gb: 10,
145+
gpu_passthrough: None,
107146
};
108147

109148
let result = libvirt.0.create_vm(&config).await;
@@ -116,6 +155,7 @@ async fn test_invalid_vm_configurations() -> Result<()> {
116155
vcpus: 2,
117156
disk_path: PathBuf::from("/dev/null"), // Invalid disk image
118157
disk_size_gb: 10,
158+
gpu_passthrough: None,
119159
};
120160

121161
let result = libvirt.0.create_vm(&config).await;

0 commit comments

Comments
 (0)