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()));
}
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations