use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class SdxCloudStorageTest method testSDXWithDataLakeAndFreeIpaStorageCanBeCreatedSuccessfully.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak", when = "a basic SDX create request with FreeIPA and DataLake Cloud Storage has been sent", then = "SDX should be available along with the created Cloud storage objects")
public void testSDXWithDataLakeAndFreeIpaStorageCanBeCreatedSuccessfully(TestContext testContext) {
String sdx = resourcePropertyProvider().getName();
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
DescribeFreeIpaResponse describeFreeIpaResponse = testContext.given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).getResponse();
testContext.given(sdx, SdxTestDto.class).withCloudStorage().withExternalDatabase(sdxDatabaseRequest).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, testDto, client) -> {
getCloudFunctionality(tc).cloudStorageListContainerDataLake(getBaseLocation(testDto), testDto.getResponse().getName(), testDto.getResponse().getStackCrn());
return testDto;
}).then((tc, testDto, client) -> {
getCloudFunctionality(tc).cloudStorageListContainerFreeIpa(getBaseLocation(testDto), describeFreeIpaResponse.getName(), describeFreeIpaResponse.getCrn());
return testDto;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class SdxImagesTests method testSDXWithBaseImageCanBeCreatedSuccessfully.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak", when = "a valid SDX create request is sent (latest Base Image)", then = "SDX should be available AND deletable")
public void testSDXWithBaseImageCanBeCreatedSuccessfully(TestContext testContext) {
String sdxInternal = resourcePropertyProvider().getName();
String cluster = resourcePropertyProvider().getName();
String clouderaManager = resourcePropertyProvider().getName();
String imageSettings = resourcePropertyProvider().getName();
String imageCatalog = resourcePropertyProvider().getName();
String stack = resourcePropertyProvider().getName();
String masterInstanceGroup = "master";
String idbrokerInstanceGroup = "idbroker";
AtomicReference<String> selectedImageID = new AtomicReference<>();
SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
testContext.given(imageCatalog, ImageCatalogTestDto.class).when((tc, dto, client) -> {
selectedImageID.set(testContext.getCloudProvider().getLatestBaseImageID(tc, dto, client));
return dto;
}).given(imageSettings, ImageSettingsTestDto.class).given(clouderaManager, ClouderaManagerTestDto.class).given(cluster, ClusterTestDto.class).withBlueprintName(getDefaultSDXBlueprintName()).withValidateBlueprint(Boolean.FALSE).withClouderaManager(clouderaManager).given(masterInstanceGroup, InstanceGroupTestDto.class).withHostGroup(MASTER).withNodeCount(1).given(idbrokerInstanceGroup, InstanceGroupTestDto.class).withHostGroup(IDBROKER).withNodeCount(1).given(stack, StackTestDto.class).withCluster(cluster).withImageSettings(imageSettings).withInstanceGroups(masterInstanceGroup, idbrokerInstanceGroup).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withStackRequest(key(cluster), key(stack)).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, dto, client) -> {
Log.log(LOGGER, format(" Image Catalog Name: %s ", dto.getResponse().getStackV4Response().getImage().getCatalogName()));
Log.log(LOGGER, format(" Image Catalog URL: %s ", dto.getResponse().getStackV4Response().getImage().getCatalogUrl()));
Log.log(LOGGER, format(" Image ID: %s ", dto.getResponse().getStackV4Response().getImage().getId()));
if (!dto.getResponse().getStackV4Response().getImage().getId().equals(selectedImageID.get())) {
throw new TestFailException(" The selected image ID is: " + dto.getResponse().getStackV4Response().getImage().getId() + " instead of: " + selectedImageID.get());
}
return dto;
}).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class SdxSecurityTests method testSDXAutoTlsCertRotation.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "autotls cert rotation is called on the SDX cluster", then = "host certificates' validity should be changed on all hosts, the cluster should be up and running")
public void testSDXAutoTlsCertRotation(TestContext testContext) {
String sdx = resourcePropertyProvider().getName();
List<String> originalCertValidityOutput = new ArrayList<>();
List<String> renewedCertValidityOutput = new ArrayList<>();
SdxDatabaseRequest noDatabaseRequest = new SdxDatabaseRequest();
noDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
testContext.given(sdx, SdxTestDto.class).withCloudStorage().withExternalDatabase(noDatabaseRequest).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, testDto, client) -> {
Map<String, Pair<Integer, String>> certValidityCmdResultByIpsMap = sshJClientActions.executeSshCommandOnHost(getInstanceGroups(testDto, client), List.of(HostGroupType.MASTER.getName(), HostGroupType.IDBROKER.getName()), HOST_CERT_VALIDITY_CMD, false);
originalCertValidityOutput.addAll(certValidityCmdResultByIpsMap.values().stream().map(Pair::getValue).collect(Collectors.toList()));
return testDto;
}).when(sdxTestClient.rotateAutotlsCertificates(), key(sdx)).await(SdxClusterStatusResponse.CERT_ROTATION_IN_PROGRESS, key(sdx).withWaitForFlow(false)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, testDto, client) -> {
Map<String, Pair<Integer, String>> certValidityCmdResultByIpsMap = sshJClientActions.executeSshCommandOnHost(getInstanceGroups(testDto, client), List.of(HostGroupType.MASTER.getName(), HostGroupType.IDBROKER.getName()), HOST_CERT_VALIDITY_CMD, false);
renewedCertValidityOutput.addAll(certValidityCmdResultByIpsMap.entrySet().stream().map(e -> e.getValue().getValue()).collect(Collectors.toList()));
return testDto;
}).then((tc, testDto, client) -> compareCertValidityOutputs(testDto, originalCertValidityOutput, renewedCertValidityOutput)).validate();
}
use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.
the class MultiThreadTenantTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(MockedTestContext 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 ClusterTemplateTest method validateDefaultCount.
private ClusterTemplateTestDto validateDefaultCount(TestContext tc, ClusterTemplateTestDto entity, CloudbreakClient cc) {
try {
assertNotNull(entity);
assertNotNull(entity.getResponses());
long defaultCount = entity.getResponses().stream().filter(template -> ResourceStatus.DEFAULT.equals(template.getStatus())).count();
long expectedCount = 602;
assertEquals("Should have " + expectedCount + " of default cluster templates.", expectedCount, defaultCount);
} catch (Exception e) {
throw new TestFailException(String.format("Failed to validate default count of cluster templates: %s", e.getMessage()), e);
}
return entity;
}
Aggregations