Search in sources :

Example 1 with ListTimeSeriesPage

use of com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage in project spring-cloud-gcp by GoogleCloudPlatform.

the class HealthTrackerImplTests method noMessagesOverThresholdNoProcessing.

@Test
void noMessagesOverThresholdNoProcessing() throws InterruptedException {
    LockSupport.parkNanos(1001 * 1000000);
    ListTimeSeriesPagedResponse listTimeSeriesPagedResponse = mock(ListTimeSeriesPagedResponse.class);
    TimeSeries timeSeries = TimeSeries.newBuilder().addPoints(Point.newBuilder().setValue(TypedValue.newBuilder().setInt64Value(100).build()).build()).build();
    ListTimeSeriesResponse timeSeriesResponse = ListTimeSeriesResponse.newBuilder().addTimeSeries(timeSeries).build();
    ListTimeSeriesPage listTimeSeriesPage = mock(ListTimeSeriesPage.class);
    when(listTimeSeriesPagedResponse.getPage()).thenReturn(listTimeSeriesPage);
    when(listTimeSeriesPage.getResponse()).thenReturn(timeSeriesResponse);
    doReturn(listTimeSeriesPagedResponse).when(metricServiceClient).listTimeSeries(any(ProjectName.class), anyString(), any(), any());
    long messagesOverThreshold = healthTracker.messagesOverThreshold();
    assertThat(messagesOverThreshold).isNegative();
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesPage(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse) Test(org.junit.jupiter.api.Test)

Example 2 with ListTimeSeriesPage

use of com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage in project spring-cloud-gcp by GoogleCloudPlatform.

the class HealthTrackerImplTests method messagesOverThresholdNoProcessing.

@Test
void messagesOverThresholdNoProcessing() throws InterruptedException {
    LockSupport.parkNanos(1001 * 1000000);
    ListTimeSeriesPagedResponse listTimeSeriesPagedResponse = mock(ListTimeSeriesPagedResponse.class);
    TimeSeries timeSeries = TimeSeries.newBuilder().addPoints(Point.newBuilder().setValue(TypedValue.newBuilder().setInt64Value(201).build()).build()).build();
    ListTimeSeriesResponse timeSeriesResponse = ListTimeSeriesResponse.newBuilder().addTimeSeries(timeSeries).build();
    ListTimeSeriesPage listTimeSeriesPage = mock(ListTimeSeriesPage.class);
    when(listTimeSeriesPagedResponse.getPage()).thenReturn(listTimeSeriesPage);
    when(listTimeSeriesPage.getResponse()).thenReturn(timeSeriesResponse);
    doReturn(listTimeSeriesPagedResponse).when(metricServiceClient).listTimeSeries(any(ProjectName.class), anyString(), any(), any());
    long messagesOverThreshold = healthTracker.messagesOverThreshold();
    assertThat(messagesOverThreshold).isEqualTo(1);
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesPage(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse) Test(org.junit.jupiter.api.Test)

Example 3 with ListTimeSeriesPage

use of com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage in project spring-cloud-gcp by GoogleCloudPlatform.

the class HealthTrackerImplTests method noMessagesOverThresholdNoProcessingNoBacklogMessages.

@Test
void noMessagesOverThresholdNoProcessingNoBacklogMessages() throws InterruptedException {
    LockSupport.parkNanos(1001 * 1000000);
    ListTimeSeriesPagedResponse listTimeSeriesPagedResponse = mock(ListTimeSeriesPagedResponse.class);
    ListTimeSeriesResponse timeSeriesResponse = ListTimeSeriesResponse.newBuilder().build();
    ListTimeSeriesPage listTimeSeriesPage = mock(ListTimeSeriesPage.class);
    when(listTimeSeriesPagedResponse.getPage()).thenReturn(listTimeSeriesPage);
    when(listTimeSeriesPage.getResponse()).thenReturn(timeSeriesResponse);
    doReturn(listTimeSeriesPagedResponse).when(metricServiceClient).listTimeSeries(any(ProjectName.class), anyString(), any(), any());
    long messagesOverThreshold = healthTracker.messagesOverThreshold();
    assertThat(messagesOverThreshold).isZero();
}
Also used : ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesPage(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ListTimeSeriesPage (com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage)3 ListTimeSeriesPagedResponse (com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse)3 ListTimeSeriesResponse (com.google.monitoring.v3.ListTimeSeriesResponse)3 ProjectName (com.google.monitoring.v3.ProjectName)3 Test (org.junit.jupiter.api.Test)3 TimeSeries (com.google.monitoring.v3.TimeSeries)2