use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class EnvironmentEditTest method authenticationEditWhenSetManagedKeyAndNotDeleteExisted.
@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running cloudbreak with existed ssh key", when = "change existing ssh key to managed one", then = "delete managed ssh key but not create new one")
public void authenticationEditWhenSetManagedKeyAndNotDeleteExisted(MockedTestContext testContext) {
String randomPublicKeyId = UUID.randomUUID().toString();
testContext.given(EnvironmentAuthenticationTestDto.class).withPublicKeyId(randomPublicKeyId).withPublicKey(null).given(EnvironmentTestDto.class).withCreateFreeIpa(false).when(environmentTestClient.create()).await(EnvironmentStatus.AVAILABLE).given(EnvironmentAuthenticationTestDto.class).withPublicKey(PUBLIC_KEY).withPublicKeyId(null).given(EnvironmentTestDto.class).when(environmentTestClient.changeAuthentication()).when(environmentTestClient.describe()).then((tc, t, c) -> {
String publicKeyId = t.getResponse().getAuthentication().getPublicKeyId();
String publicKey = t.getResponse().getAuthentication().getPublicKey();
if (randomPublicKeyId.equals(publicKeyId)) {
throw new TestFailException("The auth public key id was not changed, but it should be changed");
}
if (publicKey == null) {
throw new TestFailException("The auth public key should not be null");
}
return t;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class AbstractMinimalTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(TestContext testContext, Method method, Object[] params) {
Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
TestCaseDescription testCaseDescription = null;
if (declaredAnnotation != null) {
testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
testContext.addDescription(testCaseDescription);
} else if (method.getParameters().length == params.length) {
Parameter[] parameters = method.getParameters();
for (int i = 1; i < parameters.length; i++) {
if (parameters[i].getAnnotation(Description.class) != null) {
Object param = params[i];
if (!(param instanceof TestCaseDescription)) {
throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
}
testCaseDescription = (TestCaseDescription) param;
testContext.addDescription(testCaseDescription);
break;
}
}
}
return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class AbstractImageValidatorE2ETest method validateImageIdAndWriteToFile.
@AfterMethod
public void validateImageIdAndWriteToFile(Object[] data, ITestResult result) {
TestContext testContext = (TestContext) data[0];
if (result.getStatus() == ITestResult.SUCCESS) {
String expectedImageUuid = commonCloudProperties().getImageValidation().getImageUuid();
String actualImageUuid = getImageId(testContext);
if (Strings.isNotNullAndNotEmpty(expectedImageUuid) && !expectedImageUuid.equalsIgnoreCase(actualImageUuid)) {
throw new RuntimeException("The test was successful but the image is not the expected one. Actual: " + actualImageUuid + " Expected: " + expectedImageUuid);
}
LOG.info("The test was successful with this image: " + actualImageUuid);
writeImageIdToFile(testContext);
}
}
use of com.sequenceiq.it.cloudbreak.context.TestContext 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());
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class DistroXStopStartScaleTest method testStopStartScaleDistroX.
/**
* The "Scaling" via Instance Stop/Start for DataHub ‘compute’ nodes (NodeManagers only) improves scaling performance
* - at best, 4-6 minutes for a single node.
*
* @param testContext Spring offers ApplicationContextAware interface to provide configuration of the Integration Test ApplicationContext.
* @param iTestContext TestNG offers the ITestContext interface to store and share test objects through test execution.
*/
@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running default Distrox cluster", when = "cluster has been scaled successfully by 4 compute nodes", then = "cluster compute nodes can be scaled down then up via stop then start instances at provider")
public void testStopStartScaleDistroX(TestContext testContext, ITestContext iTestContext) {
AtomicReference<List<String>> instancesToStop = new AtomicReference<>();
DistroXScaleTestParameters params = new DistroXScaleTestParameters(iTestContext.getCurrentXmlTest().getAllParameters());
if (params.getTimes() < 1) {
throw new TestFailException("Test should execute at least 1 round of scaling");
}
testContext.given(DistroXTestDto.class).when(distroXTestClient.scale(params.getHostGroup(), params.getScaleUpTarget())).awaitForFlow().then((tc, testDto, client) -> {
instancesToStop.set(distroxUtil.getInstanceIds(testDto, client, params.getHostGroup()).stream().limit(params.getScaleDownTarget()).collect(Collectors.toList()));
testDto.setInstanceIdsForActions(instancesToStop.get());
return testDto;
}).when(distroXTestClient.scaleStopInstances()).awaitForFlow().then(new DistroxStopStartScaleDurationAssertions(6, false)).when(distroXTestClient.scaleStartInstances(params.getHostGroup(), params.getScaleUpTarget())).awaitForFlow().when(distroXTestClient.get()).then(new DistroxStopStartScaleDurationAssertions(6, true));
IntStream.range(1, params.getTimes()).forEach(i -> {
testContext.given(DistroXTestDto.class).when(distroXTestClient.scaleStopInstances()).awaitForFlow().then(new DistroxStopStartScaleDurationAssertions(6, false)).when(distroXTestClient.scaleStartInstances(params.getHostGroup(), params.getScaleUpTarget())).awaitForFlow().when(distroXTestClient.get()).then(new DistroxStopStartScaleDurationAssertions(6, true));
});
testContext.given(DistroXTestDto.class).validate();
}
Aggregations