Search in sources :

Example 11 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class StackInfoMapperTest method mapRemainingFields.

@Test
public void mapRemainingFields() {
    Stack stack = new Stack();
    stack.setStackName("name");
    stack.setId("id");
    stack.setStackStatusReason("message");
    stack.setParameters(new HashMap<String, Object>());
    StackInfoMapper mapper = new StackInfoMapper(stack);
    StackInfo info = mapper.map();
    assertEquals("name", info.getName());
    assertEquals("name/id", info.getCanonicalName());
    assertEquals("message", info.getStatusMessage());
    assertEquals(stack.getParameters(), info.getParameters());
}
Also used : StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 12 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class MsoHeatUtilsTest method handleUnknownCreateStackFailure_Test.

@Test
public final void handleUnknownCreateStackFailure_Test() throws MsoException, IOException {
    Stack stack = new Stack();
    stack.setId("id");
    stack.setStackName("stackName");
    stack.setStackStatus("CREATE_FAILED");
    stack.setStackStatusReason("Resource CREATE failed: Conflict: resources.my_keypair: Key pair 'hst3bbfnm0011vm001' already exists. (HTTP 409) (Request-ID: req-941b0af6-63ae-4d6a-afbc-90b728bacf82");
    Stack deletedStack = new Stack();
    deletedStack.setId("id");
    deletedStack.setStackName("stackName");
    deletedStack.setStackStatus("DELETE_COMPLETE");
    deletedStack.setStackStatusReason("Stack Deleted");
    CreateStackParam createStackParam = new CreateStackParam();
    createStackParam.setStackName("stackName");
    doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
    doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(mockDeleteStack);
    doReturn(stackResource).when(heatClient).getStacks();
    doReturn(mockDeleteStack).when(stackResource).deleteByName("stackName/id");
    heatUtils.handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
    Mockito.verify(heatUtils, times(1)).executeAndRecordOpenstackRequest(mockDeleteStack);
    Mockito.verify(heatUtils, times(0)).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId, true);
    Mockito.verify(heatUtils, times(0)).postProcessStackDelete(deletedStack);
}
Also used : CreateStackParam(com.woorea.openstack.heat.model.CreateStackParam) Stack(com.woorea.openstack.heat.model.Stack) CreateStack(com.woorea.openstack.heat.StackResource.CreateStack) DeleteStack(com.woorea.openstack.heat.StackResource.DeleteStack) Test(org.junit.Test)

Example 13 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class MsoHeatUtilsTest method pollStackForStatus_Polling_Exhausted_Test.

@Test
public final void pollStackForStatus_Polling_Exhausted_Test() throws MsoException, IOException {
    Stack stack = new Stack();
    stack.setId("id");
    stack.setStackName("stackName");
    stack.setStackStatus("CREATE_IN_PROGRESS");
    stack.setStackStatusReason("Stack Finished");
    String requestId = getRequestId();
    doNothing().when(stackStatusHandler).updateStackStatus(stack, requestId);
    doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
    doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
    Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
    Mockito.verify(stackStatusHandler, times(5)).updateStackStatus(stack, requestId);
    Mockito.verify(heatUtils, times(5)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
    assertEquals(true, actual != null);
}
Also used : Heat(com.woorea.openstack.heat.Heat) Stack(com.woorea.openstack.heat.model.Stack) CreateStack(com.woorea.openstack.heat.StackResource.CreateStack) DeleteStack(com.woorea.openstack.heat.StackResource.DeleteStack) Test(org.junit.Test)

Example 14 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class MsoHeatUtilsTest method processCreateStack_Exception_No_Backout_Test.

@Test
public final void processCreateStack_Exception_No_Backout_Test() throws MsoException, IOException, NovaClientException {
    Stack stack = new Stack();
    stack.setId("id");
    stack.setStackName("stackName");
    stack.setStackStatus("CREATE_FAILED");
    stack.setStackStatusReason("Resource CREATE failed: Conflict: resources.my_keypair: Key pair 'hst3bbfnm0011vm001' already exists. (HTTP 409) (Request-ID: req-941b0af6-63ae-4d6a-afbc-90b728bacf82");
    Stack deletedStack = new Stack();
    deletedStack.setId("id");
    deletedStack.setStackName("stackName");
    deletedStack.setStackStatus("DELETE_COMPLETE");
    deletedStack.setStackStatusReason("Stack Deleted");
    CreateStackParam createStackParam = new CreateStackParam();
    createStackParam.setStackName("stackName");
    doThrow(new StackCreationException("Error")).when(heatUtils).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
    exceptionRule.expect(MsoException.class);
    exceptionRule.expectMessage("Error");
    heatUtils.processCreateStack(cloudSiteId, tenantId, 120, false, stack, createStackParam, true);
    Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
    Mockito.verify(heatUtils, times(0)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
}
Also used : CreateStackParam(com.woorea.openstack.heat.model.CreateStackParam) Stack(com.woorea.openstack.heat.model.Stack) CreateStack(com.woorea.openstack.heat.StackResource.CreateStack) DeleteStack(com.woorea.openstack.heat.StackResource.DeleteStack) Test(org.junit.Test)

Example 15 with Stack

use of com.woorea.openstack.heat.model.Stack in project so by onap.

the class MsoHeatUtilsTest method postProcessStackCreate_CREATE_IN_PROGRESS_Test.

@Test
public final void postProcessStackCreate_CREATE_IN_PROGRESS_Test() throws MsoException, IOException {
    Stack stack = new Stack();
    stack.setId("id");
    stack.setStackName("stackName");
    stack.setStackStatus("CREATE_IN_PROGRESS");
    stack.setStackStatusReason("Stack In Progress");
    CreateStackParam createStackParam = new CreateStackParam();
    createStackParam.setStackName("stackName");
    exceptionRule.expect(StackCreationException.class);
    exceptionRule.expectMessage("Stack Creation Failed Openstack Status: CREATE_IN_PROGRESS Status Reason: Stack In Progress. Stack rollback suppressed, stack not deleted");
    heatUtils.postProcessStackCreate(stack, false, 120, false, cloudSiteId, tenantId, createStackParam);
}
Also used : CreateStackParam(com.woorea.openstack.heat.model.CreateStackParam) Stack(com.woorea.openstack.heat.model.Stack) CreateStack(com.woorea.openstack.heat.StackResource.CreateStack) DeleteStack(com.woorea.openstack.heat.StackResource.DeleteStack) Test(org.junit.Test)

Aggregations

Stack (com.woorea.openstack.heat.model.Stack)41 Test (org.junit.Test)26 CreateStack (com.woorea.openstack.heat.StackResource.CreateStack)15 DeleteStack (com.woorea.openstack.heat.StackResource.DeleteStack)15 CreateStackParam (com.woorea.openstack.heat.model.CreateStackParam)10 Heat (com.woorea.openstack.heat.Heat)9 StackInfo (org.onap.so.openstack.beans.StackInfo)9 StackInfoMapper (org.onap.so.openstack.mappers.StackInfoMapper)7 MsoException (org.onap.so.openstack.exceptions.MsoException)5 OpenStackRequest (com.woorea.openstack.base.client.OpenStackRequest)3 File (java.io.File)3 HashMap (java.util.HashMap)3 CloudSite (org.onap.so.db.catalog.beans.CloudSite)3 MsoOpenstackException (org.onap.so.openstack.exceptions.MsoOpenstackException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RequestProcessingData (org.onap.so.db.request.beans.RequestProcessingData)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)1 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)1 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1