blob: d88857a67c40087fde7a8be3458b6c4e0bacfa01 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package org.openslx.runvirt.plugin.qemu.configuration;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.openslx.libvirt.domain.Domain;
import org.openslx.libvirt.domain.Domain.CpuCheck;
import org.openslx.libvirt.domain.Domain.CpuMode;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs;
import org.openslx.virtualization.configuration.transformation.TransformationException;
public class TransformationGenericCpuTest
{
@Test
@DisplayName( "Test transformation of VM CPU configuration" )
public void testTransformationGenericCpu() throws TransformationException
{
final TransformationGenericCpu transformation = new TransformationGenericCpu();
final Domain config = TransformationTestUtils.getDefaultDomain();
final CommandLineArgs args = TransformationTestUtils.getDefaultCmdLnArgs();
assertNotEquals( Integer.parseInt( TransformationTestUtils.DEFAULT_VM_NCPUS ), config.getVCpu() );
assertNotEquals( CpuMode.HOST_PASSTHROUGH, config.getCpuMode() );
assertEquals( CpuCheck.PARTIAL, config.getCpuCheck() );
transformation.transform( config, args );
assertEquals( Integer.parseInt( TransformationTestUtils.DEFAULT_VM_NCPUS ), config.getVCpu() );
assertEquals( CpuMode.HOST_PASSTHROUGH, config.getCpuMode() );
assertEquals( CpuCheck.PARTIAL, config.getCpuCheck() );
assertDoesNotThrow( () -> config.validateXml() );
}
@Test
@DisplayName( "Test transformation of VM CPU configuration with unspecified input data" )
public void testTransformationGenericCpuNoData() throws TransformationException
{
final TransformationGenericCpu transformation = new TransformationGenericCpu();
final Domain config = TransformationTestUtils.getDefaultDomain();
final CommandLineArgs args = TransformationTestUtils.getEmptyCmdLnArgs();
assertThrows( TransformationException.class, () -> transformation.transform( config, args ) );
}
}
|