use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin-gcp by openzipkin.
the class StackdriverSpanConsumerTest method verifyCheckReturnsFailureWhenServiceFailsForUnknownReason.
@Test
public void verifyCheckReturnsFailureWhenServiceFailsForUnknownReason() {
onClientCall(observer -> {
observer.onError(new RuntimeException("oh no"));
});
CheckResult result = storage.check();
assertThat(result.ok()).isFalse();
assertThat(result.error()).isInstanceOf(ArmeriaStatusException.class).satisfies(e -> assertThat(((ArmeriaStatusException) e).getCode()).isEqualTo(Status.UNKNOWN.getCode().value()));
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class StackImageUpdateService method checkPackageVersions.
public CheckResult checkPackageVersions(Stack stack, StatedImage newImage) {
Set<InstanceMetaData> instanceMetaDataSet = stack.getNotDeletedAndNotZombieInstanceMetaDataSet();
CheckResult instanceHaveMultipleVersionResult = packageVersionChecker.checkInstancesHaveMultiplePackageVersions(instanceMetaDataSet);
if (instanceHaveMultipleVersionResult.getStatus() == EventStatus.FAILED) {
LOGGER.debug("Check packages - Instances do have multiple package versions: {}", instanceHaveMultipleVersionResult);
return instanceHaveMultipleVersionResult;
}
CheckResult instancesHaveAllMandatoryPackageVersionResult = packageVersionChecker.checkInstancesHaveAllMandatoryPackageVersion(instanceMetaDataSet);
if (instancesHaveAllMandatoryPackageVersionResult.getStatus() == EventStatus.FAILED) {
LOGGER.debug("Check packages - Instances are missing one or more package versions: {}", instancesHaveAllMandatoryPackageVersionResult);
return instancesHaveAllMandatoryPackageVersionResult;
}
CheckResult compareImageAndInstancesMandatoryPackageVersion = packageVersionChecker.compareImageAndInstancesMandatoryPackageVersion(newImage, instanceMetaDataSet);
if (compareImageAndInstancesMandatoryPackageVersion.getStatus() == EventStatus.FAILED) {
LOGGER.debug("Check packages - Image and instances mandatory packages do differ: {}", compareImageAndInstancesMandatoryPackageVersion);
return compareImageAndInstancesMandatoryPackageVersion;
}
return CheckResult.ok();
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class StackImageUpdateService method isValidImage.
public boolean isValidImage(Stack stack, String newImageId, String imageCatalogName, String imageCatalogUrl) {
if (isCbVersionOk(stack)) {
try {
Image currentImage = stackImageService.getCurrentImage(stack);
StatedImage newImage = getNewImage(newImageId, imageCatalogName, imageCatalogUrl, currentImage);
boolean cloudPlatformMatches = isCloudPlatformMatches(stack, newImage);
boolean osVersionsMatch = isOsVersionsMatch(currentImage, newImage);
boolean stackMatchIfPrewarmed = isStackMatchIfPrewarmed(newImage);
CheckResult checkPackageVersionsStatus = checkPackageVersions(stack, newImage);
boolean aggregatedValidationResult = cloudPlatformMatches && osVersionsMatch && stackMatchIfPrewarmed;
if (!aggregatedValidationResult) {
LOGGER.info("Image validation for {}:\n " + "Valid platform? {}\n " + "Valid os? {}\n " + "Valid stack (prewarmed only)? {}", newImageId, cloudPlatformMatches, osVersionsMatch, stackMatchIfPrewarmed);
}
if (checkPackageVersionsStatus.getStatus() != EventStatus.OK) {
LOGGER.info("Image validation for {}:\n " + "Valid package versions? {}", newImageId, checkPackageVersionsStatus);
}
return aggregatedValidationResult;
} catch (CloudbreakImageNotFoundException e) {
LOGGER.debug("Cloudbreak Image not found", e);
return false;
} catch (CloudbreakImageCatalogException e) {
LOGGER.debug("Cloudbreak Image catalog error", e);
return false;
}
}
return false;
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class PackageVersionCheckerTest method checkInstancesHaveAllMandatoryPackageVersionNok.
@Test
public void checkInstancesHaveAllMandatoryPackageVersionNok() {
when(instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(anySet())).thenReturn(Collections.singletonMap("instance", Collections.singletonList("package")));
CheckResult result = underTest.checkInstancesHaveAllMandatoryPackageVersion(Collections.emptySet());
assertEquals(EventStatus.FAILED, result.getStatus());
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult 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());
}
Aggregations