use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot.
@Test
void deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot() {
PollingConfig pollingConfig = getPollingConfig();
EnvironmentView environment = getEnvironmentView();
when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet());
when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name"));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(stackV4Endpoint.list(anyLong(), anyString(), anyBoolean())).thenReturn(new StackViewV4Responses());
underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
verify(stackV4Endpoint).deleteInternal(eq(0L), eq("name"), eq(true), nullable(String.class));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class StackAttachRecipeAction method action.
@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
Log.whenJson(LOGGER, " attach recipe to stack request:\n", testDto.getAttachRecipeV4Request());
AttachRecipeV4Response response = client.getDefaultClient().stackV4Endpoint().attachRecipe(client.getWorkspaceId(), testDto.getAttachRecipeV4Request(), testDto.getName(), testContext.getActingUserCrn().getAccountId());
Log.whenJson(LOGGER, " attach recipe to stack response:\n", response);
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class StackBlueprintRequestAction method action.
@Override
public StackTestDto action(TestContext testContext, StackTestDto testDto, CloudbreakClient client) throws Exception {
Log.whenJson(LOGGER, " Stack get generated blueprint:\n", testDto.getRequest());
GeneratedBlueprintV4Response bp = client.getDefaultClient().stackV4Endpoint().postStackForBlueprint(client.getWorkspaceId(), testDto.getName(), testDto.getRequest(), testContext.getActingUserCrn().getAccountId());
testDto.withGeneratedBlueprint(bp);
Log.whenJson(LOGGER, " get generated blueprint was successfully:\n", testDto.getGeneratedBlueprint());
return testDto;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.StackV4Endpoint in project cloudbreak by hortonworks.
the class CloudbreakUtil method waitForStatuses.
private static WaitResult waitForStatuses(CloudbreakClient cloudbreakClient, Long workspaceId, String stackName, Map<String, String> desiredStatuses, String accountId) {
WaitResult waitResult = WaitResult.SUCCESSFUL;
Map<String, String> currentStatuses = new HashMap<>();
int retryCount = 0;
do {
LOGGER.info("Waiting for status(es) {}, stack id: {}, current status(es) {} ...", desiredStatuses, stackName, currentStatuses);
sleep();
StackV4Endpoint stackV4Endpoint = cloudbreakClient.stackV4Endpoint();
try {
StackStatusV4Response statusResult = stackV4Endpoint.getStatusByName(workspaceId, stackName, accountId);
for (String statusPath : desiredStatuses.keySet()) {
currentStatuses.put(statusPath, statusResult.getStatus().name());
}
} catch (RuntimeException ignore) {
continue;
}
retryCount++;
} while (!checkStatuses(currentStatuses, desiredStatuses) && !checkFailedStatuses(currentStatuses) && retryCount < MAX_RETRY);
LOGGER.info("Status(es) {} for {} are in desired status(es) {}", desiredStatuses.keySet(), stackName, currentStatuses.values());
if (currentStatuses.values().stream().anyMatch(cs -> cs.contains("FAILED")) || checkNotExpectedDelete(currentStatuses, desiredStatuses)) {
waitResult = WaitResult.FAILED;
}
if (retryCount == MAX_RETRY) {
waitResult = WaitResult.TIMEOUT;
}
return waitResult;
}
Aggregations