Search in sources :

Example 1 with DistroxStopStartScaleDurationAssertions

use of com.sequenceiq.it.cloudbreak.assertion.distrox.DistroxStopStartScaleDurationAssertions 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();
}
Also used : IntStream(java.util.stream.IntStream) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ITestContext(org.testng.ITestContext) DistroxStopStartScaleDurationAssertions(com.sequenceiq.it.cloudbreak.assertion.distrox.DistroxStopStartScaleDurationAssertions) Test(org.testng.annotations.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) Collectors(java.util.stream.Collectors) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) 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) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) DistroXTestDto(com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) List(java.util.List) AtomicReference(java.util.concurrent.atomic.AtomicReference) DistroxStopStartScaleDurationAssertions(com.sequenceiq.it.cloudbreak.assertion.distrox.DistroxStopStartScaleDurationAssertions) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)

Aggregations

CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 DistroxStopStartScaleDurationAssertions (com.sequenceiq.it.cloudbreak.assertion.distrox.DistroxStopStartScaleDurationAssertions)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 DistroxUtil (com.sequenceiq.it.cloudbreak.util.DistroxUtil)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Inject (javax.inject.Inject)1 ITestContext (org.testng.ITestContext)1 Test (org.testng.annotations.Test)1