use of com.sequenceiq.it.cloudbreak.MicroserviceClient in project cloudbreak by hortonworks.
the class InstanceAwait method await.
public <E extends Enum<E>> CloudbreakTestDto await(CloudbreakTestDto entity, Map<List<String>, E> desiredStatuses, TestContext testContext, RunningParameter runningParameter, Duration pollingInterval, int maxRetry) {
if (entity == null) {
throw new RuntimeException("Cloudbreak key has been provided but no result in resource map!");
}
try {
Log.await(LOGGER, String.format("%s for %s", entity.getName(), desiredStatuses));
MicroserviceClient client = testContext.getMicroserviceClient(entity.getClass(), testContext.setActingUser(runningParameter).getAccessKey());
desiredStatuses.forEach((instanceIds, instanceStatus) -> {
InstanceWaitObject instanceWaitObject = client.waitInstancesObject(entity, testContext, instanceIds, instanceStatus);
if (instanceWaitObject.isDeletionCheck()) {
client.<CloudbreakInstanceWaitObject>waiterService().waitObject(new InstanceTerminationChecker<>(), instanceWaitObject, testContext, pollingInterval, maxRetry, 1);
} else if (instanceWaitObject.isFailedCheck()) {
client.<CloudbreakInstanceWaitObject>waiterService().waitObject(new InstanceFailedChecker<>(), instanceWaitObject, testContext, pollingInterval, maxRetry, 1);
} else {
if (runningParameter != null && runningParameter.getTimeoutChecker() != null) {
client.<CloudbreakInstanceWaitObject>waiterService().waitObject(new InstanceOperationChecker<>(), instanceWaitObject, testContext, pollingInterval, runningParameter.getTimeoutChecker(), maxRetry);
} else {
client.<CloudbreakInstanceWaitObject>waiterService().waitObject(new InstanceOperationChecker<>(), instanceWaitObject, testContext, pollingInterval, maxRetry, 1);
}
}
});
} catch (Exception e) {
if (runningParameter.isLogError()) {
LOGGER.error("await [{}] is failed for statuses {}: {}, name: {}", entity, desiredStatuses, ResponseUtil.getErrorMessage(e), entity.getName());
Log.await(null, String.format("[%s] is failed for statuses %s: %s, name: %s", entity, desiredStatuses, ResponseUtil.getErrorMessage(e), entity.getName()));
}
testContext.getExceptionMap().put("await " + entity + " for desired statuses " + desiredStatuses, e);
}
return entity;
}
use of com.sequenceiq.it.cloudbreak.MicroserviceClient in project cloudbreak by hortonworks.
the class PurgeGarbageService method purge.
private <T> void purge(TestContext testContext) {
orderedPurgables().forEach(purgable -> {
MicroserviceClient client = testContext.getMicroserviceClient(purgable.client());
Collection<Object> all = purgable.getAll(client);
all = all.stream().filter(purgable::deletable).collect(Collectors.toList());
LOGGER.info("Purge all {}, count: {}", purgable.getClass().getSimpleName(), all.size());
if (cleanupBeforeStart) {
all.forEach(e -> purgable.delete(testContext, e, client));
} else {
all.forEach(e -> LOGGER.info("Created resource remained in the Database: {}", e));
}
});
}
use of com.sequenceiq.it.cloudbreak.MicroserviceClient in project cloudbreak by hortonworks.
the class TestContext method as.
public TestContext as(CloudbreakUser cloudbreakUser) {
checkShutdown();
LOGGER.info(" Acting user as: \ndisplay name: {} \naccess key: {} \nsecret key: {} \ncrn: {} \nadmin: {} ", cloudbreakUser.getDisplayName(), cloudbreakUser.getAccessKey(), cloudbreakUser.getSecretKey(), cloudbreakUser.getCrn(), cloudbreakUser.getAdmin());
Log.as(LOGGER, cloudbreakUser.toString());
setActingUser(cloudbreakUser);
if (clients.get(cloudbreakUser.getAccessKey()) == null) {
CloudbreakClient cloudbreakClient = CloudbreakClient.createProxyCloudbreakClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
FreeIpaClient freeIpaClient = FreeIpaClient.createProxyFreeIpaClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
EnvironmentClient environmentClient = EnvironmentClient.createProxyEnvironmentClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
SdxClient sdxClient = SdxClient.createProxySdxClient(testParameter, cloudbreakUser);
UmsClient umsClient = UmsClient.createProxyUmsClient(tracer, umsHost);
SdxSaasItClient sdxSaasItClient = SdxSaasItClient.createProxySdxSaasClient(tracer, umsHost, regionAwareInternalCrnGeneratorFactory);
RedbeamsClient redbeamsClient = RedbeamsClient.createProxyRedbeamsClient(testParameter, cloudbreakUser);
Map<Class<? extends MicroserviceClient>, MicroserviceClient> clientMap = Map.of(CloudbreakClient.class, cloudbreakClient, FreeIpaClient.class, freeIpaClient, EnvironmentClient.class, environmentClient, SdxClient.class, sdxClient, RedbeamsClient.class, redbeamsClient, UmsClient.class, umsClient, SdxSaasItClient.class, sdxSaasItClient);
clients.put(cloudbreakUser.getAccessKey(), clientMap);
cloudbreakClient.setWorkspaceId(0L);
}
return this;
}
use of com.sequenceiq.it.cloudbreak.MicroserviceClient in project cloudbreak by hortonworks.
the class TestContext method awaitForFlow.
public <T extends CloudbreakTestDto> T awaitForFlow(T entity, RunningParameter runningParameter) {
checkShutdown();
String key = getKeyForAwait(entity, entity.getClass(), runningParameter);
if (StringUtils.isBlank(key)) {
key = entity.getClass().getSimpleName();
}
CloudbreakTestDto awaitEntity = get(key);
if (awaitEntity == null) {
awaitEntity = entity;
}
if (!getExceptionMap().isEmpty() && runningParameter.isSkipOnFail()) {
Log.await(LOGGER, "Cloudbreak await for flow should be skipped because of previous error.");
} else {
LOGGER.info(String.format(" Cloudbreak await for flow on resource: %s at account: %s - for entity: %s ", awaitEntity.getCrn(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId(), awaitEntity));
Log.await(LOGGER, String.format(" Cloudbreak await for flow on resource: %s at account: %s - for entity: %s ", awaitEntity.getCrn(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId(), awaitEntity));
MicroserviceClient msClient = getAdminMicroserviceClient(awaitEntity.getClass(), Objects.requireNonNull(Crn.fromString(awaitEntity.getCrn())).getAccountId());
flowUtilSingleStatus.waitBasedOnLastKnownFlow(awaitEntity, msClient, getTestContext(), runningParameter);
}
entity.setLastKnownFlowId(null);
return entity;
}
use of com.sequenceiq.it.cloudbreak.MicroserviceClient in project cloudbreak by hortonworks.
the class TestContext method initMicroserviceClientsForUMSAccountAdmin.
private void initMicroserviceClientsForUMSAccountAdmin(CloudbreakUser accountAdmin) {
if (clients.get(accountAdmin.getAccessKey()) == null) {
CloudbreakClient cloudbreakClient = CloudbreakClient.createProxyCloudbreakClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
FreeIpaClient freeIpaClient = FreeIpaClient.createProxyFreeIpaClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
EnvironmentClient environmentClient = EnvironmentClient.createProxyEnvironmentClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
SdxClient sdxClient = SdxClient.createProxySdxClient(testParameter, accountAdmin);
UmsClient umsClient = UmsClient.createProxyUmsClient(tracer, umsHost);
SdxSaasItClient sdxSaasItClient = SdxSaasItClient.createProxySdxSaasClient(tracer, umsHost, regionAwareInternalCrnGeneratorFactory);
RedbeamsClient redbeamsClient = RedbeamsClient.createProxyRedbeamsClient(testParameter, accountAdmin);
Map<Class<? extends MicroserviceClient>, MicroserviceClient> clientMap = Map.of(CloudbreakClient.class, cloudbreakClient, FreeIpaClient.class, freeIpaClient, EnvironmentClient.class, environmentClient, SdxClient.class, sdxClient, RedbeamsClient.class, redbeamsClient, UmsClient.class, umsClient, SdxSaasItClient.class, sdxSaasItClient);
clients.put(accountAdmin.getAccessKey(), clientMap);
}
LOGGER.info(" Microservice clients have been initialized successfully for UMS account admin:: \nDisplay name: {} \nAccess key: {} \nSecret key: {} " + "\nCrn: {} ", accountAdmin.getDisplayName(), accountAdmin.getAccessKey(), accountAdmin.getSecretKey(), accountAdmin.getCrn());
}
Aggregations