From 0d172ab55c6eb9a235870d8f98d619078bb91078 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Tue, 16 Nov 2021 08:43:18 +0100 Subject: Add CPU topology functionality for Libvirt domain XML configs --- .../org/openslx/libvirt/domain/DomainTest.java | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'src/test/java/org/openslx/libvirt/domain') diff --git a/src/test/java/org/openslx/libvirt/domain/DomainTest.java b/src/test/java/org/openslx/libvirt/domain/DomainTest.java index 6b53125..00bf83b 100644 --- a/src/test/java/org/openslx/libvirt/domain/DomainTest.java +++ b/src/test/java/org/openslx/libvirt/domain/DomainTest.java @@ -322,6 +322,74 @@ public class DomainTest assertEquals( CpuCheck.NONE.toString(), vm.getCpuCheck().toString() ); } + @Test + @DisplayName( "Get VM CPU dies from libvirt XML file" ) + public void testGetCpuDies() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + assertEquals( 2, vm.getCpuDies() ); + } + + @Test + @DisplayName( "Set VM CPU dies in libvirt XML file" ) + public void testSetCpuDies() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + vm.setCpuDies( 3 ); + assertEquals( 3, vm.getCpuDies() ); + } + + @Test + @DisplayName( "Get VM CPU sockets from libvirt XML file" ) + public void testGetCpuSockets() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + assertEquals( 3, vm.getCpuSockets() ); + } + + @Test + @DisplayName( "Set VM CPU sockets in libvirt XML file" ) + public void testSetCpuSockets() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + vm.setCpuSockets( 2 ); + assertEquals( 2, vm.getCpuSockets() ); + } + + @Test + @DisplayName( "Get VM CPU cores from libvirt XML file" ) + public void testGetCpuCores() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + assertEquals( 4, vm.getCpuCores() ); + } + + @Test + @DisplayName( "Set VM CPU cores in libvirt XML file" ) + public void testSetCpuCores() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + vm.setCpuCores( 8 ); + assertEquals( 8, vm.getCpuCores() ); + } + + @Test + @DisplayName( "Get VM CPU threads from libvirt XML file" ) + public void testGetCpuThreads() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + assertEquals( 1, vm.getCpuThreads() ); + } + + @Test + @DisplayName( "Set VM CPU threads in libvirt XML file" ) + public void testSetCpuThreads() + { + Domain vm = this.newDomainInstance( "qemu-kvm_default-ubuntu-20-04-vm_cpu-topology.xml" ); + vm.setCpuThreads( 2 ); + assertEquals( 2, vm.getCpuThreads() ); + } + @Test @DisplayName( "Get VM emulator binary from libvirt XML file" ) public void testGetDevicesEmulator() -- cgit v1.2.3-55-g7522