Search in sources :

Example 26 with CheckResult

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);
}
Also used : CheckResult(zipkin2.CheckResult) Future(java.util.concurrent.Future) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test)

Example 27 with CheckResult

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;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArrayList(java.util.ArrayList) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)

Example 28 with CheckResult

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()));
        }
    };
}
Also used : StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) Map(java.util.Map) ImageUpdateEvent(com.sequenceiq.cloudbreak.reactor.api.event.stack.ImageUpdateEvent) Bean(org.springframework.context.annotation.Bean)

Example 29 with CheckResult

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());
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Package(com.sequenceiq.cloudbreak.service.cluster.Package) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.catalog.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) Test(org.junit.Test)

Example 30 with CheckResult

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());
}
Also used : CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) Test(org.junit.Test)

Aggregations

CheckResult (zipkin2.CheckResult)30 Test (org.junit.Test)24 CheckResult (com.sequenceiq.cloudbreak.core.flow2.CheckResult)12 Test (org.junit.jupiter.api.Test)7 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)6 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)5 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)4 Json (com.sequenceiq.cloudbreak.common.json.Json)4 Package (com.sequenceiq.cloudbreak.service.cluster.Package)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)4 Bean (org.springframework.context.annotation.Bean)3 Span (zipkin2.Span)3 ArmeriaStatusException (com.linecorp.armeria.common.grpc.protocol.ArmeriaStatusException)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 Future (java.util.concurrent.Future)2