Search in sources :

Example 16 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class KnoxGatewayConfigProviderTest method roleConfigsWithGateway.

@Test
public void roleConfigsWithGateway() {
    GatewayTopology topology = new GatewayTopology();
    topology.setTopologyName("my-topology");
    topology.setExposedServices(Json.silent(new ExposedServices()));
    Gateway gateway = new Gateway();
    gateway.setKnoxMasterSecret("admin");
    gateway.setPath("/a/b/c");
    gateway.setTopologies(Set.of(topology));
    GeneralClusterConfigs generalClusterConfigs = new GeneralClusterConfigs();
    generalClusterConfigs.setAccountId(Optional.of("1234"));
    IdBroker idBroker = new IdBroker();
    idBroker.setMasterSecret("supersecret");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    BlueprintView blueprintView = new BlueprintView("text", "7.2.11", "CDH", blueprintTextProcessor);
    TemplatePreparationObject source = Builder.builder().withGateway(gateway, "key", new HashSet<>()).withGeneralClusterConfigs(generalClusterConfigs).withBlueprintView(blueprintView).withVirtualGroupView(new VirtualGroupRequest(TestConstants.CRN, "")).withProductDetails(new ClouderaManagerRepo().withVersion("7.4.2"), List.of(new ClouderaManagerProduct().withVersion("7.2.10").withName("CDH"))).withIdBroker(idBroker).build();
    when(virtualGroupService.createOrGetVirtualGroup(source.getVirtualGroupRequest(), UmsVirtualGroupRight.KNOX_ADMIN)).thenReturn("");
    when(entitlementService.isOjdbcTokenDhOneHour(anyString())).thenReturn(true);
    assertEquals(List.of(config("idbroker_master_secret", "supersecret"), config("idbroker_gateway_knox_admin_groups", ""), config("idbroker_gateway_signing_keystore_name", "signing.jks"), config("idbroker_gateway_signing_keystore_type", "JKS"), config("idbroker_gateway_signing_key_alias", "signing-identity")), underTest.getRoleConfigs(KnoxRoles.IDBROKER, source));
    assertEquals(List.of(config("gateway_master_secret", gateway.getKnoxMasterSecret()), config("gateway_default_topology_name", gateway.getTopologies().iterator().next().getTopologyName()), config("gateway_knox_admin_groups", ""), config("gateway_auto_discovery_enabled", "false"), config("gateway_path", gateway.getPath()), config("gateway_signing_keystore_name", "signing.jks"), config("gateway_signing_keystore_type", "JKS"), config("gateway_signing_key_alias", "signing-identity"), config("gateway_dispatch_whitelist", "^*.*$"), config("gateway_service_tokenstate_impl", "org.apache.knox.gateway.services.token.impl.JDBCTokenStateService")), ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.getRoleConfigs(KnoxRoles.KNOX_GATEWAY, source)));
    assertEquals(List.of(), underTest.getRoleConfigs("NAMENODE", source));
}
Also used : TemplatePreparationObject(com.sequenceiq.cloudbreak.template.TemplatePreparationObject) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) GeneralClusterConfigs(com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs) VirtualGroupRequest(com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) BlueprintTextProcessor(com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor) BlueprintView(com.sequenceiq.cloudbreak.template.views.BlueprintView) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) GatewayTopology(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.GatewayTopology) IdBroker(com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker) Test(org.junit.Test)

Example 17 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmInstalledComponentFinderServiceTest method testFindParcelComponents.

@Test
void testFindParcelComponents() {
    Set<Image> candidateImages = Set.of(mock(Image.class));
    Set<ClouderaManagerProduct> candidateCmProduct = Set.of(new ClouderaManagerProduct());
    Set<ParcelInfo> queriedParcelInfo = Set.of(new ParcelInfo("", ""));
    Set<ClouderaManagerProduct> chosenClouderaManagerProducts = Set.of(new ClouderaManagerProduct());
    when(stack.isDatalake()).thenReturn(true);
    when(imageReaderService.getParcels(candidateImages, true)).thenReturn(candidateCmProduct);
    when(cmInfoRetriever.queryActiveParcels(eq(stack))).thenReturn(queriedParcelInfo);
    when(cmProductChooserService.chooseParcelProduct(queriedParcelInfo, candidateCmProduct)).thenReturn(chosenClouderaManagerProducts);
    CmParcelSyncOperationResult cmParcelSyncOperationResult = underTest.findParcelComponents(stack, candidateImages);
    assertThat(cmParcelSyncOperationResult.getActiveParcels(), hasSize(1));
    verify(imageReaderService).getParcels(candidateImages, true);
    verify(cmInfoRetriever).queryActiveParcels(stack);
    verify(cmProductChooserService).chooseParcelProduct(queriedParcelInfo, candidateCmProduct);
}
Also used : CmParcelSyncOperationResult(com.sequenceiq.cloudbreak.service.upgrade.sync.operationresult.CmParcelSyncOperationResult) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) Test(org.junit.jupiter.api.Test)

Example 18 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmProductChooserServiceTest method testChooseParcelProductWhenDifferentNameButSameVersionThenEmptyResult.

@Test
void testChooseParcelProductWhenDifferentNameButSameVersionThenEmptyResult() {
    Set<ParcelInfo> activeParcels = Set.of(new ParcelInfo(PARCEL_NAME_2, PARCEL_VERSION_1));
    Set<ClouderaManagerProduct> candidateProducts = Set.of(new ClouderaManagerProduct().withName(PARCEL_NAME_1).withVersion(PARCEL_VERSION_1));
    Set<ClouderaManagerProduct> foundProducts = underTest.chooseParcelProduct(activeParcels, candidateProducts);
    assertThat(foundProducts, hasSize(0));
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test)

Example 19 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmProductChooserServiceTest method testChooseParcelProductWhenMultipleMatchingNameAndVersionThenReturnsAllMatches.

@Test
void testChooseParcelProductWhenMultipleMatchingNameAndVersionThenReturnsAllMatches() {
    Set<ParcelInfo> activeParcels = Set.of(new ParcelInfo(PARCEL_NAME_1, PARCEL_VERSION_1), new ParcelInfo(PARCEL_NAME_2, PARCEL_VERSION_2));
    Set<ClouderaManagerProduct> candidateProducts = Set.of(new ClouderaManagerProduct().withName(PARCEL_NAME_1).withVersion(PARCEL_VERSION_1), new ClouderaManagerProduct().withName(PARCEL_NAME_2).withVersion(PARCEL_VERSION_2));
    Set<ClouderaManagerProduct> foundProducts = underTest.chooseParcelProduct(activeParcels, candidateProducts);
    assertThat(foundProducts, hasSize(2));
    List<ClouderaManagerProduct> foundProductList = new ArrayList<>(foundProducts);
    foundProductList.sort(Comparator.comparing(ClouderaManagerProduct::getName));
    assertEquals(PARCEL_NAME_1, foundProductList.get(0).getName());
    assertEquals(PARCEL_VERSION_1, foundProductList.get(0).getVersion());
    assertEquals(PARCEL_NAME_2, foundProductList.get(1).getName());
    assertEquals(PARCEL_VERSION_2, foundProductList.get(1).getVersion());
}
Also used : ArrayList(java.util.ArrayList) ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test)

Example 20 with ClouderaManagerProduct

use of com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct in project cloudbreak by hortonworks.

the class CmProductChooserServiceTest method testChooseParcelProductWhenMatchingNameAndVersionThenReturns.

@Test
void testChooseParcelProductWhenMatchingNameAndVersionThenReturns() {
    Set<ParcelInfo> activeParcels = Set.of(new ParcelInfo(PARCEL_NAME_1, PARCEL_VERSION_1));
    Set<ClouderaManagerProduct> candidateProducts = Set.of(new ClouderaManagerProduct().withName(PARCEL_NAME_1).withVersion(PARCEL_VERSION_1));
    Set<ClouderaManagerProduct> foundProducts = underTest.chooseParcelProduct(activeParcels, candidateProducts);
    assertThat(foundProducts, hasSize(1));
    ClouderaManagerProduct foundProduct = foundProducts.iterator().next();
    assertEquals(PARCEL_NAME_1, foundProduct.getName());
    assertEquals(PARCEL_VERSION_1, foundProduct.getVersion());
}
Also used : ParcelInfo(com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo) ClouderaManagerProduct(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct) Test(org.junit.jupiter.api.Test)

Aggregations

ClouderaManagerProduct (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerProduct)91 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)23 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)20 ClouderaManagerRepo (com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo)14 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)10 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)9 ClusterComponent (com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent)9 ParcelInfo (com.sequenceiq.cloudbreak.service.upgrade.sync.common.ParcelInfo)9 HashSet (java.util.HashSet)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 BlueprintView (com.sequenceiq.cloudbreak.template.views.BlueprintView)7 VirtualGroupRequest (com.sequenceiq.cloudbreak.auth.altus.VirtualGroupRequest)6 IdBroker (com.sequenceiq.cloudbreak.domain.stack.cluster.IdBroker)6 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)6 BlueprintTextProcessor (com.sequenceiq.cloudbreak.template.processor.BlueprintTextProcessor)6 Gateway (com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway)5