Search in sources :

Example 6 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class DistroXRemoveInstancesAction method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    List<String> removableInstanceIds = testDto.getInstanceIdsForAction();
    if (!removableInstanceIds.isEmpty()) {
        MultipleInstanceDeleteRequest instanceDeleteRequest = new MultipleInstanceDeleteRequest();
        instanceDeleteRequest.setInstances(removableInstanceIds);
        Log.when(LOGGER, String.format(" Removing instances [%s] from distrox '%s'... ", instanceDeleteRequest.getInstances(), testDto.getName()));
        FlowIdentifier flowIdentifier = client.getDefaultClient().distroXV1Endpoint().deleteInstancesByCrn(testDto.getCrn(), removableInstanceIds, instanceDeleteRequest, false);
        testDto.setFlow("Instance deletion", flowIdentifier);
        StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), new HashSet<>(Arrays.asList("hardware_info", "events")));
        testDto.setResponse(stackV4Response);
        Log.whenJson(LOGGER, " Distrox remove instances response: ", stackV4Response);
        LOGGER.info(String.format("Hardware info for distrox '%s' after remove instances [%s].", testDto.getName(), stackV4Response.getHardwareInfoGroups()));
        return testDto;
    } else {
        throw new TestFailException(String.format("Cannot find any instance to remove from distrox '%s'!", testDto.getName()));
    }
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) MultipleInstanceDeleteRequest(com.sequenceiq.distrox.api.v1.distrox.model.MultipleInstanceDeleteRequest) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier)

Example 7 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class CheckVariant method action.

@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
    Log.when(LOGGER, " Checking the stack variant, expected: " + variant);
    StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().getByName(testDto.getName(), Collections.emptySet());
    if (!stackV4Response.getVariant().equals(variant)) {
        throw new TestFailException("Variants are mismatched: expected: " + variant + ", got: " + stackV4Response.getVariant());
    }
    Log.when(LOGGER, " Stack variant checked and matched");
    return testDto;
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 8 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method generateServiceKeytab.

private void generateServiceKeytab(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        ServiceKeytabRequest serviceKeytabRequest = new ServiceKeytabRequest();
        serviceKeytabRequest.setEnvironmentCrn(environmentCrn);
        serviceKeytabRequest.setServiceName("test");
        serviceKeytabRequest.setServerHostName("test.local");
        serviceKeytabRequest.setDoNotRecreateKeytab(Boolean.FALSE);
        ipaClient.getKerberosMgmtV1Endpoint().generateServiceKeytab(serviceKeytabRequest, null);
    } catch (Exception e) {
        logger.error("Generate Service keytab test failed during upgrade", e);
        throw new TestFailException("Generate Service keytab test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : ServiceKeytabRequest(com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.ServiceKeytabRequest) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 9 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method syncUsers.

private void syncUsers(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn, String accountId) {
    try {
        SyncOperationStatus lastSyncOperationStatus = ipaClient.getUserV1Endpoint().getLastSyncOperationStatus(environmentCrn);
        if (lastSyncOperationStatus.getStatus() == SynchronizationStatus.RUNNING) {
            waitToCompleted(testContext, lastSyncOperationStatus.getOperationId(), "Initial or periodic usersync");
        }
        SynchronizeAllUsersRequest request = new SynchronizeAllUsersRequest();
        request.setAccountId(accountId);
        request.setEnvironments(Set.of(environmentCrn));
        request.setWorkloadCredentialsUpdateType(WorkloadCredentialsUpdateType.FORCE_UPDATE);
        try {
            SyncOperationStatus syncOperationStatus = ipaClient.getUserV1Endpoint().synchronizeAllUsers(request);
            waitToCompleted(testContext, syncOperationStatus.getOperationId(), "Full forced usersync");
        } catch (WebApplicationException e) {
            if (e.getResponse() != null && Response.Status.CONFLICT.getStatusCode() == e.getResponse().getStatus()) {
                logger.info("Usersync is already running");
            } else {
                throw e;
            }
        }
    } catch (Exception e) {
        logger.error("Full forced usersync test failed during upgrade", e);
        throw new TestFailException("Full forced usersync test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SyncOperationStatus(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SyncOperationStatus) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SynchronizeAllUsersRequest(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SynchronizeAllUsersRequest) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 10 with TestFailException

use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.

the class FreeIpaUpgradeTests method addAndDeleteDnsARecord.

private void addAndDeleteDnsARecord(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
    try {
        AddDnsARecordRequest aRecordRequest = new AddDnsARecordRequest();
        aRecordRequest.setHostname("test-a-record");
        aRecordRequest.setCreateReverse(true);
        aRecordRequest.setEnvironmentCrn(environmentCrn);
        aRecordRequest.setIp("1.2.3.4");
        ipaClient.getDnsV1Endpoint().addDnsARecord(aRecordRequest);
        ipaClient.getDnsV1Endpoint().deleteDnsARecord(environmentCrn, null, aRecordRequest.getHostname());
    } catch (Exception e) {
        logger.error("DNS A record test failed during upgrade", e);
        throw new TestFailException("DNS A record test failed during upgrade with: " + e.getMessage(), e);
    }
}
Also used : AddDnsARecordRequest(com.sequenceiq.freeipa.api.v1.dns.model.AddDnsARecordRequest) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) WebApplicationException(javax.ws.rs.WebApplicationException) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Aggregations

TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)101 List (java.util.List)15 Inject (javax.inject.Inject)14 Map (java.util.Map)13 Description (com.sequenceiq.it.cloudbreak.context.Description)12 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Test (org.testng.annotations.Test)12 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 Log (com.sequenceiq.it.cloudbreak.log.Log)9 String.format (java.lang.String.format)9 Collectors (java.util.stream.Collectors)9 FreeIpaTestDto (com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto)8 SdxTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto)8 IOException (java.io.IOException)8 URISyntaxException (java.net.URISyntaxException)8 ArrayList (java.util.ArrayList)8 Set (java.util.Set)8