Search in sources :

Example 1 with Package

use of com.sequenceiq.cloudbreak.service.cluster.Package in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionPrewarmedOk.

@Test
public void compareImageAndInstancesMandatoryPackageVersionPrewarmedOk() throws JsonProcessingException {
    String packageName = "package";
    Map<String, String> packageVersions = Collections.singletonMap(packageName, "1");
    when(statedImage.getImage()).thenReturn(image);
    when(image.isPrewarmed()).thenReturn(true);
    when(image.getPackageVersions()).thenReturn(packageVersions);
    Package aPackage = new Package();
    aPackage.setName(packageName);
    aPackage.setPrewarmed(true);
    when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
    when(instanceMetadataUpdater.isPackagesVersionEqual(anyString(), anyString())).thenReturn(true);
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setImage(new Json(new com.sequenceiq.cloudbreak.cloud.model.Image("image", Collections.emptyMap(), "os", "ostype", "catalogn", "catalogu", "id", packageVersions)));
    Set<InstanceMetaData> instanceMetaDataSet = Collections.singleton(instanceMetaData);
    CheckResult result = underTest.compareImageAndInstancesMandatoryPackageVersion(statedImage, instanceMetaDataSet);
    assertEquals(EventStatus.OK, result.getStatus());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Package(com.sequenceiq.cloudbreak.service.cluster.Package) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.Test)

Example 2 with Package

use of com.sequenceiq.cloudbreak.service.cluster.Package in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionDifferentPackageVersionInImage.

@Test
public void compareImageAndInstancesMandatoryPackageVersionDifferentPackageVersionInImage() throws JsonProcessingException {
    String packageName = "package";
    Map<String, String> packageVersions = Collections.singletonMap(packageName, "1");
    when(statedImage.getImage()).thenReturn(image);
    when(image.isPrewarmed()).thenReturn(true);
    when(image.getPackageVersions()).thenReturn(Collections.singletonMap(packageName, "2"));
    Package aPackage = new Package();
    aPackage.setName(packageName);
    aPackage.setPrewarmed(true);
    when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setImage(new Json(new com.sequenceiq.cloudbreak.cloud.model.Image("image", Collections.emptyMap(), "os", "ostype", "catalogn", "catalogu", "id", packageVersions)));
    Set<InstanceMetaData> instanceMetaDataSet = Collections.singleton(instanceMetaData);
    CheckResult result = underTest.compareImageAndInstancesMandatoryPackageVersion(statedImage, instanceMetaDataSet);
    assertEquals(EventStatus.FAILED, result.getStatus());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Package(com.sequenceiq.cloudbreak.service.cluster.Package) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.Test)

Example 3 with Package

use of com.sequenceiq.cloudbreak.service.cluster.Package in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage.

@Test
public void compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage() throws JsonProcessingException {
    String packageName = "package";
    Map<String, String> packageVersions = Collections.singletonMap(packageName, "1");
    when(statedImage.getImage()).thenReturn(image);
    when(image.isPrewarmed()).thenReturn(true);
    when(image.getPackageVersions()).thenReturn(Collections.emptyMap());
    Package aPackage = new Package();
    aPackage.setName(packageName);
    aPackage.setPrewarmed(true);
    when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setImage(new Json(new com.sequenceiq.cloudbreak.cloud.model.Image("image", Collections.emptyMap(), "os", "ostype", "catalogn", "catalogu", "id", packageVersions)));
    Set<InstanceMetaData> instanceMetaDataSet = Collections.singleton(instanceMetaData);
    CheckResult result = underTest.compareImageAndInstancesMandatoryPackageVersion(statedImage, instanceMetaDataSet);
    assertEquals(EventStatus.FAILED, result.getStatus());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Package(com.sequenceiq.cloudbreak.service.cluster.Package) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.Test)

Example 4 with Package

use of com.sequenceiq.cloudbreak.service.cluster.Package in project cloudbreak by hortonworks.

the class CmVersionQueryServiceTest method getOtherPackage.

private Package getOtherPackage() {
    Package otherPackage = new Package();
    otherPackage.setName("other");
    otherPackage.setPkg(Lists.newArrayList(generatePackageName("other-package", "(.*)-(.*)\\..*")));
    return otherPackage;
}
Also used : Package(com.sequenceiq.cloudbreak.service.cluster.Package)

Example 5 with Package

use of com.sequenceiq.cloudbreak.service.cluster.Package in project cloudbreak by hortonworks.

the class CmVersionQueryService method queryCmPackageInfo.

/**
 * Will query all CM related package versions (CM server and CM agent as well) from the nodes.
 * <p>
 *
 * @param stack The stack, with metadata to be able to build the client to query package versions
 * @return List of package info found in each host (map key is host fqdn)
 */
Map<String, List<PackageInfo>> queryCmPackageInfo(Stack stack) throws CloudbreakOrchestratorFailedException {
    GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    Map<String, Optional<String>> packageMap = packages.stream().filter(aPackage -> aPackage.getName().equals(ImagePackageVersion.CM.getKey())).map(Package::getPkg).flatMap(List::stream).collect(Collectors.toMap(PackageName::getName, packageName -> Optional.ofNullable(packageName.getPattern())));
    Map<String, List<PackageInfo>> fullPackageVersionsFromAllHosts = hostOrchestrator.getFullPackageVersionsFromAllHosts(gatewayConfig, packageMap);
    LOGGER.debug("Reading CM package info, found packages: " + fullPackageVersionsFromAllHosts);
    return fullPackageVersionsFromAllHosts;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Logger(org.slf4j.Logger) PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) ConfigurationProperties(org.springframework.boot.context.properties.ConfigurationProperties) Multimap(com.google.common.collect.Multimap) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) Inject(javax.inject.Inject) GatewayConfigService(com.sequenceiq.cloudbreak.service.GatewayConfigService) List(java.util.List) Component(org.springframework.stereotype.Component) HashMultimap(com.google.common.collect.HashMultimap) ImagePackageVersion(com.sequenceiq.cloudbreak.cloud.model.catalog.ImagePackageVersion) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Map(java.util.Map) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Package(com.sequenceiq.cloudbreak.service.cluster.Package) Optional(java.util.Optional) PackageName(com.sequenceiq.cloudbreak.service.cluster.PackageName) Optional(java.util.Optional) List(java.util.List) Package(com.sequenceiq.cloudbreak.service.cluster.Package) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

Package (com.sequenceiq.cloudbreak.service.cluster.Package)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 CheckResult (com.sequenceiq.cloudbreak.core.flow2.CheckResult)4 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)4 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)4 Test (org.junit.Test)4 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)2 Map (java.util.Map)2 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 ImagePackageVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.ImagePackageVersion)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 PackageInfo (com.sequenceiq.cloudbreak.common.model.PackageInfo)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)1 GatewayConfigService (com.sequenceiq.cloudbreak.service.GatewayConfigService)1 PackageName (com.sequenceiq.cloudbreak.service.cluster.PackageName)1