use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class StackUpdaterTest method updateStackStatusAndReasonThenNotificationSentOnWebsocket.
@Test
public void updateStackStatusAndReasonThenNotificationSentOnWebsocket() {
Stack stack = TestUtil.stack();
DetailedStackStatus newStatus = DetailedStackStatus.DELETE_COMPLETED;
String newStatusReason = "test";
StackStatus testStackStatus = new StackStatus(stack, newStatus.getStatus(), newStatusReason, newStatus);
when(stackStatusRepository.save(any(StackStatus.class))).thenReturn(testStackStatus);
when(stackRepository.findOne(anyLong())).thenReturn(stack);
when(stackRepository.save(any(Stack.class))).thenReturn(stack);
doNothing().when(cloudbreakEventService).fireCloudbreakEvent(anyLong(), anyString(), anyString());
when(statusToPollGroupConverter.convert(newStatus.getStatus())).thenReturn(PollGroup.POLLABLE);
Stack newStack = underTest.updateStackStatus(1L, newStatus, newStatusReason);
assertEquals(newStatus.getStatus(), newStack.getStatus());
assertEquals(newStatusReason, newStack.getStatusReason());
}
use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class DefaultStackHostServiceTypeTest method stack.
private Stack stack(Status stackStatus, Status clusterStatus) {
Credential gcpCredential = new Credential();
Stack stack = new Stack();
stack.setName("simplestack");
stack.setStackStatus(new StackStatus(stack, stackStatus, "", DetailedStackStatus.UNKNOWN));
stack.setCredential(gcpCredential);
stack.setId(1L);
Cluster cluster = new Cluster();
cluster.setStatus(clusterStatus);
cluster.setId(1L);
stack.setCluster(cluster);
return stack;
}
use of com.sequenceiq.cloudbreak.domain.StackStatus in project cloudbreak by hortonworks.
the class StackUpdater method doUpdateStackStatus.
private Stack doUpdateStackStatus(Long stackId, DetailedStackStatus detailedStatus, String statusReason) {
Stack stack = stackRepository.findOne(stackId);
Status status = detailedStatus.getStatus();
if (!stack.isDeleteCompleted()) {
stack.setStackStatus(new StackStatus(stack, status, statusReason, detailedStatus));
if (status.isRemovableStatus()) {
InMemoryStateStore.deleteStack(stackId);
if (stack.getCluster() != null && stack.getCluster().getStatus().isRemovableStatus()) {
InMemoryStateStore.deleteCluster(stack.getCluster().getId());
}
} else {
InMemoryStateStore.putStack(stackId, statusToPollGroupConverter.convert(status));
}
stack = stackRepository.save(stack);
}
return stack;
}
Aggregations