Search in sources :

Example 16 with Stack

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

the class MsoHeatUtilsTest method postProcessStackDelete_Stack_Test.

@Test
public final void postProcessStackDelete_Stack_Test() throws MsoException, IOException {
    Stack deletedStack = new Stack();
    deletedStack.setId("id");
    deletedStack.setStackName("stackName");
    deletedStack.setStackStatus("DELETE_FAILED");
    deletedStack.setStackStatusReason("Stack DID NOT DELETE");
    exceptionRule.expect(StackRollbackException.class);
    exceptionRule.expectMessage("Stack Deletion completed with status: DELETE_FAILED Status Reason: Stack DID NOT DELETE");
    heatUtils.postProcessStackDelete(deletedStack);
}
Also used : 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 17 with Stack

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

the class MsoHeatUtilsTest method handleUnknownCreateStackFailure_Null_Stack_Test.

@Test
public final void handleUnknownCreateStackFailure_Null_Stack_Test() throws MsoException, IOException {
    Stack stack = null;
    exceptionRule.expect(StackCreationException.class);
    exceptionRule.expectMessage("Cannot Find Stack Name or Id");
    heatUtils.handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
}
Also used : 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 18 with Stack

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

the class MsoHeatUtilsWithUpdateTest method updateStackWithEnvironmentTest.

@Test
public void updateStackWithEnvironmentTest() throws JsonParseException, JsonMappingException, IOException, MsoException {
    String environmentString = "environmentString";
    CloudSite cloudSite = new CloudSite();
    Heat heatClient = new Heat("endpoint");
    Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class);
    Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class);
    StackInfo expectedStackInfo = new StackInfo("stackName", HeatStatus.UPDATED, "stackStatusReason", null);
    expectedStackInfo.setCanonicalName("stackName/id");
    doReturn(heatClient).when(heatUtils).getHeatClient(isA(String.class), isA(String.class));
    doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(isA(OpenStackRequest.class));
    doReturn("0").when(environment).getProperty(isA(String.class), isA(String.class));
    doReturn(updateStack).when(heatUtils).queryHeatStack(isA(Heat.class), isA(String.class));
    StackInfo actualStackInfo = heatUtils.updateStack(cloudSiteId, cloudOwner, tenantId, stackName, heatTemplate, stackInputs, pollForCompletion, timeoutMinutes, environmentString);
    assertThat(actualStackInfo, sameBeanAs(expectedStackInfo));
}
Also used : Heat(com.woorea.openstack.heat.Heat) CloudSite(org.onap.so.db.catalog.beans.CloudSite) OpenStackRequest(com.woorea.openstack.base.client.OpenStackRequest) File(java.io.File) StackInfo(org.onap.so.openstack.beans.StackInfo) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 19 with Stack

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

the class StackStatusHandlerTest method recordExists_Test.

@Test
public final void recordExists_Test() throws MsoException, IOException {
    RequestProcessingData requestProcessingData = new RequestProcessingData();
    requestProcessingData.setValue("testMe");
    String requestId = getRequestId();
    doReturn(requestProcessingData).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, "stackName", "id");
    Stack latestStack = new Stack();
    latestStack.setId("id");
    latestStack.setStackName("stackName");
    latestStack.setStackStatus("CREATE_COMPLETE");
    latestStack.setStackStatusReason("Stack Finished");
    statusHandler.updateStackStatus(latestStack, requestId);
    Mockito.verify(requestDBClient, times(1)).updateRequestProcessingData(requestProcessingData);
    assertNotEquals("testMe", requestProcessingData.getValue());
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) Stack(com.woorea.openstack.heat.model.Stack) Test(org.junit.Test)

Example 20 with Stack

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

the class StackStatusHandlerTest method record_Not_Exists_Test.

@Test
public final void record_Not_Exists_Test() throws MsoException, IOException {
    String requestId = getRequestId();
    ArgumentCaptor<RequestProcessingData> requestCaptor = ArgumentCaptor.forClass(RequestProcessingData.class);
    doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, "stackName", "id");
    Stack latestStack = new Stack();
    latestStack.setId("id");
    latestStack.setStackName("stackName");
    latestStack.setStackStatus("CREATE_COMPLETE");
    latestStack.setStackStatusReason("Stack Finished");
    statusHandler.updateStackStatus(latestStack, requestId);
    Mockito.verify(requestDBClient, times(1)).saveRequestProcessingData(requestCaptor.capture());
    RequestProcessingData actualRequest = requestCaptor.getValue();
    assertEquals("id", actualRequest.getGroupingId());
    assertEquals("StackInformation", actualRequest.getTag());
    assertEquals("stackName", actualRequest.getName());
    assertNotNull(actualRequest.getValue());
}
Also used : RequestProcessingData(org.onap.so.db.request.beans.RequestProcessingData) Stack(com.woorea.openstack.heat.model.Stack) 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