Search in sources :

Example 1 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testErrorCreatingService.

@Test
public void testErrorCreatingService() {
    ExecutionEngineImpl engine = new ExecutionEngineImpl();
    engine.setModelClient(modelClient);
    engine.setServiceFactory(new ExecutionServiceFactory() {

        @Override
        public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
            throw new RuntimeException("Unexpected error");
        }
    });
    Order order = executeOrder(engine, createOrder("ErrorCreatingService"));
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionServiceFactory(com.emc.sa.engine.service.ExecutionServiceFactory) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) Test(org.junit.Test)

Example 2 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testClearSomeRollback.

@Test
public void testClearSomeRollback() {
    final EmptyTask rollback1 = new EmptyTask("Rollback 1");
    final EmptyTask rollback2 = new EmptyTask("Rollback 2");
    ExecutionService rollbackService = new EmptyService() {

        @Override
        public void execute() throws Exception {
            addRollback(rollback1);
            clearRollback();
            addRollback(rollback2);
            throw new Exception("Trigger rollback");
        }
    };
    Order order = executeOrder(rollbackService, "ClearSomeRollback");
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
    Assert.assertEquals(false, rollback1.wasRun);
    Assert.assertEquals(true, rollback2.wasRun);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Test(org.junit.Test)

Example 3 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testRollback.

@Test
public void testRollback() {
    final EmptyTask firstRollbackTask = new EmptyTask("First Rollback");
    final EmptyTask secondRollbackTask = new EmptyTask("Second Rollback");
    ExecutionService rollbackService = new EmptyService() {

        @Param
        protected boolean rollback;

        @Override
        public void execute() throws Exception {
            addRollback(firstRollbackTask);
            addRollback(secondRollbackTask);
            if (rollback) {
                throw new Exception("Trigger rollback");
            }
        }
    };
    Order noRollbackOrder = executeOrder(rollbackService, "NoRollback", "rollback=false");
    Assert.assertEquals(OrderStatus.SUCCESS.name(), noRollbackOrder.getOrderStatus());
    Assert.assertFalse(firstRollbackTask.wasRun);
    Assert.assertFalse(secondRollbackTask.wasRun);
    Order rollbackOrder = executeOrder(rollbackService, "Rollback", "rollback=true");
    Assert.assertEquals(OrderStatus.ERROR.name(), rollbackOrder.getOrderStatus());
    Assert.assertTrue(firstRollbackTask.wasRun);
    Assert.assertTrue(secondRollbackTask.wasRun);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Test(org.junit.Test)

Example 4 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testClearRollback.

@Test
public void testClearRollback() {
    final EmptyTask rollback1 = new EmptyTask("Rollback 1");
    final EmptyTask rollback2 = new EmptyTask("Rollback 2");
    ExecutionService rollbackService = new EmptyService() {

        @Override
        public void execute() throws Exception {
            addRollback(rollback1);
            addRollback(rollback2);
            clearRollback();
            throw new Exception("Trigger rollback");
        }
    };
    Order order = executeOrder(rollbackService, "ClearRollback");
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
    Assert.assertEquals(false, rollback1.wasRun);
    Assert.assertEquals(false, rollback2.wasRun);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Test(org.junit.Test)

Example 5 with ExecutionService

use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method testRemoveRollbackByType.

@Test
public void testRemoveRollbackByType() {
    final FailureTask rollback1 = new FailureTask("Rollback 1", "Fail 1");
    final EmptyTask rollback2 = new EmptyTask("Rollback 2");
    ExecutionService rollbackService = new EmptyService() {

        @Override
        public void execute() throws Exception {
            addRollback(rollback1);
            addRollback(rollback2);
            removeRollback(FailureTask.class);
            throw new Exception("Trigger rollback");
        }
    };
    Order order = executeOrder(rollbackService, "RemoveRollbackByType");
    Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
    Assert.assertEquals(false, rollback1.wasRun);
    Assert.assertEquals(true, rollback2.wasRun);
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionService(com.emc.sa.engine.service.ExecutionService) AbstractExecutionService(com.emc.sa.engine.service.AbstractExecutionService) ServiceNotFoundException(com.emc.sa.engine.service.ServiceNotFoundException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Test(org.junit.Test)

Aggregations

ExecutionService (com.emc.sa.engine.service.ExecutionService)7 AbstractExecutionService (com.emc.sa.engine.service.AbstractExecutionService)6 ServiceNotFoundException (com.emc.sa.engine.service.ServiceNotFoundException)6 Order (com.emc.storageos.db.client.model.uimodels.Order)6 Test (org.junit.Test)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 ExecutionServiceFactory (com.emc.sa.engine.service.ExecutionServiceFactory)1 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)1