Search in sources :

Example 1 with MicroserviceClient

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;
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakInstanceWaitObject(com.sequenceiq.it.cloudbreak.util.wait.service.instance.cloudbreak.CloudbreakInstanceWaitObject) CloudbreakInstanceWaitObject(com.sequenceiq.it.cloudbreak.util.wait.service.instance.cloudbreak.CloudbreakInstanceWaitObject)

Example 2 with MicroserviceClient

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));
        }
    });
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient)

Example 3 with MicroserviceClient

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;
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) RedbeamsClient(com.sequenceiq.it.cloudbreak.RedbeamsClient) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) UmsClient(com.sequenceiq.it.cloudbreak.UmsClient) SdxSaasItClient(com.sequenceiq.it.cloudbreak.SdxSaasItClient)

Example 4 with MicroserviceClient

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;
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)

Example 5 with MicroserviceClient

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());
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) RedbeamsClient(com.sequenceiq.it.cloudbreak.RedbeamsClient) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) UmsClient(com.sequenceiq.it.cloudbreak.UmsClient) SdxSaasItClient(com.sequenceiq.it.cloudbreak.SdxSaasItClient)

Aggregations

MicroserviceClient (com.sequenceiq.it.cloudbreak.MicroserviceClient)5 CloudbreakClient (com.sequenceiq.it.cloudbreak.CloudbreakClient)2 EnvironmentClient (com.sequenceiq.it.cloudbreak.EnvironmentClient)2 FreeIpaClient (com.sequenceiq.it.cloudbreak.FreeIpaClient)2 RedbeamsClient (com.sequenceiq.it.cloudbreak.RedbeamsClient)2 SdxClient (com.sequenceiq.it.cloudbreak.SdxClient)2 SdxSaasItClient (com.sequenceiq.it.cloudbreak.SdxSaasItClient)2 UmsClient (com.sequenceiq.it.cloudbreak.UmsClient)2 CloudbreakTestDto (com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)1 CloudbreakInstanceWaitObject (com.sequenceiq.it.cloudbreak.util.wait.service.instance.cloudbreak.CloudbreakInstanceWaitObject)1