Search in sources :

Example 66 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class CloudResourceAdvisorTest method createBlueprint.

private Blueprint createBlueprint() {
    Blueprint blueprint = new Blueprint();
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    blueprint.setWorkspace(workspace);
    blueprint.setBlueprintText("{\"Blueprints\":{123:2}}");
    return blueprint;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 67 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class LoggingAgentAutoRestartPatchServiceTest method createStack.

private Stack createStack() {
    Stack stack = new Stack();
    stack.setId(1L);
    stack.setType(StackType.WORKLOAD);
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    stack.setWorkspace(workspace);
    stack.setCluster(cluster);
    stack.setResourceCrn("crn:cdp:datahub:us-west-1:accountId:cluster:name");
    InstanceGroup instanceGroup = createInstanceGroup();
    instanceGroup.setInstanceMetaData(Set.of(createInstanceMetaData()));
    stack.setInstanceGroups(Set.of(instanceGroup));
    return stack;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 68 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class ClusterTemplateServiceCreationValidationTest method testWhenClusterTemplateDoesNotContainBlueprintBadRequestExceptionComes.

@Test
void testWhenClusterTemplateDoesNotContainBlueprintBadRequestExceptionComes() {
    Workspace workspace = new Workspace();
    Blueprint blueprint = new Blueprint();
    Cluster cluster = new Cluster();
    cluster.setBlueprint(blueprint);
    Stack stack = new Stack();
    stack.setEnvironmentCrn("someCrn");
    stack.setCluster(cluster);
    ClusterTemplate clusterTemplate = new ClusterTemplate();
    clusterTemplate.setStackTemplate(stack);
    clusterTemplate.setStatus(ResourceStatus.USER_MANAGED);
    clusterTemplate.setWorkspace(workspace);
    when(clusterTemplateRepository.findByNameAndWorkspace(any(), any())).thenReturn(Optional.empty());
    when(blueprintService.getAllAvailableInWorkspace(workspace)).thenReturn(Collections.emptySet());
    when(entitlementService.internalTenant(anyString())).thenReturn(true);
    when(internalClusterTemplateValidator.isInternalTemplateInNotInternalTenant(anyBoolean(), any(FeatureState.class))).thenReturn(true);
    Exception e = Assertions.assertThrows(BadRequestException.class, () -> underTest.createForLoggedInUser(clusterTemplate, WORKSPACE_ID, ACCOUNT_ID, CREATOR_ID));
    Assert.assertEquals("Cluster definition should contain a Datahub template!", e.getMessage());
}
Also used : ClusterTemplate(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) FeatureState(com.sequenceiq.cloudbreak.api.endpoint.v4.common.FeatureState) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 69 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class SharedServiceValidatorTest method getWorkspace.

private Workspace getWorkspace() {
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    return workspace;
}
Also used : Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 70 with Workspace

use of com.sequenceiq.cloudbreak.workspace.model.Workspace in project cloudbreak by hortonworks.

the class StackService method getByCrnInWorkspaceWithEntries.

public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
    try {
        return transactionService.required(() -> {
            Workspace workspace = workspaceService.get(workspaceId, user);
            ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
            Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
            if (stack.isEmpty()) {
                throw new NotFoundException(format("Stack not found by crn '%s'", crn));
            }
            StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
            stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
            return stackResponse;
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : ShowTerminatedClustersAfterConfig(com.sequenceiq.cloudbreak.service.stack.ShowTerminatedClusterConfigService.ShowTerminatedClustersAfterConfig) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AutoscaleStack(com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Aggregations

Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)75 User (com.sequenceiq.cloudbreak.workspace.model.User)26 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)17 Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)12 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)9 Test (org.junit.jupiter.api.Test)9 HashMap (java.util.HashMap)8 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 Before (org.junit.Before)7 Test (org.junit.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)4 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)4 ClusterTemplate (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterTemplate)4 HashSet (java.util.HashSet)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4