Search in sources :

Example 1 with DELETED_ON_PROVIDER_SIDE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.DELETED_ON_PROVIDER_SIDE 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());
}
Also used : IntStream(java.util.stream.IntStream) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ITestContext(org.testng.ITestContext) Test(org.testng.annotations.Test) DELETED_ON_PROVIDER_SIDE(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.DELETED_ON_PROVIDER_SIDE) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) List(java.util.List) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) DistroxUtil(com.sequenceiq.it.cloudbreak.util.DistroxUtil) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) Optional(java.util.Optional) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) Optional(java.util.Optional) CloudFunctionality(com.sequenceiq.it.cloudbreak.util.CloudFunctionality) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)

Aggregations

DELETED_ON_PROVIDER_SIDE (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.DELETED_ON_PROVIDER_SIDE)1 DistroXTestClient (com.sequenceiq.it.cloudbreak.client.DistroXTestClient)1 Description (com.sequenceiq.it.cloudbreak.context.Description)1 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)1 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 AbstractE2ETest (com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)1 CloudFunctionality (com.sequenceiq.it.cloudbreak.util.CloudFunctionality)1 DistroxUtil (com.sequenceiq.it.cloudbreak.util.DistroxUtil)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 IntStream (java.util.stream.IntStream)1 Inject (javax.inject.Inject)1 ITestContext (org.testng.ITestContext)1 Test (org.testng.annotations.Test)1