Search in sources :

Example 31 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class MockSdxRepairTests method repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "there is a running Cloudbreak", when = "terminate instances and repair an sdx cluster", then = "repair should fail and repaired instance should be in deleted on provider side")
public void repairTerminatedMasterAndItFailedButInstanceShouldBeDeletedOnProviderSide(MockedTestContext testContext) {
    String sdxInternal = resourcePropertyProvider().getName();
    String networkKey = "someOtherNetwork";
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NON_HA);
    CustomDomainSettingsV4Request customDomain = new CustomDomainSettingsV4Request();
    customDomain.setDomainName("dummydomainname");
    customDomain.setHostname("dummyhostname");
    customDomain.setClusterNameAsSubdomain(true);
    customDomain.setHostgroupNameAsHostname(true);
    testContext.given(networkKey, EnvironmentNetworkTestDto.class).withMock(new EnvironmentNetworkMockParams()).given(EnvironmentTestDto.class).withNetwork(networkKey).withCreateFreeIpa(Boolean.TRUE).withName(resourcePropertyProvider().getEnvironmentName()).when(getEnvironmentTestClient().create()).await(EnvironmentStatus.AVAILABLE).given(FreeIpaTestDto.class).when(freeIpaTestClient.create()).await(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE).given(sdxInternal, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCustomDomain(customDomain).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).then((tc, testDto, client) -> {
        List<String> instancesToDelete = new ArrayList<>(sdxUtil.getInstanceIds(testDto, client, MASTER.getName()));
        instancesToDelete.forEach(instanceId -> getExecuteQueryToMockInfrastructure().call("/" + testDto.getCrn() + "/spi/" + instanceId + "/terminate", w -> w));
        getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/disable_add_instance", new HashMap<>(), null, response -> {
        }, w -> w);
        return testDto;
    }).await(SdxClusterStatusResponse.NODE_FAILURE, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).awaitForMasterDeletedOnProvider().awaitForFlowFail().then((tc, testDto, client) -> {
        getExecuteQueryToMockInfrastructure().executeMethod(Method.build("POST"), "/" + testDto.getCrn() + "/spi/enable_add_instance", new HashMap<>(), null, response -> {
        }, w -> w);
        return testDto;
    }).when(sdxTestClient.repairInternal(MASTER.getName()), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
Also used : SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) Duration(java.time.Duration) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) Method(com.sequenceiq.it.cloudbreak.dto.mock.Method) RunningParameter.pollingInterval(com.sequenceiq.it.cloudbreak.context.RunningParameter.pollingInterval) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) Consumer(java.util.function.Consumer) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) HashMap(java.util.HashMap) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) EnvironmentNetworkMockParams(com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams) ArrayList(java.util.ArrayList) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 32 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class SdxRangerRazEnabledTests method testCreateSdxWithRangerRaz.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak", when = "enableRangerRaz is called when Raz is installed", then = "rangerRazEnabled is set for Sdx")
public void testCreateSdxWithRangerRaz(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(SdxTestDto.class).withExternalDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withRangerRazEnabled(Boolean.TRUE).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().when(sdxTestClient.enableRangerRaz()).then((tc, testDto, client) -> {
        final boolean rangerRazEnabled = testDto.getResponse().getRangerRazEnabled();
        if (!rangerRazEnabled) {
            throw new TestFailException("Ranger raz was not enabled!");
        }
        return testDto;
    }).validate();
}
Also used : Inject(javax.inject.Inject) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) BadRequestException(javax.ws.rs.BadRequestException) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 33 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class SdxRepairTests method testSDXRepairMasterAndIDBRokerWithStoppedEC2Instance.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "recovery called on the MASTER and then the IDBROKER host group, where the EC2 instance had been stopped", then = "SDX recovery should be successful, the cluster should be up and running")
public void testSDXRepairMasterAndIDBRokerWithStoppedEC2Instance(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    DescribeFreeIpaResponse describeFreeIpaResponse = testContext.given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).getResponse();
    SdxTestDto sdxTestDto = testContext.given(sdx, SdxTestDto.class).withCloudStorage(getCloudStorageRequest(testContext)).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances();
    repair(sdxTestDto, sdx, MASTER.getName(), Set.of(SdxClusterStatusResponse.CLUSTER_UNREACHABLE));
    repair(sdxTestDto, sdx, IDBROKER.getName(), Set.of(SdxClusterStatusResponse.NODE_FAILURE));
    sdxTestDto.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();
}
Also used : SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) HashSet(java.util.HashSet) Inject(javax.inject.Inject) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) StackTestClient(com.sequenceiq.it.cloudbreak.client.StackTestClient) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) VolumeUtils(com.sequenceiq.it.cloudbreak.util.VolumeUtils) RecipeTestClient(com.sequenceiq.it.cloudbreak.client.RecipeTestClient) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 34 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class SdxResizeTests method testSDXResize.

@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "resize called on the SDX cluster", then = "SDX resize should be successful, the cluster should be up and running")
public void testSDXResize(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    AtomicReference<String> expectedShape = new AtomicReference<>();
    AtomicReference<String> expectedCrn = new AtomicReference<>();
    AtomicReference<String> expectedName = new AtomicReference<>();
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(sdx, SdxInternalTestDto.class).withDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).withClusterShape(SdxClusterShape.CUSTOM).when(sdxTestClient.createInternal(), key(sdx)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, testDto, client) -> {
        expectedShape.set(sdxUtil.getShape(testDto, client));
        expectedCrn.set(sdxUtil.getCrn(testDto, client));
        expectedName.set(testDto.getName());
        return testDto;
    }).when(sdxTestClient.resize(), key(sdx)).await(SdxClusterStatusResponse.STOP_IN_PROGRESS, key(sdx).withWaitForFlow(Boolean.FALSE)).await(SdxClusterStatusResponse.STACK_CREATION_IN_PROGRESS, key(sdx).withWaitForFlow(Boolean.FALSE)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, dto, client) -> validateStackCrn(expectedCrn, dto)).then((tc, dto, client) -> validateCrn(expectedCrn, dto)).then((tc, dto, client) -> validateShape(dto)).then((tc, dto, client) -> validateClusterName(expectedName, dto)).validate();
}
Also used : SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) LoggerFactory(org.slf4j.LoggerFactory) Log(com.sequenceiq.it.cloudbreak.log.Log) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) AtomicReference(java.util.concurrent.atomic.AtomicReference) String.format(java.lang.String.format) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) AtomicReference(java.util.concurrent.atomic.AtomicReference) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)

Example 35 with TestContext

use of com.sequenceiq.it.cloudbreak.context.TestContext in project cloudbreak by hortonworks.

the class AwsSdxSpotInstanceTest method testSdxOnSpotInstances.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running cloudbreak ", when = "creating an SDX with 100% spot percentage ", then = "SDX is started on spot instances, or fails with insufficient spot capacity")
public void testSdxOnSpotInstances(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    SdxDatabaseRequest database = new SdxDatabaseRequest();
    database.setCreate(false);
    testContext.given(SdxTestDto.class).withCloudStorage().withExternalDatabase(database).withSpotPercentage(100).when(sdxTestClient.create(), key(sdx)).then((tc, testDto, client) -> {
        testDto.await(STACK_CREATED, key(sdx));
        Map<String, Exception> exceptionMap = testContext.getExceptionMap();
        if (!exceptionMap.isEmpty()) {
            String key = testDto.getAwaitExceptionKey(STACK_CREATED);
            if (exceptionMap.containsKey(key)) {
                LOGGER.info("Awaiting STACK_CREATED failed, clearing exception to check status reason", exceptionMap.get(key));
                exceptionMap.remove(key);
            }
        }
        return testDto;
    }).when(sdxTestClient.describe()).then(assertSpotInstances()).validate();
}
Also used : SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) Test(org.testng.annotations.Test) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) Assertion(com.sequenceiq.it.cloudbreak.assertion.Assertion) Map(java.util.Map) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) InstanceLifeCycle(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceLifeCycle) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) Map(java.util.Map) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) AbstractE2ETest(com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)

Aggregations

TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)45 Test (org.testng.annotations.Test)38 Description (com.sequenceiq.it.cloudbreak.context.Description)32 Inject (javax.inject.Inject)32 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)20 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)20 SdxTestClient (com.sequenceiq.it.cloudbreak.client.SdxTestClient)18 MockedTestContext (com.sequenceiq.it.cloudbreak.context.MockedTestContext)18 UseSpotInstances (com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)17 SdxClusterStatusResponse (com.sequenceiq.sdx.api.model.SdxClusterStatusResponse)17 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)15 List (java.util.List)15 AbstractE2ETest (com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)14 DistroXTestClient (com.sequenceiq.it.cloudbreak.client.DistroXTestClient)13 Logger (org.slf4j.Logger)13 LoggerFactory (org.slf4j.LoggerFactory)13 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)12 SdxTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto)12 SdxDatabaseRequest (com.sequenceiq.sdx.api.model.SdxDatabaseRequest)11 EnvironmentTestClient (com.sequenceiq.it.cloudbreak.client.EnvironmentTestClient)10