use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method createBindUser.
private void createBindUser(TestContext testContext, com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
BindUserCreateRequest bindUserCreateRequest = new BindUserCreateRequest();
bindUserCreateRequest.setEnvironmentCrn(environmentCrn);
bindUserCreateRequest.setBindUserNameSuffix("testuser");
String initiatorUserCrn = "__internal__actor__";
OperationStatus operationStatus = ipaClient.getFreeIpaV1Endpoint().createE2ETestBindUser(bindUserCreateRequest, initiatorUserCrn);
waitToCompleted(testContext, operationStatus.getOperationId(), "createBindUserOperation");
} catch (Exception e) {
logger.error("CREATE BIND USER test failed during upgrade", e);
throw new TestFailException("CREATE BIND USER 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 addAndDeleteDnsCnameRecord.
private void addAndDeleteDnsCnameRecord(com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient, String environmentCrn) {
try {
AddDnsCnameRecordRequest request = new AddDnsCnameRecordRequest();
request.setCname("test-cname-record");
request.setTargetFqdn("cloudera.com");
request.setEnvironmentCrn(environmentCrn);
ipaClient.getDnsV1Endpoint().addDnsCnameRecord(request);
ipaClient.getDnsV1Endpoint().deleteDnsCnameRecord(environmentCrn, null, request.getCname());
} catch (Exception e) {
logger.error("DNS CNAME record test failed during upgrade", e);
throw new TestFailException("DNS CNAME record 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 testFreeIpaAvailabilityDuringUpgrade.
private FreeIpaOperationStatusTestDto testFreeIpaAvailabilityDuringUpgrade(TestContext testContext, FreeIpaOperationStatusTestDto testDto, FreeIpaClient freeIpaClient, String freeIpa) {
try {
com.sequenceiq.freeipa.api.client.FreeIpaClient ipaClient = freeIpaClient.getDefaultClient();
FreeIpaTestDto freeIpaTestDto = testContext.get(freeIpa);
String environmentCrn = freeIpaTestDto.getResponse().getEnvironmentCrn();
String accountId = Crn.safeFromString(environmentCrn).getAccountId();
boolean firstTestFailure = true;
while (ipaClient.getOperationV1Endpoint().getOperationStatus(testDto.getOperationId(), accountId).getStatus() == RUNNING) {
try {
addAndDeleteDnsARecord(ipaClient, environmentCrn);
addAndDeleteDnsCnameRecord(ipaClient, environmentCrn);
addListDeleteDnsZonesBySubnet(ipaClient, environmentCrn);
createBindUser(testContext, ipaClient, environmentCrn);
generateHostKeyTab(ipaClient, environmentCrn);
generateServiceKeytab(ipaClient, environmentCrn);
dnsLookups(testContext.given(SdxTestDto.class), testContext.getSdxClient());
cleanUp(testContext, ipaClient, environmentCrn);
kinit(testContext.given(SdxTestDto.class), testContext.getSdxClient(), ipaClient, environmentCrn);
syncUsers(testContext, ipaClient, environmentCrn, accountId);
} catch (TestFailException e) {
if (firstTestFailure) {
logger.info("First test failure is ignored until CB-15454 is fixed");
firstTestFailure = false;
} else {
throw e;
}
}
}
} catch (TestFailException e) {
throw e;
} catch (Exception e) {
logger.error("Unexpected error during FreeIPA upgrade availability test", e);
throw new TestFailException("Unexpected error during FreeIPA upgrade availability test: " + e.getMessage(), e);
}
return testDto;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class FreeIpaUpgradeTests method dnsLookups.
private void dnsLookups(SdxTestDto sdxTestDto, SdxClient sdxClient) {
InstanceMetaDataV4Response instanceGroupMetadata = getInstanceGroups(sdxTestDto, sdxClient).stream().flatMap(instanceGroup -> instanceGroup.getMetadata().stream()).filter(metadata -> metadata.getInstanceGroup().equals("idbroker")).filter(metadata -> StringUtils.isNoneBlank(metadata.getDiscoveryFQDN(), metadata.getPrivateIp())).findFirst().orElseThrow(() -> new TestFailException("FreeIPA upgrade DNS lookups test failed, idbroker instance group was not found."));
try {
String cmd = String.format(CHECK_DNS_LOOKUPS_CMD, instanceGroupMetadata.getDiscoveryFQDN(), instanceGroupMetadata.getPrivateIp());
Map<String, Pair<Integer, String>> results = sshJClientActions.executeSshCommandOnHost(getInstanceGroups(sdxTestDto, sdxClient), List.of(HostGroupType.MASTER.getName()), cmd, false);
results.values().forEach(result -> Assertions.assertEquals(0, result.getLeft()));
} catch (Exception e) {
logger.error("FreeIPA upgrade DNS lookups test failed with unexpected error", e);
throw new TestFailException("FreeIPA upgrade DNS lookups test failed with unexpected error: " + e.getMessage(), e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class DistroXScaleTest method testCreateAndScaleDistroX.
@Test(dataProvider = TEST_CONTEXT, description = "Resilient Scaling: " + "UseCase1: " + "- Start upscale on running cluster " + "- Delete a non CM server host from provider other hostgroup during upscale " + "- Upscale should complete ")
@Description(given = "there is a running default Distrox cluster", when = "deleted a Compute instance while cluster was upscaling (by Worker nodes)", then = "cluster can be resiliently scaled up then down with higher node count")
public void testCreateAndScaleDistroX(TestContext testContext, ITestContext iTestContext) {
DistroXScaleTestParameters params = new DistroXScaleTestParameters(iTestContext.getCurrentXmlTest().getAllParameters());
if (params.getTimes() < 1) {
throw new TestFailException("Test should execute at least 1 round of scaling");
}
StringBuilder instanceToStopId = new StringBuilder();
testContext.given(DistroXTestDto.class).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
Optional<String> anInstanceToStop = distroxUtil.getInstanceIds(testDto, client, params.getHostGroup()).stream().findFirst();
if (anInstanceToStop.isEmpty()) {
throw new TestFailException(String.format("At least 1 instance needed from group %s to test stop it and test targeted upscale.", params.getIrrelevantHostGroup()));
}
cloudFunctionality.stopInstances(testDto.getName(), List.of(anInstanceToStop.get()));
instanceToStopId.append(anInstanceToStop.get());
return testDto;
}).await(STACK_NODE_FAILURE).when(distroXTestClient.scale(params.getHostGroup(), params.getScaleUpTarget())).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
Optional<String> anInstanceToDelete = distroxUtil.getInstanceIds(testDto, client, params.getIrrelevantHostGroup()).stream().findFirst();
if (anInstanceToDelete.isEmpty()) {
throw new TestFailException(String.format("At least 1 instance needed from group %s to test delete it and test targeted upscale.", params.getIrrelevantHostGroup()));
}
cloudFunctionality.deleteInstances(testDto.getName(), List.of(anInstanceToDelete.get()));
testDto.setInstanceIdsForActions(List.of(anInstanceToDelete.get()));
return testDto;
}).awaitForFlow().awaitForActionedInstances(DELETED_ON_PROVIDER_SIDE).then((tc, testDto, client) -> {
testDto.setInstanceIdsForActions(mergeInstanceIdList(testDto.getInstanceIdsForAction(), instanceToStopId.toString()));
return testDto;
}).when(distroXTestClient.removeInstances()).awaitForFlow().when(distroXTestClient.scale(params.getHostGroup(), params.getScaleDownTarget())).awaitForFlow().validate();
IntStream.range(1, params.getTimes()).forEach(i -> testContext.given(DistroXTestDto.class).when(distroXTestClient.scale(params.getHostGroup(), params.getScaleUpTarget())).awaitForFlow().when(distroXTestClient.scale(params.getHostGroup(), params.getScaleDownTarget())).awaitForFlow().validate());
}
Aggregations