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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations