Search in sources :

Example 1 with PackageInfo

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());
}
Also used : PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 2 with PackageInfo

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;
}
Also used : PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) ArrayList(java.util.ArrayList)

Example 3 with PackageInfo

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));
    }
}
Also used : PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo) ArrayList(java.util.ArrayList)

Example 4 with PackageInfo

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;
}
Also used : Matcher(java.util.regex.Matcher) PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo)

Example 5 with 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;
}
Also used : PackageVersionResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.PackageVersionResponse) HashMap(java.util.HashMap) PackageInfo(com.sequenceiq.cloudbreak.common.model.PackageInfo)

Aggregations

PackageInfo (com.sequenceiq.cloudbreak.common.model.PackageInfo)10 ArrayList (java.util.ArrayList)5 List (java.util.List)5 PackageVersionResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.PackageVersionResponse)3 HashMap (java.util.HashMap)3 Optional (java.util.Optional)3 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)2 HostList (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList)2 Map (java.util.Map)2 Test (org.junit.Test)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 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 GatewayConfigService (com.sequenceiq.cloudbreak.service.GatewayConfigService)1 Package (com.sequenceiq.cloudbreak.service.cluster.Package)1 PackageName (com.sequenceiq.cloudbreak.service.cluster.PackageName)1