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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations