Search in sources :

Example 1 with HostGroupType

use of com.sequenceiq.it.cloudbreak.cloud.HostGroupType in project cloudbreak by hortonworks.

the class MockSdxRepairTests method testRepair.

public void testRepair(MockedTestContext testContext, List<HostGroupType> hostGroups, Consumer<String> actionOnNode, SdxClusterStatusResponse stateBeforeRepair) {
    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<>();
        for (HostGroupType hostGroupType : hostGroups) {
            instancesToDelete.addAll(sdxUtil.getInstanceIds(testDto, client, hostGroupType.getName()));
        }
        instancesToDelete.forEach(instanceId -> actionOnNode.accept("/" + testDto.getCrn() + "/spi/" + instanceId));
        return testDto;
    }).await(stateBeforeRepair, pollingInterval(Duration.ofSeconds(POLLING_INTERVAL_FOR_REPAIR_SECONDS))).when(sdxTestClient.repairInternal(hostGroups.stream().map(HostGroupType::getName).toArray(String[]::new)), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).validate();
}
Also used : HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) 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)

Example 2 with HostGroupType

use of com.sequenceiq.it.cloudbreak.cloud.HostGroupType in project cloudbreak by hortonworks.

the class RecipeClusterTest method testDeletedRecipeCannotBeAssignedToCluster.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a deleted recipe", when = "starting cluster with deleted recipe", then = "badrequest exception is received")
public void testDeletedRecipeCannotBeAssignedToCluster(MockedTestContext testContext) {
    LOGGER.info("testing recipe execution for type: {}", PRE_CLOUDERA_MANAGER_START.name());
    String recipeName = resourcePropertyProvider().getName();
    String stackName = resourcePropertyProvider().getName();
    String instanceGroupName = resourcePropertyProvider().getName();
    HostGroupType hostGroupTypeForRecipe = HostGroupType.WORKER;
    testContext.given(recipeName, RecipeTestDto.class).withName(recipeName).withContent(RECIPE_CONTENT).withRecipeType(PRE_CLOUDERA_MANAGER_START).when(recipeTestClient.createV4(), RunningParameter.key(recipeName)).when(recipeTestClient.deleteV4(), RunningParameter.key(recipeName)).given(instanceGroupName, InstanceGroupTestDto.class).withHostGroup(hostGroupTypeForRecipe).withNodeCount(NODE_COUNT).withRecipes(recipeName).given(stackName, StackTestDto.class).replaceInstanceGroups(instanceGroupName).whenException(stackTestClient.createV4(), BadRequestException.class, expectedMessage(String.format("The given recipe does not exist" + " for the instance group \"%s\": %s", hostGroupTypeForRecipe.getName(), recipeName))).validate();
}
Also used : HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) StackTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto) BadRequestException(javax.ws.rs.BadRequestException) RecipeTestDto(com.sequenceiq.it.cloudbreak.dto.recipe.RecipeTestDto) InstanceGroupTestDto(com.sequenceiq.it.cloudbreak.dto.InstanceGroupTestDto) Description(com.sequenceiq.it.cloudbreak.context.Description) TestCaseDescription(com.sequenceiq.it.cloudbreak.context.TestCaseDescription) Test(org.testng.annotations.Test)

Aggregations

HostGroupType (com.sequenceiq.it.cloudbreak.cloud.HostGroupType)2 CustomDomainSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request)1 EnvironmentNetworkMockParams (com.sequenceiq.environment.api.v1.environment.model.EnvironmentNetworkMockParams)1 Description (com.sequenceiq.it.cloudbreak.context.Description)1 TestCaseDescription (com.sequenceiq.it.cloudbreak.context.TestCaseDescription)1 InstanceGroupTestDto (com.sequenceiq.it.cloudbreak.dto.InstanceGroupTestDto)1 RecipeTestDto (com.sequenceiq.it.cloudbreak.dto.recipe.RecipeTestDto)1 SdxInternalTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto)1 StackTestDto (com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto)1 SdxDatabaseRequest (com.sequenceiq.sdx.api.model.SdxDatabaseRequest)1 ArrayList (java.util.ArrayList)1 BadRequestException (javax.ws.rs.BadRequestException)1 Test (org.testng.annotations.Test)1