use of com.sequenceiq.it.cloudbreak.util.CloudFunctionality in project cloudbreak by hortonworks.
the class DistroXEncryptedVolumeTest method verifyVolumeEncryptionKey.
private void verifyVolumeEncryptionKey(CloudPlatform cloudPlatform, String resourceName, List<String> instanceIds, CloudFunctionality cloudFunctionality, String environmentName, String resourceGroupName) {
if (CloudPlatform.AWS.equals(cloudPlatform)) {
String kmsKeyArn = awsCloudProvider.getEncryptionKeyArn(true);
List<String> volumeKmsKeyIds = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, null, instanceIds));
if (volumeKmsKeyIds.stream().noneMatch(keyId -> keyId.equalsIgnoreCase(kmsKeyArn))) {
LOGGER.error(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
throw new TestFailException(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
} else {
LOGGER.info(format("Volume has been encrypted with '%s' KMS key.", kmsKeyArn));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' KMS key. ", kmsKeyArn));
}
} else if (CloudPlatform.AZURE.equals(cloudPlatform)) {
String desKeyUrl = azureCloudProvider.getEncryptionKeyUrl();
List<String> volumesDesId = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, resourceGroupName, instanceIds));
volumesDesId.forEach(desId -> {
if (desId.contains("diskEncryptionSets/" + environmentName)) {
LOGGER.info(format("Volume has been encrypted with '%s' DES key.", desId));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' DES key. ", desId));
} else {
LOGGER.error(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
throw new TestFailException(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
}
});
} else {
LOGGER.warn(format("Disk encryption feature is not available at '%s' currently!", cloudPlatform));
}
}
use of com.sequenceiq.it.cloudbreak.util.CloudFunctionality in project cloudbreak by hortonworks.
the class DistroXEncryptedVolumeTest method verifyFreeIpaVolumeEncryptionKey.
private FreeIpaTestDto verifyFreeIpaVolumeEncryptionKey(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient freeIpaClient, String resourceGroupName) {
CloudFunctionality cloudFunctionality = testContext.getCloudProvider().getCloudFunctionality();
List<String> instanceIds = freeIpaInstanceUtil.getInstanceIds(testDto, freeIpaClient, MASTER.getName());
verifyVolumeEncryptionKey(testDto.getCloudPlatform(), testDto.getName(), instanceIds, cloudFunctionality, testContext.given(EnvironmentTestDto.class).getRequest().getName(), resourceGroupName);
return testDto;
}
use of com.sequenceiq.it.cloudbreak.util.CloudFunctionality in project cloudbreak by hortonworks.
the class DistroXScaleEdgeCasesTest method testCreateDistroxAndRemoveLostNode.
@Test(dataProvider = TEST_CONTEXT)
@Description(given = "a running environment", when = "a valid DistroX create request is sent and one random worker node removed from provider", then = "lost node should be removable from cluster")
public void testCreateDistroxAndRemoveLostNode(TestContext testContext) {
testContext.given(DistroXTestDto.class).when(distroXTestClient.create()).await(STACK_AVAILABLE).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instancesToDelete = distroxUtil.getInstanceIds(testDto, client, WORKER.getName()).stream().limit(1).collect(Collectors.toList());
cloudFunctionality.deleteInstances(testDto.getName(), instancesToDelete);
testDto.setInstanceIdsForActions(List.of(instancesToDelete.iterator().next()));
return testDto;
}).awaitForActionedInstances(DELETED_ON_PROVIDER_SIDE).when(distroXTestClient.removeInstances()).awaitForFlow().validate();
}
use of com.sequenceiq.it.cloudbreak.util.CloudFunctionality in project cloudbreak by hortonworks.
the class DistroXRepairTests method verifyMountedDisks.
private DistroXTestDto verifyMountedDisks(TestContext testContext, DistroXTestDto testDto, CloudbreakClient cloudbreakClient) {
CloudFunctionality cloudFunctionality = testContext.getCloudProvider().getCloudFunctionality();
List<InstanceGroupV4Response> instanceGroups = testDto.getResponse().getInstanceGroups();
cloudFunctionality.checkMountedDisks(instanceGroups, List.of(HostGroupType.WORKER.getName()));
return testDto;
}
use of com.sequenceiq.it.cloudbreak.util.CloudFunctionality in project cloudbreak by hortonworks.
the class DistroXRepairTests method testEphemeralDistroXMasterRepairWithTerminatedEC2Instances.
@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak, and an environment with SDX and DistroX cluster in available state", when = "recovery called on the MASTER host group of DistroX cluster, where the EC2 instance had been terminated", then = "DistroX recovery should be successful, the cluster should be up and running")
public void testEphemeralDistroXMasterRepairWithTerminatedEC2Instances(TestContext testContext) {
String distrox = resourcePropertyProvider().getName();
List<String> actualVolumeIds = new ArrayList<>();
List<String> expectedVolumeIds = new ArrayList<>();
String username = testContext.getActingUserCrn().getResource();
String sanitizedUserName = SanitizerUtil.sanitizeWorkloadUsername(username);
testContext.given(distrox, DistroXTestDto.class).withInstanceGroupsEntity(new DistroXInstanceGroupsBuilder(testContext).defaultHostGroup().withStorageOptimizedInstancetype().build()).when(distroXTestClient.create(), key(distrox)).await(STACK_AVAILABLE).awaitForHealthyInstances().then(this::verifyMountedDisks).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instancesToDelete = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
expectedVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instancesToDelete));
cloudFunctionality.deleteInstances(testDto.getName(), instancesToDelete);
return testDto;
}).awaitForHostGroup(MASTER.getName(), InstanceStatus.DELETED_ON_PROVIDER_SIDE).when(distroXTestClient.repair(MASTER), key(distrox)).await(STACK_AVAILABLE, key(distrox)).awaitForHealthyInstances().then(this::verifyMountedDisks).then((tc, testDto, client) -> clouderaManagerUtil.checkClouderaManagerYarnNodemanagerRoleConfigGroups(testDto, sanitizedUserName, MOCK_UMS_PASSWORD)).then((tc, testDto, client) -> {
CloudFunctionality cloudFunctionality = tc.getCloudProvider().getCloudFunctionality();
List<String> instanceIds = distroxUtil.getInstanceIds(testDto, client, MASTER.getName());
actualVolumeIds.addAll(cloudFunctionality.listInstanceVolumeIds(testDto.getName(), instanceIds));
return testDto;
}).then((tc, testDto, client) -> VolumeUtils.compareVolumeIdsAfterRepair(testDto, actualVolumeIds, expectedVolumeIds)).validate();
}
Aggregations