Search in sources :

Example 1 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method startedStepsByStepSubjectEntityOtherEntityTYpe.

@Test
public void startedStepsByStepSubjectEntityOtherEntityTYpe() {
    StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
    subjectEntity.setEntityType(VdcObjectType.AdElements);
    assertNoStartedStepsForSubjectEntity(subjectEntity);
}
Also used : StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 2 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepSubjectEntityDaoTest method saveStepSubjectEntities.

@Test
public void saveStepSubjectEntities() {
    VdcObjectType type = VdcObjectType.VmPool;
    Guid entityId = Guid.newGuid();
    StepSubjectEntity stepSubjectEntity = new StepSubjectEntity(FixturesTool.STEP_ID, type, entityId, 50);
    Guid entityId2 = Guid.newGuid();
    StepSubjectEntity stepSubjectEntity2 = new StepSubjectEntity(FixturesTool.STEP_ID, type, entityId2, 50);
    dao.saveAll(Arrays.asList(stepSubjectEntity, stepSubjectEntity2));
    List<StepSubjectEntity> entities = dao.getStepSubjectEntitiesByStepId(FixturesTool.STEP_ID);
    assertEquals("StepSubjectEntity list not in the expected size", 4, entities.size());
    assertSubjectEntityPresence(stepSubjectEntity, entities, true);
    assertSubjectEntityPresence(stepSubjectEntity2, entities, true);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 3 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class VdsCommandsHelper method chooseHostForExecution.

private void chooseHostForExecution(VdsIdVDSCommandParametersBase parametersBase, Guid storagePoolId, CommandBase<?> cmd, Collection<Guid> executedHosts) {
    Guid vdsForExecution = getHostForExecution(storagePoolId, executedHosts);
    parametersBase.setVdsId(vdsForExecution);
    if (cmd != null) {
        if (cmd.getCommandStep() != null && cmd.getExecutionContext().getStep() != null) {
            Guid stepId = cmd.getExecutionContext().getStep().getId();
            if (cmd.getParameters().getVdsRunningOn() != null) {
                stepSubjectEntityDao.remove(cmd.getParameters().getVdsRunningOn(), stepId);
            }
            if (vdsForExecution != null) {
                stepSubjectEntityDao.saveAll(Collections.singletonList(new StepSubjectEntity(stepId, VdcObjectType.EXECUTION_HOST, vdsForExecution)));
                updateStepMessage(cmd, vdsForExecution);
            }
        }
        cmd.getParameters().setVdsRunningOn(vdsForExecution);
        cmd.persistCommand(cmd.getParameters().getParentCommand(), cmd.getCallback() != null);
    }
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity)

Example 4 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method startedStepsByStepSubjectEntityOtherId.

@Test
public void startedStepsByStepSubjectEntityOtherId() {
    StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
    subjectEntity.setEntityId(Guid.Empty);
    assertNoStartedStepsForSubjectEntity(subjectEntity);
}
Also used : StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 5 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method startedStepsByStepSubjectEntityNoStepsHaveStep.

@Test
public void startedStepsByStepSubjectEntityNoStepsHaveStep() {
    StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
    List<Step> steps = dao.getStartedStepsByStepSubjectEntity(subjectEntity);
    assertEquals(1, steps.size());
    assertEquals(subjectEntity.getStepId(), steps.get(0).getId());
}
Also used : Step(org.ovirt.engine.core.common.job.Step) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Aggregations

StepSubjectEntity (org.ovirt.engine.core.common.job.StepSubjectEntity)11 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)5 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)4 Step (org.ovirt.engine.core.common.job.Step)3 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)2 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Matchers.emptyCollectionOf (org.hamcrest.Matchers.emptyCollectionOf)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Step (org.ovirt.engine.api.model.Step)1 SubjectEntity (org.ovirt.engine.core.common.businessentities.SubjectEntity)1 ExternalSystemType (org.ovirt.engine.core.common.job.ExternalSystemType)1