use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin-azure by openzipkin.
the class EventHubCollectorTest method check_failsOnRuntimeException_registering.
@Test
public void check_failsOnRuntimeException_registering() {
RuntimeException exception = new RuntimeException();
EventHubCollector collector = new EventHubCollector(new LazyFuture() {
@Override
protected Future<?> compute() {
throw exception;
}
});
CheckResult result = collector.check();
assertThat(result.error()).isEqualTo(exception);
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class MaintenanceModeValidationService method validateImageCatalog.
public List<Warning> validateImageCatalog(Stack stack) {
List<Warning> warnings = new ArrayList<>();
try {
Image image = componentConfigProviderService.getImage(stack.getId());
StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId());
if (!image.getPackageVersions().isEmpty()) {
CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage);
if (checkResult.getStatus().equals(EventStatus.FAILED)) {
warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage()));
}
}
} catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) {
throw new CloudbreakServiceException("Image info could not be validated!", e);
}
return warnings;
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class StackImageUpdateActions method checkPackageVersions.
@Bean(name = "CHECK_PACKAGE_VERSIONS_STATE")
public AbstractStackImageUpdateAction<?> checkPackageVersions() {
return new AbstractStackImageUpdateAction<>(ImageUpdateEvent.class) {
@Override
protected void doExecute(StackContext context, ImageUpdateEvent payload, Map<Object, Object> variables) {
CheckResult checkResult = getStackImageUpdateService().checkPackageVersions(context.getStack(), payload.getImage());
if (checkResult.getStatus() == EventStatus.FAILED) {
LOGGER.info("Check package versions failed: {}", checkResult);
}
sendEvent(context, new ImageUpdateEvent(StackImageUpdateEvent.CHECK_PACKAGE_VERSIONS_FINISHED_EVENT.event(), context.getStack().getId(), payload.getImage()));
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionBaseOk.
@Test
public void compareImageAndInstancesMandatoryPackageVersionBaseOk() throws JsonProcessingException {
String packageName = "package";
Map<String, String> packageVersions = Collections.singletonMap(packageName, "1");
when(statedImage.getImage()).thenReturn(image);
when(image.isPrewarmed()).thenReturn(false);
when(image.getPackageVersions()).thenReturn(packageVersions);
Package aPackage = new Package();
aPackage.setName(packageName);
aPackage.setPrewarmed(false);
Package prewarmedPackage = new Package();
prewarmedPackage.setName(packageName);
prewarmedPackage.setPrewarmed(true);
when(instanceMetadataUpdater.getPackages()).thenReturn(Lists.newArrayList(aPackage, prewarmedPackage));
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.core.flow2.CheckResult in project cloudbreak by hortonworks.
the class PackageVersionCheckerTest method checkInstancesHaveMultiplePackageVersionsNok.
@Test
public void checkInstancesHaveMultiplePackageVersionsNok() {
when(instanceMetadataUpdater.collectPackagesWithMultipleVersions(anySet())).thenReturn(Collections.singletonList("package"));
CheckResult result = underTest.checkInstancesHaveMultiplePackageVersions(Collections.emptySet());
assertEquals(EventStatus.FAILED, result.getStatus());
}
Aggregations