Search in sources :

Example 26 with Description

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

the class SdxRangerRazEnabledTests method testCreateSdxWithoutRangerRaz.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak", when = "enableRangerRaz is called when Raz is not installed", then = "Exception is thrown")
public void testCreateSdxWithoutRangerRaz(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(SdxTestDto.class).withExternalDatabase(sdxDatabaseRequest).withCloudStorage(getCloudStorageRequest(testContext)).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().whenException(sdxTestClient.enableRangerRaz(), BadRequestException.class).validate();
}
Also used : SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) BadRequestException(javax.ws.rs.BadRequestException) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 27 with Description

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

the class SdxSecurityTests method testSDXAutoTlsCertRotation.

@Test(dataProvider = TEST_CONTEXT)
@UseSpotInstances
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "autotls cert rotation is called on the SDX cluster", then = "host certificates' validity should be changed on all hosts, the cluster should be up and running")
public void testSDXAutoTlsCertRotation(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    List<String> originalCertValidityOutput = new ArrayList<>();
    List<String> renewedCertValidityOutput = new ArrayList<>();
    SdxDatabaseRequest noDatabaseRequest = new SdxDatabaseRequest();
    noDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(sdx, SdxTestDto.class).withCloudStorage().withExternalDatabase(noDatabaseRequest).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, testDto, client) -> {
        Map<String, Pair<Integer, String>> certValidityCmdResultByIpsMap = sshJClientActions.executeSshCommandOnHost(getInstanceGroups(testDto, client), List.of(HostGroupType.MASTER.getName(), HostGroupType.IDBROKER.getName()), HOST_CERT_VALIDITY_CMD, false);
        originalCertValidityOutput.addAll(certValidityCmdResultByIpsMap.values().stream().map(Pair::getValue).collect(Collectors.toList()));
        return testDto;
    }).when(sdxTestClient.rotateAutotlsCertificates(), key(sdx)).await(SdxClusterStatusResponse.CERT_ROTATION_IN_PROGRESS, key(sdx).withWaitForFlow(false)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances().then((tc, testDto, client) -> {
        Map<String, Pair<Integer, String>> certValidityCmdResultByIpsMap = sshJClientActions.executeSshCommandOnHost(getInstanceGroups(testDto, client), List.of(HostGroupType.MASTER.getName(), HostGroupType.IDBROKER.getName()), HOST_CERT_VALIDITY_CMD, false);
        renewedCertValidityOutput.addAll(certValidityCmdResultByIpsMap.entrySet().stream().map(e -> e.getValue().getValue()).collect(Collectors.toList()));
        return testDto;
    }).then((tc, testDto, client) -> compareCertValidityOutputs(testDto, originalCertValidityOutput, renewedCertValidityOutput)).validate();
}
Also used : SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) 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) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) Map(java.util.Map) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) SshJClientActions(com.sequenceiq.it.cloudbreak.util.ssh.action.SshJClientActions) HostGroupType(com.sequenceiq.it.cloudbreak.cloud.HostGroupType) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) ArrayList(java.util.ArrayList) Map(java.util.Map) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Pair(org.apache.commons.lang3.tuple.Pair) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)

Example 28 with Description

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

the class MultiThreadTenantTest method collectTestCaseDescription.

private TestCaseDescription collectTestCaseDescription(MockedTestContext testContext, Method method, Object[] params) {
    Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
    TestCaseDescription testCaseDescription = null;
    if (declaredAnnotation != null) {
        testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
        testContext.addDescription(testCaseDescription);
    } else if (method.getParameters().length == params.length) {
        Parameter[] parameters = method.getParameters();
        for (int i = 1; i < parameters.length; i++) {
            if (parameters[i].getAnnotation(Description.class) != null) {
                Object param = params[i];
                if (!(param instanceof TestCaseDescription)) {
                    throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
                }
                testCaseDescription = (TestCaseDescription) param;
                testContext.addDescription(testCaseDescription);
                break;
            }
        }
    }
    return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
Also used : ImageCatalogTestClient(com.sequenceiq.it.cloudbreak.client.ImageCatalogTestClient) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) LoggerFactory(org.slf4j.LoggerFactory) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) IntegrationTestConfiguration(com.sequenceiq.it.config.IntegrationTestConfiguration) Description(com.sequenceiq.it.cloudbreak.context.Description) EnvironmentNetworkTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto) Map(java.util.Map) ThreadLocalProfiles(com.sequenceiq.it.cloudbreak.mock.ThreadLocalProfiles) TestCaseDescription(com.sequenceiq.it.cloudbreak.context.TestCaseDescription) Method(java.lang.reflect.Method) AbstractTestNGSpringContextTests(org.springframework.test.context.testng.AbstractTestNGSpringContextTests) MockedTestContext(com.sequenceiq.it.cloudbreak.context.MockedTestContext) TestCaseDescriptionMissingException(com.sequenceiq.it.cloudbreak.exception.TestCaseDescriptionMissingException) BeforeMethod(org.testng.annotations.BeforeMethod) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) DistroXTestClient(com.sequenceiq.it.cloudbreak.client.DistroXTestClient) Optional(java.util.Optional) EnvironmentStatus(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentStatus) BlueprintTestDto(com.sequenceiq.it.cloudbreak.dto.blueprint.BlueprintTestDto) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) ImageCatalogCreateRetryAction(com.sequenceiq.it.cloudbreak.action.v4.imagecatalog.ImageCatalogCreateRetryAction) CredentialTestDto(com.sequenceiq.it.cloudbreak.dto.credential.CredentialTestDto) DataProvider(org.testng.annotations.DataProvider) TracerAutoConfiguration(io.opentracing.contrib.spring.tracer.configuration.TracerAutoConfiguration) ITestResult(org.testng.ITestResult) TestCaseDescriptionBuilder(com.sequenceiq.it.cloudbreak.context.TestCaseDescription.TestCaseDescriptionBuilder) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) Strings(com.google.common.base.Strings) ConfigFileApplicationContextInitializer(org.springframework.boot.test.context.ConfigFileApplicationContextInitializer) Parameter(java.lang.reflect.Parameter) CredentialTestClient(com.sequenceiq.it.cloudbreak.client.CredentialTestClient) ResourcePropertyProvider(com.sequenceiq.it.cloudbreak.ResourcePropertyProvider) AfterClass(org.testng.annotations.AfterClass) BlueprintTestClient(com.sequenceiq.it.cloudbreak.client.BlueprintTestClient) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) BeansException(org.springframework.beans.BeansException) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) 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) CloudbreakActor(com.sequenceiq.it.cloudbreak.actor.CloudbreakActor) MDC(org.slf4j.MDC) ContextConfiguration(org.springframework.test.context.ContextConfiguration) TestCaseDescriptionMissingException(com.sequenceiq.it.cloudbreak.exception.TestCaseDescriptionMissingException) Description(com.sequenceiq.it.cloudbreak.context.Description) TestCaseDescription(com.sequenceiq.it.cloudbreak.context.TestCaseDescription) TestCaseDescriptionBuilder(com.sequenceiq.it.cloudbreak.context.TestCaseDescription.TestCaseDescriptionBuilder) TestCaseDescription(com.sequenceiq.it.cloudbreak.context.TestCaseDescription)

Example 29 with Description

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

the class RecipeClusterTest method testWhenClusterGetUpScaledThenPostClusterInstallRecipeShouldBeExecuted.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a created cluster with post ambari install recipe", when = "upscaling cluster", then = "the post recipe should run on the new nodes as well")
public void testWhenClusterGetUpScaledThenPostClusterInstallRecipeShouldBeExecuted(MockedTestContext testContext) {
    ApiParcel parcel = parcelGeneratorUtil.getActivatedCDHParcel();
    String clusterName = resourcePropertyProvider.getName();
    parcelMockActivatorUtil.mockActivateWithDefaultParcels(testContext, clusterName, parcel);
    String recipeName = resourcePropertyProvider().getName();
    testContext.given(RecipeTestDto.class).withName(recipeName).withContent(RECIPE_CONTENT).withRecipeType(POST_CLUSTER_INSTALL).when(recipeTestClient.createV4()).given(INSTANCE_GROUP_ID, InstanceGroupTestDto.class).withHostGroup(HostGroupType.WORKER).withNodeCount(NODE_COUNT).withRecipes(recipeName).given("computeIg", InstanceGroupTestDto.class).withHostGroup(HostGroupType.COMPUTE).withNodeCount(NODE_COUNT).withRecipes(recipeName).given("cmpkey", ClouderaManagerProductTestDto.class).withParcel("someParcel").withName(parcel.getProduct()).withVersion(parcel.getVersion()).given("cmanager", ClouderaManagerTestDto.class).withClouderaManagerProduct("cmpkey").given("cmpclusterkey", ClusterTestDto.class).withClouderaManager("cmanager").given(StackTestDto.class).withName(clusterName).replaceInstanceGroups(INSTANCE_GROUP_ID).withCluster("cmpclusterkey").when(stackTestClient.createV4()).enableVerification().await(STACK_AVAILABLE).when(StackScalePostAction.valid().withDesiredCount(4)).await(STACK_AVAILABLE, pollingInterval(POLLING_INTERVAL)).mockSalt().run().post().bodyContains(HIGHSTATE, 1).atLeast(1).verify().validate();
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ClouderaManagerProductTestDto(com.sequenceiq.it.cloudbreak.dto.ClouderaManagerProductTestDto) StackTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto) ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) ClouderaManagerTestDto(com.sequenceiq.it.cloudbreak.dto.ClouderaManagerTestDto) 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)

Example 30 with Description

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

the class RecipeClusterTest method testWhenRecipeProvidedToHostGroupAndAnotherHostGroupGetUpScaledThenThereIsNoFurtherRecipeExecutionOnTheNewNodeBesideTheDefaultOnes.

@Test(dataProvider = TEST_CONTEXT_WITH_MOCK)
@Description(given = "a created cluster with post ambari recipe", when = "upscaling cluster on hostgroup which has no post install recipe", then = "the post recipe should not run on the new nodes because those recipe not configured on the upscaled hostgroup")
public void testWhenRecipeProvidedToHostGroupAndAnotherHostGroupGetUpScaledThenThereIsNoFurtherRecipeExecutionOnTheNewNodeBesideTheDefaultOnes(MockedTestContext testContext) {
    ApiParcel parcel = parcelGeneratorUtil.getActivatedCDHParcel();
    String recipeName = resourcePropertyProvider().getName();
    String clusterName = resourcePropertyProvider.getName();
    parcelMockActivatorUtil.mockActivateWithDefaultParcels(testContext, clusterName, parcel);
    testContext.given(RecipeTestDto.class).withName(recipeName).withContent(RECIPE_CONTENT).withRecipeType(POST_CLOUDERA_MANAGER_START).when(recipeTestClient.createV4()).given(INSTANCE_GROUP_ID, InstanceGroupTestDto.class).withHostGroup(HostGroupType.COMPUTE).withNodeCount(NODE_COUNT).withRecipes(recipeName).given("cmpkey", ClouderaManagerProductTestDto.class).withParcel("someParcel").withName(parcel.getProduct()).withVersion(parcel.getVersion()).given("cmanager", ClouderaManagerTestDto.class).withClouderaManagerProduct("cmpkey").given("cmpclusterkey", ClusterTestDto.class).withClouderaManager("cmanager").given(StackTestDto.class).withName(clusterName).replaceInstanceGroups(INSTANCE_GROUP_ID).withCluster("cmpclusterkey").when(stackTestClient.createV4()).enableVerification().await(STACK_AVAILABLE).when(StackScalePostAction.valid().withDesiredCount(4)).await(STACK_AVAILABLE, pollingInterval(POLLING_INTERVAL)).mockSalt().run().post().bodyContains(HIGHSTATE, 1).atLeast(1).verify().validate();
}
Also used : ApiParcel(com.cloudera.api.swagger.model.ApiParcel) ClouderaManagerProductTestDto(com.sequenceiq.it.cloudbreak.dto.ClouderaManagerProductTestDto) StackTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto) ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) ClouderaManagerTestDto(com.sequenceiq.it.cloudbreak.dto.ClouderaManagerTestDto) 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

Description (com.sequenceiq.it.cloudbreak.context.Description)72 Test (org.testng.annotations.Test)71 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)30 Inject (javax.inject.Inject)30 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)29 DistroXTestDto (com.sequenceiq.it.cloudbreak.dto.distrox.DistroXTestDto)24 AbstractE2ETest (com.sequenceiq.it.cloudbreak.testcase.e2e.AbstractE2ETest)22 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)19 UseSpotInstances (com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances)19 SdxTestClient (com.sequenceiq.it.cloudbreak.client.SdxTestClient)17 SdxInternalTestDto (com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto)17 FreeIpaTestDto (com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto)16 SdxClusterStatusResponse (com.sequenceiq.sdx.api.model.SdxClusterStatusResponse)16 SdxDatabaseRequest (com.sequenceiq.sdx.api.model.SdxDatabaseRequest)15 EnvironmentNetworkTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentNetworkTestDto)14 List (java.util.List)14 ImageCatalogTestDto (com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)13 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)13 AbstractIntegrationTest (com.sequenceiq.it.cloudbreak.testcase.AbstractIntegrationTest)13 DistroXTestClient (com.sequenceiq.it.cloudbreak.client.DistroXTestClient)12