Search in sources :

Example 21 with FenceOperationResult

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

the class HostFenceActionExecutorTest method successfulFenceWith1stError2ndSuccess.

/**
 * Test successful fence action when the 1st of 2 sequential fence agents returns error and 2nd one return success
 */
@Test
public void successfulFenceWith1stError2ndSuccess() {
    mockFenceAgents();
    // result of fence action invoked on 1st sequential agent
    mockFenceResult(agentExecutor1, new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN));
    // result of fence action invoked on 2nd sequential agent
    mockFenceResult(agentExecutor2, new FenceOperationResult(Status.SUCCESS, PowerStatus.ON));
    FenceOperationResult result = executor.fence(FenceActionType.STATUS);
    assertEquals(Status.SUCCESS, result.getStatus());
    assertEquals(PowerStatus.ON, result.getPowerStatus());
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 22 with FenceOperationResult

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

the class SingleAgentFenceActionExecutorTest method successfulStartWithStatusRetry.

/**
 * Test successful start action with 1 status retry
 */
@Test
public void successfulStartWithStatusRetry() {
    FenceOperationResult expectedResult = new FenceOperationResult(Status.SUCCESS, PowerStatus.ON);
    FenceOperationResult[] expectedResults = { // result of start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 1st status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.ON), expectedResult };
    mockFenceActionResults(expectedResults);
    FenceOperationResult result = executor.fence(FenceActionType.START);
    validateResult(expectedResult, result);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 23 with FenceOperationResult

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

the class SingleAgentFenceActionExecutorTest method failedStartStatusRetriesExceeded.

/**
 * Test start action with status retries exceeded
 */
@Test
public void failedStartStatusRetriesExceeded() {
    FenceOperationResult expectedResult = new FenceOperationResult(Status.ERROR, PowerStatus.OFF);
    FenceOperationResult[] expectedResults = { // result of 1st start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 1st status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF), // result of 2nd status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF), // result of 2nd start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 1st status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF), // result of 2nd status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.OFF) };
    mockFenceActionResults(expectedResults);
    FenceOperationResult result = executor.fence(FenceActionType.START);
    validateResult(expectedResult, result);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 24 with FenceOperationResult

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

the class SingleAgentFenceActionExecutorTest method failedStartUnknownStatusLimitExceeded.

/**
 * Test start action with UNKNOWN power status limit exceeded
 */
@Test
public void failedStartUnknownStatusLimitExceeded() {
    FenceOperationResult expectedResult = new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN);
    FenceOperationResult[] expectedResults = { // result of 1st start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 1st status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 2nd start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of 1st status action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN) };
    mockFenceActionResults(expectedResults);
    FenceOperationResult result = executor.fence(FenceActionType.START);
    validateResult(expectedResult, result);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Example 25 with FenceOperationResult

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

the class SingleAgentFenceActionExecutorTest method successfulStartWithStartRetry.

/**
 * Test successful start action, when the 1st start attempt failed, but the 2nd one was successful
 */
@Test
public void successfulStartWithStartRetry() {
    FenceOperationResult expectedResult = new FenceOperationResult(Status.SUCCESS, PowerStatus.ON);
    FenceOperationResult[] expectedResults = { // result of the 1st start action
    new FenceOperationResult(Status.ERROR, PowerStatus.UNKNOWN), // result of the 2nd start action
    new FenceOperationResult(Status.SUCCESS, PowerStatus.UNKNOWN), // result of status action
    expectedResult };
    mockFenceActionResults(expectedResults);
    FenceOperationResult result = executor.fence(FenceActionType.START);
    validateResult(expectedResult, result);
}
Also used : FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) Test(org.junit.Test)

Aggregations

FenceOperationResult (org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult)58 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)2 Action (org.ovirt.engine.api.model.Action)2 FenceAgent (org.ovirt.engine.core.common.businessentities.pm.FenceAgent)2 PowerStatus (org.ovirt.engine.core.common.businessentities.pm.PowerStatus)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 Response (javax.ws.rs.core.Response)1 PowerManagement (org.ovirt.engine.api.model.PowerManagement)1 PowerManagementStatus (org.ovirt.engine.api.model.PowerManagementStatus)1 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)1 HostFenceActionExecutor (org.ovirt.engine.core.bll.pm.HostFenceActionExecutor)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1