Search in sources :

Example 21 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method checkInstancesHaveAllMandatoryPackageVersionOk.

@Test
public void checkInstancesHaveAllMandatoryPackageVersionOk() {
    when(instanceMetadataUpdater.collectInstancesWithMissingPackageVersions(anySet())).thenReturn(Collections.emptyMap());
    CheckResult result = underTest.checkInstancesHaveAllMandatoryPackageVersion(Collections.emptySet());
    assertEquals(EventStatus.OK, result.getStatus());
}
Also used : CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) Test(org.junit.Test)

Example 22 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionDifferentPackageVersionInImage.

@Test
public void compareImageAndInstancesMandatoryPackageVersionDifferentPackageVersionInImage() 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(Collections.singletonMap(packageName, "2"));
    Package aPackage = new Package();
    aPackage.setName(packageName);
    aPackage.setPrewarmed(true);
    when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
    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.FAILED, 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 23 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage.

@Test
public void compareImageAndInstancesMandatoryPackageVersionMissingPackageInImage() 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(Collections.emptyMap());
    Package aPackage = new Package();
    aPackage.setName(packageName);
    aPackage.setPrewarmed(true);
    when(instanceMetadataUpdater.getPackages()).thenReturn(Collections.singletonList(aPackage));
    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.FAILED, 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 24 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project cloudbreak by hortonworks.

the class PackageVersionCheckerTest method checkInstancesHaveMultiplePackageVersionsOk.

@Test
public void checkInstancesHaveMultiplePackageVersionsOk() {
    when(instanceMetadataUpdater.collectPackagesWithMultipleVersions(anySet())).thenReturn(Collections.emptyList());
    CheckResult result = underTest.checkInstancesHaveMultiplePackageVersions(Collections.emptySet());
    assertEquals(EventStatus.OK, result.getStatus());
}
Also used : CheckResult(com.sequenceiq.cloudbreak.core.flow2.CheckResult) Test(org.junit.Test)

Example 25 with CheckResult

use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project spring-cloud-gcp by GoogleCloudPlatform.

the class StackdriverTraceAutoConfiguration method stackdriverReporter.

@Bean(REPORTER_BEAN_NAME)
@ConditionalOnMissingBean(name = REPORTER_BEAN_NAME)
public Reporter<Span> stackdriverReporter(ReporterMetrics reporterMetrics, GcpTraceProperties trace, @Qualifier(SENDER_BEAN_NAME) Sender sender) {
    AsyncReporter<Span> asyncReporter = AsyncReporter.builder(sender).queuedMaxSpans(1000).messageTimeout(trace.getMessageTimeout(), TimeUnit.SECONDS).metrics(reporterMetrics).build(StackdriverEncoder.V2);
    CheckResult checkResult = asyncReporter.check();
    if (!checkResult.ok()) {
        LOGGER.warn("Error when performing Stackdriver AsyncReporter health check.", checkResult.error());
    }
    return asyncReporter;
}
Also used : CheckResult(zipkin2.CheckResult) Span(zipkin2.Span) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

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