Search in sources :

Example 31 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.

the class VmHandlerTest method testValidUpdateOfHotSetEditableFieldOnRunningVm.

@Test
public void testValidUpdateOfHotSetEditableFieldOnRunningVm() {
    // Given
    int srcNumOfSockets = 2;
    int destNumOfSockets = 4;
    VmStatic src = new VmStatic();
    src.setNumOfSockets(srcNumOfSockets);
    VmStatic dest = new VmStatic();
    dest.setNumOfSockets(destNumOfSockets);
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Up, true);
    // Then
    assertTrue("Update should be valid for different number of sockets on a running VM", updateIsValid);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 32 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.

the class VmHandlerTest method testInvalidUpdateOfNonEditableFieldOnRunningVm.

@Test
public void testInvalidUpdateOfNonEditableFieldOnRunningVm() {
    // Given
    VmStatic src = new VmStatic();
    src.setId(Guid.newGuid());
    VmStatic dest = new VmStatic();
    dest.setId(Guid.newGuid());
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest);
    // Then
    assertFalse("Update should be invalid for different IDs", updateIsValid);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 33 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.

the class VmHandlerTest method testInvalidUpdateOfHostedEngineNonEditableFieldOnRunningVm.

@Test
public void testInvalidUpdateOfHostedEngineNonEditableFieldOnRunningVm() {
    // Given
    VmStatic src = new VmStatic();
    src.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    src.setName(RandomUtils.instance().nextString(10));
    VmStatic dest = new VmStatic();
    dest.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    dest.setName(RandomUtils.instance().nextString(10));
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Up, false);
    // Then
    assertFalse("Update should be invalid for different names on a running, hosted engine VM", updateIsValid);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 34 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.

the class VmHandlerTest method testUpdateFieldsNameInStatusUp.

@Test
public void testUpdateFieldsNameInStatusUp() {
    VmStatic src = new VmStatic();
    src.setName(RandomUtils.instance().nextString(10));
    src.setInterfaces(new ArrayList<>(2));
    VmStatic dest = new VmStatic();
    dest.setName(RandomUtils.instance().nextString(10));
    assertFalse("Update should not be valid for different names", vmHandler.isUpdateValid(src, dest));
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 35 with VmStatic

use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.

the class UpdateClusterCommandTest method vmsAreUpdatedByTheOrderOfTheirIds.

@Test
public void vmsAreUpdatedByTheOrderOfTheirIds() {
    final Cluster newerCluster = createDefaultCluster();
    newerCluster.setCompatibilityVersion(new Version(1, 2));
    createCommand(newerCluster);
    cmd.init();
    VmStatic vm1 = new VmStatic();
    vm1.setId(VM_ID1);
    VmStatic vm2 = new VmStatic();
    vm2.setId(VM_ID2);
    VmStatic vm3 = new VmStatic();
    vm3.setId(VM_ID3);
    when(vmStaticDao.getAllByCluster(any())).thenReturn(Arrays.asList(vm1, vm2, vm3));
    // the VMs ordered by Guids: v2, v3, v1
    assertEquals(Arrays.asList(vm2, vm3, vm1), cmd.filterVmsInClusterNeedUpdate());
}
Also used : Version(org.ovirt.engine.core.compat.Version) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Aggregations

VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)87 Test (org.junit.Test)26 Guid (org.ovirt.engine.core.compat.Guid)15 VM (org.ovirt.engine.core.common.businessentities.VM)11 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)8 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)8 Label (org.ovirt.engine.core.common.businessentities.Label)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)4 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 Before (org.junit.Before)3