use of com.sequenceiq.cloudbreak.common.model.PackageInfo in project cloudbreak by hortonworks.
the class CmVersionQueryServiceTest method testWhenPackagesAreValidThenValidateConsistencyShouldPass.
@Test
void testWhenPackagesAreValidThenValidateConsistencyShouldPass() {
Map<String, List<PackageInfo>> hostPackageMap = Maps.newHashMap();
hostPackageMap.put(HOST_1, getPackageInfoList(true));
hostPackageMap.put(HOST_2, getPackageInfoList(true));
PackageInfo packageInfo = underTest.checkCmPackageInfoConsistency(hostPackageMap);
Assertions.assertEquals("1", packageInfo.getVersion());
Assertions.assertEquals("1000", packageInfo.getBuildNumber());
Assertions.assertEquals("1-1000", packageInfo.getFullVersion());
}
use of com.sequenceiq.cloudbreak.common.model.PackageInfo in project cloudbreak by hortonworks.
the class CmVersionQueryServiceTest method getPackageInfoList.
private List<PackageInfo> getPackageInfoList(boolean matchVersions) {
List<PackageInfo> packageMap = new ArrayList<>();
packageMap.add(getPackageInfo(CLOUDERA_MANAGER_AGENT, A_VERSION, A_BUILD_NUMBER));
PackageInfo server = null;
if (matchVersions) {
server = getPackageInfo(CLOUDERA_MANAGER_SERVER, A_VERSION, A_BUILD_NUMBER);
} else {
server = getPackageInfo(CLOUDERA_MANAGER_SERVER, OTHER_VERSION, OTHER_BUILD_NUMBER);
}
packageMap.add(server);
return packageMap;
}
use of com.sequenceiq.cloudbreak.common.model.PackageInfo in project cloudbreak by hortonworks.
the class SaltStates method addToVersionList.
private static void addToVersionList(Map<String, List<PackageInfo>> packageVersions, Entry<String, PackageInfo> entry) {
String hostKey = entry.getKey();
PackageInfo packageInfoValue = entry.getValue();
if (packageVersions.containsKey(hostKey)) {
ArrayList<PackageInfo> packageInfos = new ArrayList<>(packageVersions.get(hostKey));
packageInfos.add(packageInfoValue);
packageVersions.put(hostKey, packageInfos);
} else {
packageVersions.put(hostKey, List.of(packageInfoValue));
}
}
use of com.sequenceiq.cloudbreak.common.model.PackageInfo in project cloudbreak by hortonworks.
the class SaltStates method parseVersion.
private static PackageInfo parseVersion(String packageName, String versionCommandOutput, Optional<String> pattern) {
PackageInfo packageInfo = new PackageInfo();
packageInfo.setName(packageName);
packageInfo.setVersion(versionCommandOutput);
if (pattern.isPresent()) {
Matcher matcher = Pattern.compile(pattern.get()).matcher(versionCommandOutput);
if (matcher.matches()) {
packageInfo.setVersion(matcher.group(1));
if (matcher.groupCount() == 2) {
packageInfo.setBuildNumber(matcher.group(2));
}
}
}
LOGGER.debug("Package version parsed as {}", packageInfo);
return packageInfo;
}
use of com.sequenceiq.cloudbreak.common.model.PackageInfo in project cloudbreak by hortonworks.
the class SaltStates method getSinglePackageVersion.
private static Map<String, PackageInfo> getSinglePackageVersion(SaltConnector sc, String singlePackage, Optional<String> versionPattern) {
PackageVersionResponse packageVersionResponse = measure(() -> sc.run(Glob.ALL, "pkg.version", LOCAL, PackageVersionResponse.class, singlePackage), LOGGER, "Get package version took {}ms for package [{}] with pattern [{}]", singlePackage, versionPattern);
Map<String, String> packageVersionsMap = CollectionUtils.isEmpty(packageVersionResponse.getResult()) ? new HashMap<>() : packageVersionResponse.getResult().get(0);
Map<String, PackageInfo> result = new HashMap<>();
for (Entry<String, String> e : packageVersionsMap.entrySet()) {
result.put(e.getKey(), parseVersion(singlePackage, e.getValue(), versionPattern));
}
return result;
}
Aggregations