Skip to content

Commit 96aea8c

Browse files
Sebastien Boeufbryteise
authored andcommitted
ch_integration_tests: Extend domain with 'current' cVPUs
Adding the 'current' parameter to the <vcpu> node allows to make the distinction between "boot" and "max" parameters referring to the vCPUs. Signed-off-by: Sebastien Boeuf <[email protected]>
1 parent a673781 commit 96aea8c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

ch_integration_tests/tests/integration.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ mod tests {
2424
const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64.raw";
2525

2626
pub const DEFAULT_TCP_LISTENER_PORT: u16 = 8000;
27-
const DEFAULT_VCPUS: u8 = 1;
2827
const DEFAULT_RAM_SIZE: u64 = 1 << 30;
2928

3029
lazy_static! {
@@ -44,6 +43,17 @@ mod tests {
4443
}
4544
}
4645

46+
struct VcpuConfig {
47+
boot: u8,
48+
max: u8,
49+
}
50+
51+
impl Default for VcpuConfig {
52+
fn default() -> Self {
53+
VcpuConfig { boot: 1, max: 1 }
54+
}
55+
}
56+
4757
struct Guest<'a> {
4858
tmp_dir: TempDir,
4959
vm_name: String,
@@ -56,7 +66,7 @@ mod tests {
5666
impl<'a> std::panic::RefUnwindSafe for Guest<'a> {}
5767

5868
impl<'a> Guest<'a> {
59-
fn create_domain(&self, vcpus: u8, memory_size: u64) -> PathBuf {
69+
fn create_domain(&self, vcpus: VcpuConfig, memory_size: u64) -> PathBuf {
6070
let domain = format!(
6171
"<domain type='ch'> \
6272
<name>{}</name> \
@@ -68,7 +78,7 @@ mod tests {
6878
<type>hvm</type> \
6979
<kernel>{}</kernel> \
7080
</os> \
71-
<vcpu>{}</vcpu> \
81+
<vcpu current='{}'>{}</vcpu> \
7282
<memory unit='b'>{}</memory> \
7383
<devices> \
7484
<disk type='file'> \
@@ -96,7 +106,8 @@ mod tests {
96106
self.vm_name,
97107
self.vm_name,
98108
self.kernel_path.to_str().unwrap(),
99-
vcpus,
109+
vcpus.boot,
110+
vcpus.max,
100111
memory_size,
101112
self.disk_config
102113
.disk(DiskType::OperatingSystem)
@@ -231,7 +242,7 @@ mod tests {
231242
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
232243
let guest = Guest::new(&mut disk);
233244

234-
let domain_path = guest.create_domain(DEFAULT_VCPUS, DEFAULT_RAM_SIZE);
245+
let domain_path = guest.create_domain(VcpuConfig::default(), DEFAULT_RAM_SIZE);
235246

236247
let r = std::panic::catch_unwind(|| {
237248
let output = spawn_virsh(&["create", domain_path.to_str().unwrap()])
@@ -289,7 +300,7 @@ mod tests {
289300

290301
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
291302
let guest = Guest::new(&mut disk);
292-
let domain_path = guest.create_domain(DEFAULT_VCPUS, DEFAULT_RAM_SIZE);
303+
let domain_path = guest.create_domain(VcpuConfig::default(), DEFAULT_RAM_SIZE);
293304
let output = spawn_virsh(&["define", domain_path.to_str().unwrap()])
294305
.unwrap()
295306
.wait_with_output()
@@ -347,7 +358,7 @@ mod tests {
347358
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
348359
let guest = Guest::new(&mut disk);
349360

350-
let domain_path = guest.create_domain(DEFAULT_VCPUS, 128 << 30);
361+
let domain_path = guest.create_domain(VcpuConfig::default(), 128 << 30);
351362

352363
let r = std::panic::catch_unwind(|| {
353364
spawn_virsh(&["create", domain_path.to_str().unwrap()])
@@ -386,7 +397,7 @@ mod tests {
386397
let mut disk = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_owned());
387398
let guest = Guest::new(&mut disk);
388399

389-
let domain_path = guest.create_domain(4, DEFAULT_RAM_SIZE);
400+
let domain_path = guest.create_domain(VcpuConfig { boot: 4, max: 4 }, DEFAULT_RAM_SIZE);
390401

391402
let r = std::panic::catch_unwind(|| {
392403
spawn_virsh(&["create", domain_path.to_str().unwrap()])

0 commit comments

Comments
 (0)