Search in sources :

Example 11 with Tenant

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

the class ServiceEndpointCollectorTest method createClusterWithComponents.

private Cluster createClusterWithComponents(ExposedService[] topology1Services, ExposedService[] topology2Services, GatewayType gatewayType) {
    Cluster cluster = clusterkWithOrchestrator("ANY");
    GatewayTopology topology1 = gatewayTopology("topology1", topology1Services);
    topology1.setGateway(cluster.getGateway());
    GatewayTopology topology2 = gatewayTopology("topology2", topology2Services);
    topology2.setGateway(cluster.getGateway());
    cluster.getGateway().setTopologies(Sets.newHashSet(topology1, topology2));
    cluster.getGateway().setGatewayType(gatewayType);
    Workspace workspace = new Workspace();
    Tenant tenant = new Tenant();
    tenant.setName("tenant");
    workspace.setTenant(tenant);
    cluster.setWorkspace(workspace);
    return cluster;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Example 12 with Tenant

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

the class StackImageUpdateActionsTest method setup.

@Before
public void setup() throws CloudbreakImageNotFoundException {
    MockitoAnnotations.initMocks(this);
    when(stateContext.getMessageHeader(HEADERS.FLOW_PARAMETERS.name())).thenReturn(new FlowParameters("flowId", "usercrn", null));
    when(stateContext.getExtendedState()).thenReturn(extendedState);
    when(stateContext.getStateMachine()).thenReturn(stateMachine);
    when(stateMachine.getState()).thenReturn(state);
    when(extendedState.getVariables()).thenReturn(variables);
    when(runningFlows.getFlowChainId(anyString())).thenReturn("flowchainid");
    when(reactorEventFactory.createEvent(any(Map.class), any(Object.class))).thenReturn(new Event("dummy"));
    when(imageService.getImage(anyLong())).thenReturn(image);
    when(tracer.buildSpan(anyString())).thenReturn(spanBuilder);
    when(spanBuilder.addReference(anyString(), any())).thenReturn(spanBuilder);
    when(spanBuilder.ignoreActiveSpan()).thenReturn(spanBuilder);
    when(spanBuilder.start()).thenReturn(span);
    when(tracer.activateSpan(span)).thenReturn(scope);
    when(span.context()).thenReturn(spanContext);
    User user = new User();
    user.setUserId("horton@hortonworks.com");
    user.setUserCrn("testCrn");
    user.setUserName("Alma ur");
    Tenant tenant = new Tenant();
    tenant.setName("hortonworks");
    tenant.setId(1L);
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    workspace.setTenant(tenant);
    Stack stack = new Stack();
    stack.setCreator(user);
    stack.setWorkspace(workspace);
    stack.setId(1L);
    stack.setRegion("region");
    stack.setAvailabilityZone("az");
    stack.setResourceCrn("crn:cdp:datalake:us-west-1:tenant:cluster:1234");
    when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
    when(stackService.getById(anyLong())).thenReturn(stack);
    when(stackUtil.getCloudCredential(stack)).thenReturn(cloudCredential);
    variables.clear();
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) User(com.sequenceiq.cloudbreak.workspace.model.User) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) FlowEvent(com.sequenceiq.flow.core.FlowEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) ImageUpdateEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent) StackImageUpdateTriggerEvent(com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent) Map(java.util.Map) HashMap(java.util.HashMap) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Before(org.junit.Before)

Example 13 with Tenant

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

the class StackToTemplatePreparationObjectConverterTest method setUp.

@BeforeEach
public void setUp() throws IOException, TransactionService.TransactionExecutionException {
    MockitoAnnotations.initMocks(this);
    doAnswer(invocation -> {
        invocation.getArgument(0, Runnable.class).run();
        return null;
    }).when(transactionService).required(any(Runnable.class));
    User user = new User();
    user.setUserName("applebob@apple.com");
    user.setUserCrn("user-crn");
    Tenant tenant = new Tenant();
    tenant.setId(1L);
    tenant.setName("account");
    user.setTenant(tenant);
    when(stackMock.getCreator()).thenReturn(user);
    when(stackMock.getEnvironmentCrn()).thenReturn("env");
    when(stackMock.getCloudPlatform()).thenReturn(TEST_CLOUD_PLATFORM);
    when(stackMock.cloudPlatform()).thenReturn(TEST_CLOUD_PLATFORM);
    when(stackMock.getType()).thenReturn(StackType.DATALAKE);
    when(stackMock.getRegion()).thenReturn(REGION);
    when(stackMock.getAvailabilityZone()).thenReturn(AVAILABILITY_ZONE);
    when(stackMock.getName()).thenReturn("stackname");
    when(sourceCluster.getId()).thenReturn(TEST_CLUSTER_ID);
    when(cluster.getId()).thenReturn(TEST_CLUSTER_ID);
    when(instanceGroupMetadataCollector.collectMetadata(stackMock)).thenReturn(groupInstances);
    when(cluster.getBlueprint()).thenReturn(blueprint);
    when(blueprint.getBlueprintText()).thenReturn(TEST_BLUEPRINT_TEXT);
    when(blueprint.getStackVersion()).thenReturn("7.2.11");
    when(stackMock.getInputs()).thenReturn(stackInputs);
    when(stackInputs.get(StackInputs.class)).thenReturn(null);
    when(stackMock.getEnvironmentCrn()).thenReturn(TestConstants.CRN);
    when(stackMock.getCluster()).thenReturn(sourceCluster);
    when(sourceCluster.getCustomConfigurations()).thenReturn(customConfigurations);
    when(customConfigurations.getCrn()).thenReturn("test-custom-configs-crn");
    when(stackMock.getResourceCrn()).thenReturn("crn:cdp:datahub:us-west-1:account:cluster:cluster");
    when(clusterService.findOneWithCustomConfigurations(anyLong())).thenReturn(sourceCluster);
    when(accountTagClientService.list()).thenReturn(new HashMap<>());
    when(entitlementService.internalTenant(anyString())).thenReturn(true);
    when(loadBalancerConfigService.getLoadBalancerUserFacingFQDN(anyLong())).thenReturn(null);
    Credential credential = Credential.builder().crn("aCredentialCRN").attributes(new Json("")).build();
    DetailedEnvironmentResponse environmentResponse = DetailedEnvironmentResponse.builder().withIdBrokerMappingSource(IdBrokerMappingSource.MOCK).withCredential(new CredentialResponse()).withAdminGroupName(ADMIN_GROUP_NAME).withCrn(TestConstants.CRN).build();
    when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
    when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
    when(credentialConverter.convert(any(CredentialResponse.class))).thenReturn(credential);
    when(awsMockAccountMappingService.getGroupMappings(REGION, cloudCredential, ADMIN_GROUP_NAME)).thenReturn(MOCK_GROUP_MAPPINGS);
    when(awsMockAccountMappingService.getUserMappings(REGION, cloudCredential)).thenReturn(MOCK_USER_MAPPINGS);
    when(ldapConfigService.get(anyString(), anyString())).thenReturn(Optional.empty());
    when(clusterService.getById(anyLong())).thenReturn(cluster);
    when(customConfigurationsService.getByNameOrCrn(any(NameOrCrn.class))).thenReturn(customConfigurations);
    when(exposedServiceCollector.getAllKnoxExposed(any())).thenReturn(Set.of());
    when(resourceService.getAllByStackId(anyLong())).thenReturn(Collections.EMPTY_LIST);
    IdBroker idbroker = idBrokerConverterUtil.generateIdBrokerSignKeys(cluster);
    when(idBrokerService.getByCluster(any(Cluster.class))).thenReturn(idbroker);
    when(idBrokerService.save(any(IdBroker.class))).thenReturn(idbroker);
    when(grpcUmsClient.listServicePrincipalCloudIdentities(anyString(), anyString(), any(Optional.class))).thenReturn(Collections.EMPTY_LIST);
    when(dbCertificateProvider.getSslCertsFilePath()).thenReturn(SSL_CERTS_FILE_PATH);
    when(stackMock.getId()).thenReturn(1L);
    when(generalClusterConfigsProvider.generalClusterConfigs(any(Stack.class), any(Cluster.class))).thenReturn(new GeneralClusterConfigs());
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.cloudbreak.dto.credential.Credential) CloudbreakUser(com.sequenceiq.cloudbreak.common.user.CloudbreakUser) User(com.sequenceiq.cloudbreak.workspace.model.User) Optional(java.util.Optional) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) Json(com.sequenceiq.cloudbreak.common.json.Json) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with Tenant

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

the class UserProfileToUserProfileV4ResponseConverterTest method setUp.

@Before
public void setUp() {
    underTest = new UserProfileToUserProfileV4ResponseConverter();
    tenant = new Tenant();
    tenant.setName("someTenant");
    user = new User();
    user.setTenant(tenant);
    user.setUserId("c1234d47-4ec4-4ad2-91x2-d44kef15d67s");
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) User(com.sequenceiq.cloudbreak.workspace.model.User) Before(org.junit.Before)

Example 15 with Tenant

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

the class ClusterCreationEnvironmentValidatorTest method getStack.

private Stack getStack() {
    Stack stack = new Stack();
    stack.setRegion("region1");
    stack.setCloudPlatform("aws");
    Workspace workspace = new Workspace();
    workspace.setId(1L);
    Tenant tenant = new Tenant();
    tenant.setName("test-tenant-name");
    workspace.setTenant(tenant);
    stack.setWorkspace(workspace);
    stack.setEnvironmentCrn("");
    return stack;
}
Also used : Tenant(com.sequenceiq.cloudbreak.workspace.model.Tenant) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace)

Aggregations

Tenant (com.sequenceiq.cloudbreak.workspace.model.Tenant)18 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)12 User (com.sequenceiq.cloudbreak.workspace.model.User)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)5 CloudbreakUser (com.sequenceiq.cloudbreak.common.user.CloudbreakUser)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)3 Before (org.junit.Before)3 GatewayTopology (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology)2 Test (org.junit.Test)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 CrnUser (com.sequenceiq.cloudbreak.auth.CrnUser)1 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)1 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)1 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)1 StackImageUpdateTriggerEvent (com.sequenceiq.cloudbreak.core.flow2.event.StackImageUpdateTriggerEvent)1