Search in sources :

Example 16 with STOPPED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED in project cloudbreak by hortonworks.

the class StackOperationServiceTest method testStartWhenStackStopped.

@Test
public void testStartWhenStackStopped() {
    Stack stack = new Stack();
    stack.setStackStatus(new StackStatus(stack, STOPPED));
    stack.setId(1L);
    underTest.start(stack);
    verify(flowManager, times(1)).triggerStackStart(stack.getId());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with STOPPED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED in project cloudbreak by hortonworks.

the class StackOperationServiceTest method testStartWhenCheckCallEnvironmentCheck.

@Test
public void testStartWhenCheckCallEnvironmentCheck() {
    Stack stack = new Stack();
    stack.setId(9876L);
    stack.setStackStatus(new StackStatus(stack, STOPPED));
    Cluster cluster = new Cluster();
    stack.setCluster(cluster);
    underTest.start(stack);
    verify(environmentService).checkEnvironmentStatus(stack, EnvironmentStatus.startable());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with STOPPED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED in project cloudbreak by hortonworks.

the class StackDownscaleValidatorServiceTest method testCheckClusterInValidStatusWhenInStoppedStatus.

@Test
public void testCheckClusterInValidStatusWhenInStoppedStatus() {
    Stack stack = new Stack();
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.STOPPED));
    expectedException.expect(BadRequestException.class);
    expectedException.expectMessage("Cluster is in Stopped status. Please start the cluster for downscale.");
    underTest.checkClusterInValidStatus(stack);
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 19 with STOPPED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED in project cloudbreak by hortonworks.

the class InternalSdxRepairWithRecipeTest method testSDXMultiRepairIDBRokerAndMasterWithRecipeFile.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "recovery called on the IDBROKER and MASTER host group, where the EC2 instance had been stopped", then = "SDX recovery should be successful, the cluster should be up and running")
public void testSDXMultiRepairIDBRokerAndMasterWithRecipeFile(TestContext testContext) throws IOException {
    String sdxInternal = resourcePropertyProvider().getName();
    String cluster = resourcePropertyProvider().getName();
    String clouderaManager = resourcePropertyProvider().getName();
    String recipeName = resourcePropertyProvider().getName();
    String stack = resourcePropertyProvider().getName();
    String filePath = "/post-install";
    String fileName = "post-install";
    String masterInstanceGroup = "master";
    String idbrokerInstanceGroup = "idbroker";
    SdxDatabaseRequest sdxDatabaseRequest = new SdxDatabaseRequest();
    sdxDatabaseRequest.setAvailabilityType(SdxDatabaseAvailabilityType.NONE);
    testContext.given(clouderaManager, ClouderaManagerTestDto.class).given(cluster, ClusterTestDto.class).withBlueprintName(getDefaultSDXBlueprintName()).withValidateBlueprint(Boolean.FALSE).withClouderaManager(clouderaManager).given(RecipeTestDto.class).withName(recipeName).withContent(generateRecipeContent()).withRecipeType(POST_CLOUDERA_MANAGER_START).when(recipeTestClient.createV4()).given(masterInstanceGroup, InstanceGroupTestDto.class).withHostGroup(MASTER).withNodeCount(1).withRecipes(recipeName).given(idbrokerInstanceGroup, InstanceGroupTestDto.class).withHostGroup(IDBROKER).withNodeCount(1).withRecipes(recipeName).given(stack, StackTestDto.class).withCluster(cluster).withInstanceGroups(masterInstanceGroup, idbrokerInstanceGroup).given(sdxInternal, SdxInternalTestDto.class).withCloudStorage(getCloudStorageRequest(testContext)).withDatabase(sdxDatabaseRequest).withStackRequest(key(cluster), key(stack)).when(sdxTestClient.createInternal(), key(sdxInternal)).await(SdxClusterStatusResponse.RUNNING).awaitForHealthyInstances().then((tc, testDto, client) -> {
        return sshJUtil.checkFilesOnHostByNameAndPath(testDto, getInstanceGroups(testDto, client), List.of(MASTER.getName(), IDBROKER.getName()), filePath, fileName, 1, null, null);
    }).then((tc, testDto, client) -> {
        List<String> instanceIdsToStop = sdxUtil.getInstanceIds(testDto, client, MASTER.getName());
        instanceIdsToStop.addAll(sdxUtil.getInstanceIds(testDto, client, IDBROKER.getName()));
        getCloudFunctionality(tc).stopInstances(testDto.getName(), instanceIdsToStop);
        return testDto;
    }).awaitForStoppedInstances().when(sdxTestClient.repairInternal(MASTER.getName(), IDBROKER.getName()), key(sdxInternal)).await(SdxClusterStatusResponse.REPAIR_IN_PROGRESS, key(sdxInternal).withWaitForFlow(Boolean.FALSE)).await(SdxClusterStatusResponse.RUNNING, key(sdxInternal)).awaitForHealthyInstances().then((tc, testDto, client) -> {
        return sshJUtil.checkFilesOnHostByNameAndPath(testDto, getInstanceGroups(testDto, client), List.of(MASTER.getName(), IDBROKER.getName()), filePath, fileName, 1, null, null);
    }).validate();
}
Also used : ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) POST_CLOUDERA_MANAGER_START(com.sequenceiq.cloudbreak.api.endpoint.v4.recipes.requests.RecipeV4Type.POST_CLOUDERA_MANAGER_START) RecipeTestDto(com.sequenceiq.it.cloudbreak.dto.recipe.RecipeTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Base64(org.apache.commons.codec.binary.Base64) Description(com.sequenceiq.it.cloudbreak.context.Description) Inject(javax.inject.Inject) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) InstanceGroupTestDto(com.sequenceiq.it.cloudbreak.dto.InstanceGroupTestDto) ResourceUtil(com.sequenceiq.it.util.ResourceUtil) StackTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) ClouderaManagerTestDto(com.sequenceiq.it.cloudbreak.dto.ClouderaManagerTestDto) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) IOException(java.io.IOException) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) StackTestClient(com.sequenceiq.it.cloudbreak.client.StackTestClient) SshJUtil(com.sequenceiq.it.cloudbreak.util.ssh.SshJUtil) List(java.util.List) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) RecipeTestClient(com.sequenceiq.it.cloudbreak.client.RecipeTestClient) SdxInternalTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxInternalTestDto) ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) RecipeTestDto(com.sequenceiq.it.cloudbreak.dto.recipe.RecipeTestDto) List(java.util.List) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 20 with STOPPED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED 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)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 Test (org.junit.jupiter.api.Test)7 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)6 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)6 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 PollerException (com.dyngr.exception.PollerException)5 PollerStoppedException (com.dyngr.exception.PollerStoppedException)5 UserBreakException (com.dyngr.exception.UserBreakException)5 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Inject (javax.inject.Inject)3 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)2 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)2 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)2 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)2