summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorSimon Rettberg2021-07-05 18:44:48 +0200
committerSimon Rettberg2021-08-12 14:40:02 +0200
commit9c6c7dbdb82335393fbfe4c1d71c97a3651dbc7a (patch)
tree5d743a7688bd359366d84cfdc9c6e61ea6ac3753 /src/test
parentRemove invalid XML tag from Libvirt VNC graphic test config (diff)
downloadmaster-sync-shared-9c6c7dbdb82335393fbfe4c1d71c97a3651dbc7a.tar.gz
master-sync-shared-9c6c7dbdb82335393fbfe4c1d71c97a3651dbc7a.tar.xz
master-sync-shared-9c6c7dbdb82335393fbfe4c1d71c97a3651dbc7a.zip
[virtualizer] Get rid of Generics for VirtualizationConfiguration
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java150
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServerTest.java6
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClientTest.java6
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClientTest.java6
-rw-r--r--src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicTestUtils.java4
-rw-r--r--src/test/resources/libvirt/xml/qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml6
6 files changed, 26 insertions, 152 deletions
diff --git a/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java b/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
index fa2ed13..6e14c64 100644
--- a/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
+++ b/src/test/java/org/openslx/virtualization/configuration/VirtualizationConfigurationQemuTest.java
@@ -27,22 +27,19 @@ import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.libvirt.domain.Domain;
-import org.openslx.libvirt.domain.device.ControllerUsb;
import org.openslx.libvirt.domain.device.DiskCdrom;
import org.openslx.libvirt.domain.device.DiskFloppy;
import org.openslx.libvirt.domain.device.DiskStorage;
import org.openslx.libvirt.domain.device.Interface;
-import org.openslx.libvirt.domain.device.Sound;
import org.openslx.libvirt.xml.LibvirtXmlTestResources;
import org.openslx.virtualization.Version;
+import org.openslx.virtualization.configuration.VirtualizationConfiguration.ConfigurableOptionGroup;
import org.openslx.virtualization.configuration.VirtualizationConfiguration.EtherType;
-import org.openslx.virtualization.configuration.VirtualizationConfiguration.EthernetDevType;
-import org.openslx.virtualization.configuration.VirtualizationConfiguration.SoundCardType;
-import org.openslx.virtualization.configuration.VirtualizationConfiguration.UsbSpeed;
import org.openslx.virtualization.configuration.logic.ConfigurationLogicTestUtils;
import org.openslx.virtualization.disk.DiskImage;
-import org.openslx.virtualization.disk.DiskImageTestResources;
import org.openslx.virtualization.disk.DiskImage.ImageFormat;
+import org.openslx.virtualization.disk.DiskImageTestResources;
+import org.openslx.virtualization.hardware.ConfigurationGroups;
public class VirtualizationConfigurationQemuTest
{
@@ -340,58 +337,6 @@ public class VirtualizationConfigurationQemuTest
}
@ParameterizedTest
- @DisplayName( "Test get sound card from VM configuration" )
- @ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-sound.xml" } )
- public void testQemuMetaDataGetSoundCardType( String xmlFileName )
- throws VirtualizationConfigurationException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( xmlFileName );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- SoundCardType soundCardType = vmConfig.getSoundCard();
-
- if ( vmLibvirtDomainConfig.getSoundDevices().isEmpty() ) {
- assertEquals( SoundCardType.NONE, soundCardType );
- } else {
- assertEquals( SoundCardType.HD_AUDIO, soundCardType );
- }
-
- assertDoesNotThrow( () -> vmConfig.validate() );
- }
-
- @ParameterizedTest
- @DisplayName( "Test set sound card in VM configuration" )
- @ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-sound.xml" } )
- public void testQemuMetaDataSetSoundCardType( String xmlFileName )
- throws VirtualizationConfigurationException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( xmlFileName );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- final int numSoundDevsLibvirtDomainXmlBeforeAdd = vmLibvirtDomainConfig.getSoundDevices().size();
-
- vmConfig.setSoundCard( SoundCardType.SOUND_BLASTER );
-
- final int numSoundDevsLibvirtDomainXmlAfterAdd = vmLibvirtDomainConfig.getSoundDevices().size();
-
- assertTrue( numSoundDevsLibvirtDomainXmlBeforeAdd >= 0 );
- assertTrue( numSoundDevsLibvirtDomainXmlAfterAdd > 0 );
-
- Sound addedSoundDevice = vmLibvirtDomainConfig.getSoundDevices().get( 0 );
- assertEquals( Sound.Model.SB16, addedSoundDevice.getModel() );
-
- assertDoesNotThrow( () -> vmConfig.validate() );
- }
-
- @ParameterizedTest
@DisplayName( "Test get ethernet device type from VM configuration" )
@ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-nic.xml" } )
public void testQemuMetaDataGetEthernetDevType( String xmlFileName )
@@ -404,92 +349,21 @@ public class VirtualizationConfigurationQemuTest
final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
.getPrivateDomainFromQemuMetaData( vmConfig );
- EthernetDevType ethernetDeviceType = vmConfig.getEthernetDevType( 0 );
-
- if ( vmLibvirtDomainConfig.getInterfaceDevices().isEmpty() ) {
- assertEquals( EthernetDevType.NONE, ethernetDeviceType );
- } else {
- assertEquals( EthernetDevType.PARAVIRT, ethernetDeviceType );
- }
-
- assertDoesNotThrow( () -> vmConfig.validate() );
- }
-
- @ParameterizedTest
- @DisplayName( "Test set ethernet device type in VM configuration" )
- @ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-nic.xml" } )
- public void testQemuMetaDataSetEthernetDevType( String xmlFileName )
- throws VirtualizationConfigurationException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( xmlFileName );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- vmConfig.setEthernetDevType( 0, EthernetDevType.E1000E );
+ List<ConfigurableOptionGroup> groups = vmConfig.getConfigurableOptions();
- if ( !vmLibvirtDomainConfig.getInterfaceDevices().isEmpty() ) {
- Interface addedEthernetDevice = vmLibvirtDomainConfig.getInterfaceDevices().get( 0 );
- assertEquals( Interface.Model.E1000E, addedEthernetDevice.getModel() );
+ for ( ConfigurableOptionGroup group : groups ) {
+ if ( group.groupIdentifier != ConfigurationGroups.NIC_MODEL )
+ continue;
+ if ( vmLibvirtDomainConfig.getInterfaceDevices().isEmpty() ) {
+ assertEquals( null, group.getSelected() );
+ } else {
+ assertEquals( Interface.Model.VIRTIO.toString(), group.getSelected().getId() );
+ }
}
assertDoesNotThrow( () -> vmConfig.validate() );
}
- @ParameterizedTest
- @DisplayName( "Test get maximal USB speed from VM configuration" )
- @ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-usb.xml" } )
- public void testQemuMetaDataGetMaxUsbSpeed( String xmlFileName )
- throws VirtualizationConfigurationException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( xmlFileName );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- UsbSpeed maxUsbSpeed = vmConfig.getMaxUsbSpeed();
-
- if ( vmLibvirtDomainConfig.getUsbControllerDevices().isEmpty() ) {
- assertEquals( UsbSpeed.NONE, maxUsbSpeed );
- } else {
- assertEquals( UsbSpeed.USB3_0, maxUsbSpeed );
- }
-
- assertDoesNotThrow( () -> vmConfig.validate() );
- }
-
- @ParameterizedTest
- @DisplayName( "Test set maximal USB speed in VM configuration" )
- @ValueSource( strings = { "qemu-kvm_default-archlinux-vm.xml", "qemu-kvm_default-archlinux-vm-no-usb.xml" } )
- public void testQemuMetaDataSetMaxUsbSpeed( String xmlFileName )
- throws VirtualizationConfigurationException, NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException
- {
- File file = LibvirtXmlTestResources.getLibvirtXmlFile( xmlFileName );
- VirtualizationConfigurationQemu vmConfig = new VirtualizationConfigurationQemu( null, file );
-
- final Domain vmLibvirtDomainConfig = VirtualizationConfigurationQemuTest
- .getPrivateDomainFromQemuMetaData( vmConfig );
-
- final int numUsbControllersLibvirtDomainXmlBeforeAdd = vmLibvirtDomainConfig.getUsbControllerDevices().size();
-
- vmConfig.setMaxUsbSpeed( UsbSpeed.USB2_0 );
-
- final int numUsbControllersLibvirtDomainXmlAfterAdd = vmLibvirtDomainConfig.getUsbControllerDevices().size();
-
- assertTrue( numUsbControllersLibvirtDomainXmlBeforeAdd >= 0 );
- assertTrue( numUsbControllersLibvirtDomainXmlAfterAdd > 0 );
-
- ControllerUsb addedUsbControllerDevice = vmLibvirtDomainConfig.getUsbControllerDevices().get( 0 );
- assertEquals( ControllerUsb.Model.ICH9_EHCI1, addedUsbControllerDevice.getModel() );
-
- assertDoesNotThrow( () -> vmConfig.validate() );
- }
-
static Stream<Arguments> configAndEthernetTypeProvider()
{
return Stream.of(
diff --git a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServerTest.java b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServerTest.java
index 01408f0..7493fec 100644
--- a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServerTest.java
+++ b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModClientToDozModServerTest.java
@@ -32,7 +32,7 @@ public class ConfigurationLogicDozModClientToDozModServerTest
final String expectedConfigFileName = "qemu-kvm_default-ubuntu-20-04-vm_transform-privacy.xml";
final File inputConfig = LibvirtXmlTestResources.getLibvirtXmlFile( inputConfigFileName );
final File expectedConfig = LibvirtXmlTestResources.getLibvirtXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModClientToDozModServer logic = new ConfigurationLogicDozModClientToDozModServer();
@@ -53,7 +53,7 @@ public class ConfigurationLogicDozModClientToDozModServerTest
final String expectedConfigFileName = "virtualbox_default-ubuntu_transform-privacy.vbox";
final File inputConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModClientToDozModServer logic = new ConfigurationLogicDozModClientToDozModServer();
@@ -77,7 +77,7 @@ public class ConfigurationLogicDozModClientToDozModServerTest
final String expectedConfigFileName = "vmware-player_default-ubuntu_transform-privacy.vmx";
final File inputConfig = ConfigurationLogicTestResources.getVmwareVmxFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVmwareVmxFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
assertTrue( config.getHdds().size() == 1 );
final ConfigurationLogicDozModClientToDozModServer logic = new ConfigurationLogicDozModClientToDozModServer();
diff --git a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClientTest.java b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClientTest.java
index 844e5ec..5a1098a 100644
--- a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClientTest.java
+++ b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToDozModClientTest.java
@@ -47,7 +47,7 @@ public class ConfigurationLogicDozModServerToDozModClientTest
final String expectedConfigFileName = "qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml";
final File inputConfig = LibvirtXmlTestResources.getLibvirtXmlFile( inputConfigFileName );
final File expectedConfig = LibvirtXmlTestResources.getLibvirtXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModServerToDozModClient logic = new ConfigurationLogicDozModServerToDozModClient();
@@ -68,7 +68,7 @@ public class ConfigurationLogicDozModServerToDozModClientTest
final String expectedConfigFileName = "virtualbox_default-ubuntu_transform-editable.vbox";
final File inputConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModServerToDozModClient logic = new ConfigurationLogicDozModServerToDozModClient();
@@ -93,7 +93,7 @@ public class ConfigurationLogicDozModServerToDozModClientTest
final String expectedConfigFileName = "vmware-player_default-ubuntu_transform-editable.vmx";
final File inputConfig = ConfigurationLogicTestResources.getVmwareVmxFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVmwareVmxFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
assertTrue( config.getHdds().size() == 1 );
final ConfigurationLogicDozModServerToDozModClient logic = new ConfigurationLogicDozModServerToDozModClient();
diff --git a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClientTest.java b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClientTest.java
index 47d8a45..f6d56c3 100644
--- a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClientTest.java
+++ b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicDozModServerToStatelessClientTest.java
@@ -41,7 +41,7 @@ public class ConfigurationLogicDozModServerToStatelessClientTest
final String expectedConfigFileName = "qemu-kvm_default-ubuntu-20-04-vm_transform-non-persistent.xml";
final File inputConfig = LibvirtXmlTestResources.getLibvirtXmlFile( inputConfigFileName );
final File expectedConfig = LibvirtXmlTestResources.getLibvirtXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModServerToStatelessClient logic = new ConfigurationLogicDozModServerToStatelessClient();
@@ -62,7 +62,7 @@ public class ConfigurationLogicDozModServerToStatelessClientTest
final String expectedConfigFileName = "virtualbox_default-ubuntu_transform-non-persistent.vbox";
final File inputConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVirtualBoxXmlFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
final ConfigurationLogicDozModServerToStatelessClient logic = new ConfigurationLogicDozModServerToStatelessClient();
@@ -87,7 +87,7 @@ public class ConfigurationLogicDozModServerToStatelessClientTest
final String expectedConfigFileName = "vmware-player_default-ubuntu_transform-non-persistent.vmx";
final File inputConfig = ConfigurationLogicTestResources.getVmwareVmxFile( inputConfigFileName );
final File expectedConfig = ConfigurationLogicTestResources.getVmwareVmxFile( expectedConfigFileName );
- final VirtualizationConfiguration<?, ?, ?, ?> config;
+ final VirtualizationConfiguration config;
config = ConfigurationLogicTestUtils.newVirtualizationConfigurationInstance( inputConfig );
assertTrue( config.getHdds().size() == 1 );
final ConfigurationLogicDozModServerToStatelessClient logic = new ConfigurationLogicDozModServerToStatelessClient();
diff --git a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicTestUtils.java b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicTestUtils.java
index 11f8ee6..1159d74 100644
--- a/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicTestUtils.java
+++ b/src/test/java/org/openslx/virtualization/configuration/logic/ConfigurationLogicTestUtils.java
@@ -38,9 +38,9 @@ public class ConfigurationLogicTestUtils
private static final String REGEX_UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
private static final String REGEX_SOURCE_FILE_PATHS = "(<source.*file=\")(.*)(\".*>)";
- public static VirtualizationConfiguration<?, ?, ?, ?> newVirtualizationConfigurationInstance( File configFile )
+ public static VirtualizationConfiguration newVirtualizationConfigurationInstance( File configFile )
{
- VirtualizationConfiguration<?, ?, ?, ?> config = null;
+ VirtualizationConfiguration config = null;
try {
config = VirtualizationConfiguration.getInstance( ConfigurationLogicTestUtils.STUB_OS_LIST, configFile );
diff --git a/src/test/resources/libvirt/xml/qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml b/src/test/resources/libvirt/xml/qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml
index aaaee23..bf4de75 100644
--- a/src/test/resources/libvirt/xml/qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml
+++ b/src/test/resources/libvirt/xml/qemu-kvm_default-ubuntu-20-04-vm_transform-editable.xml
@@ -54,14 +54,14 @@
<address bus="0" controller="0" target="0" type="drive" unit="0"/>
<readonly/>
</disk>
- <controller index="0" model="ich9-ehci1" type="usb">
+ <controller index="0" model="ich9-uhci1" type="usb">
<address bus="0x00" domain="0x0000" function="0x7" slot="0x1d" type="pci"/>
</controller>
- <controller index="0" model="ich9-ehci1" type="usb">
+ <controller index="0" model="ich9-uhci2" type="usb">
<master startport="0"/>
<address bus="0x00" domain="0x0000" function="0x0" multifunction="on" slot="0x1d" type="pci"/>
</controller>
- <controller index="0" model="ich9-ehci1" type="usb">
+ <controller index="0" model="ich9-uhci3" type="usb">
<master startport="2"/>
<address bus="0x00" domain="0x0000" function="0x1" slot="0x1d" type="pci"/>
</controller>