Search in sources :

Example 71 with Workspace

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

the class RecipeService method createWithInternalUser.

public Recipe createWithInternalUser(Recipe recipe, @Nonnull Long workspaceId, String accountId) {
    if (recipeViewRepository.findByNameAndWorkspaceId(recipe.getName(), workspaceId).isPresent()) {
        String message = String.format("%s already exists with name '%s'", recipe.getResourceName(), recipe.getName());
        throw new BadRequestException(message);
    }
    recipe.setResourceCrn(createCRN(accountId));
    try {
        return transactionService.required(() -> {
            Workspace workspace = getWorkspaceService().getByIdWithoutAuth(workspaceId);
            recipe.setWorkspace(workspace);
            recipe.setCreationType(CreationType.SERVICE);
            return super.pureSave(recipe);
        });
    } catch (TransactionService.TransactionExecutionException e) {
        throw new TransactionService.TransactionRuntimeExecutionException(e);
    }
}
Also used : TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 72 with Workspace

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

the class ScheduledLifetimeCheckerTest method testValidateWhenClusterExceededByRunningTimeMoreThanTTL.

@Test
public void testValidateWhenClusterExceededByRunningTimeMoreThanTTL() {
    StackTtlViewImpl stack = new StackTtlViewImpl();
    stack.setId(STACK_ID);
    long startTimeMillis = 0;
    stack.setCreationFinished(startTimeMillis);
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    workspace.setName("workspace");
    stack.setWorkspace(workspace);
    int ttlMillis = 1;
    StackStatus stackStatus = new StackStatus();
    stackStatus.setStatus(Status.AVAILABLE);
    stack.setStatus(stackStatus);
    when(stackService.getAllAlive()).thenReturn(Collections.singletonList(stack));
    when(stackService.getTtlValueForStack(anyLong())).thenReturn(Optional.of(Duration.ofMillis(ttlMillis)));
    when(clock.getCurrentTimeMillis()).thenReturn(startTimeMillis + ttlMillis + 1);
    underTest.validate();
    verify(flowManager, times(1)).triggerTermination(stack.getId());
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Test(org.junit.Test)

Example 73 with Workspace

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

the class ImageCatalogServiceTest method getImageCatalog.

private ImageCatalog getImageCatalog() {
    ImageCatalog imageCatalog = new ImageCatalog();
    imageCatalog.setImageCatalogUrl(DEFAULT_CATALOG_URL);
    imageCatalog.setName("default");
    Workspace ws = new Workspace();
    ws.setId(ORG_ID);
    imageCatalog.setWorkspace(ws);
    imageCatalog.setCreator("someone");
    imageCatalog.setResourceCrn("someCrn");
    return imageCatalog;
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 74 with Workspace

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

the class CloudbreakRestRequestThreadLocalServiceTest method aWorkspace.

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

Example 75 with Workspace

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

the class ClusterDecoratorTest method testAutoTlsSetting.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void testAutoTlsSetting(String valueString) {
    boolean useAutoTls = Boolean.parseBoolean(valueString);
    Cluster expectedClusterInstance = new Cluster();
    Blueprint blueprint = getBlueprint();
    when(sharedServiceConfigProvider.configureCluster(any(Cluster.class), any(User.class), any(Workspace.class))).thenReturn(expectedClusterInstance);
    when(platformParameters.isAutoTlsSupported()).thenReturn(useAutoTls);
    when(embeddedDatabaseService.isEmbeddedDatabaseOnAttachedDiskEnabled(stack, expectedClusterInstance)).thenReturn(false);
    Cluster result = underTest.decorate(expectedClusterInstance, createClusterV4Request(), blueprint, user, new Workspace(), stack, null);
    assertEquals(useAutoTls, result.getAutoTlsEnabled());
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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