Search in sources :

Example 1 with CloudFunctionality

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));
    }
}
Also used : AwsCloudProvider(com.sequenceiq.it.cloudbreak.cloud.v4.aws.AwsCloudProvider) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) StringUtils(org.apache.commons.lang3.StringUtils) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DistroXInstanceGroupsBuilder(com.sequenceiq.it.cloudbreak.dto.distrox.instancegroup.DistroXInstanceGroupsBuilder) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) Tunnel(com.sequenceiq.common.api.type.Tunnel) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) OperationState(com.sequenceiq.freeipa.api.v1.operation.model.OperationState) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) String.format(java.lang.String.format) List(java.util.List) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) DistroXExternalDatabaseAssertion.validateTemplateContainsExternalDatabaseHostname(com.sequenceiq.it.cloudbreak.assertion.distrox.DistroXExternalDatabaseAssertion.validateTemplateContainsExternalDatabaseHostname) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) FreeIpaUserSyncTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaUserSyncTestDto) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) TelemetryTestDto(com.sequenceiq.it.cloudbreak.dto.telemetry.TelemetryTestDto) DistroXDatabaseAvailabilityType(com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseAvailabilityType) AzureCloudFunctionality(com.sequenceiq.it.cloudbreak.util.azure.AzureCloudFunctionality) HashMap(java.util.HashMap) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) AzureCloudProvider(com.sequenceiq.it.cloudbreak.cloud.v4.azure.AzureCloudProvider) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) ResourceGroupTest(com.sequenceiq.it.cloudbreak.ResourceGroupTest) DistroXInstanceGroupTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.instancegroup.DistroXInstanceGroupTestDto) AwsAvailabilityZoneAssertion(com.sequenceiq.it.cloudbreak.assertion.distrox.AwsAvailabilityZoneAssertion) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) Log(com.sequenceiq.it.cloudbreak.log.Log) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) SshEnaDriverCheckActions(com.sequenceiq.it.cloudbreak.util.ssh.action.SshEnaDriverCheckActions) FreeIpaInstanceUtil(com.sequenceiq.it.cloudbreak.util.FreeIpaInstanceUtil) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) EnvironmentTestClient(com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DistroxUtil(com.sequenceiq.it.cloudbreak.util.DistroxUtil) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) DistroXDatabaseRequest(com.sequenceiq.distrox.api.v1.distrox.model.database.DistroXDatabaseRequest) ArrayList(java.util.ArrayList) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with CloudFunctionality

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;
}
Also used : EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) AzureCloudFunctionality(com.sequenceiq.it.cloudbreak.util.azure.AzureCloudFunctionality)

Example 3 with CloudFunctionality

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();
}
Also used : DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)

Example 4 with CloudFunctionality

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;
}
Also used : CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)

Example 5 with CloudFunctionality

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();
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) DistroXInstanceGroupsBuilder(com.sequenceiq.it.cloudbreak.dto.distrox.instancegroup.DistroXInstanceGroupsBuilder) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ClouderaManagerUtil(com.sequenceiq.it.cloudbreak.util.clouderamanager.ClouderaManagerUtil) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) SanitizerUtil(com.sequenceiq.cloudbreak.util.SanitizerUtil) List(java.util.List) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) DistroxUtil(com.sequenceiq.it.cloudbreak.util.DistroxUtil) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) VolumeUtils(com.sequenceiq.it.cloudbreak.util.VolumeUtils) HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DistroXInstanceGroupsBuilder(com.sequenceiq.it.cloudbreak.dto.distrox.instancegroup.DistroXInstanceGroupsBuilder) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)

Aggregations

CloudFunctionality (com.sequenceiq.it.cloudbreak.util.CloudFunctionality)16 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)7 Description (com.sequenceiq.it.cloudbreak.context.Description)7 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)7 AbstractE2ETest (com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)7 Test (org.testng.annotations.Test)7 DistroXTestClient (com.sequenceiq.it.cloudbreak.client.DistroXTestClient)6 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)6 List (java.util.List)6 Inject (javax.inject.Inject)6 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)5 DistroxUtil (com.sequenceiq.it.cloudbreak.util.DistroxUtil)5 UseSpotInstances (com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)5 ArrayList (java.util.ArrayList)5 MASTER (com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER)4 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)4 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)4 AzureCloudFunctionality (com.sequenceiq.it.cloudbreak.util.azure.AzureCloudFunctionality)4 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)3 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)3