Search in sources :

Example 11 with ListTimeSeriesPagedResponse

use of com.google.bigtable.repackaged.com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse 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 12 with ListTimeSeriesPagedResponse

use of com.google.bigtable.repackaged.com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse 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)

Example 13 with ListTimeSeriesPagedResponse

use of com.google.bigtable.repackaged.com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse in project java-monitoring by googleapis.

the class MetricServiceClientTest method listTimeSeriesTest3.

@Test
public void listTimeSeriesTest3() throws Exception {
    TimeSeries responsesElement = TimeSeries.newBuilder().build();
    ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken("").addAllTimeSeries(Arrays.asList(responsesElement)).build();
    mockMetricService.addResponse(expectedResponse);
    ProjectName name = ProjectName.of("[PROJECT]");
    String filter = "filter-1274492040";
    TimeInterval interval = TimeInterval.newBuilder().build();
    ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
    ListTimeSeriesPagedResponse pagedListResponse = client.listTimeSeries(name, filter, interval, view);
    List<TimeSeries> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockMetricService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListTimeSeriesRequest actualRequest = ((ListTimeSeriesRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(filter, actualRequest.getFilter());
    Assert.assertEquals(interval, actualRequest.getInterval());
    Assert.assertEquals(view, actualRequest.getView());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) AbstractMessage(com.google.protobuf.AbstractMessage) TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse) ListTimeSeriesRequest(com.google.monitoring.v3.ListTimeSeriesRequest) Test(org.junit.Test)

Aggregations

ListTimeSeriesPagedResponse (com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse)12 TimeSeries (com.google.monitoring.v3.TimeSeries)11 ListTimeSeriesRequest (com.google.monitoring.v3.ListTimeSeriesRequest)9 ProjectName (com.google.monitoring.v3.ProjectName)8 TimeInterval (com.google.monitoring.v3.TimeInterval)8 ListTimeSeriesResponse (com.google.monitoring.v3.ListTimeSeriesResponse)7 Test (org.junit.Test)5 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ListTimeSeriesPage (com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPage)3 Test (org.junit.jupiter.api.Test)3 Aggregation (com.google.monitoring.v3.Aggregation)2 BigtableWorkloadOptions (bigtable.WorkloadGenerator.BigtableWorkloadOptions)1 MetricDescriptor (com.google.api.MetricDescriptor)1 Job (com.google.api.services.dataflow.model.Job)1 MetricServiceClient (com.google.bigtable.repackaged.com.google.cloud.monitoring.v3.MetricServiceClient)1 ListTimeSeriesPagedResponse (com.google.bigtable.repackaged.com.google.cloud.monitoring.v3.MetricServiceClient.ListTimeSeriesPagedResponse)1 ListTimeSeriesRequest (com.google.bigtable.repackaged.com.google.monitoring.v3.ListTimeSeriesRequest)1 ProjectName (com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName)1 TimeInterval (com.google.bigtable.repackaged.com.google.monitoring.v3.TimeInterval)1