Skip to content

Commit

Permalink
fix clirr and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Mar 14, 2024
1 parent b35d956 commit da09fae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions google-cloud-bigtable/clirr-ignored-differences.xml
Expand Up @@ -190,6 +190,7 @@
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/bigtable/data/v2/stub/metrics/ErrorCountPerConnectionMetricTracker</className>
<method>*</method>
</difference>
<difference>
<differenceType>7012</differenceType>
Expand Down
Expand Up @@ -207,9 +207,9 @@ public void testBuiltinMetricsWithDefaultOTEL() throws Exception {
ProjectName name = ProjectName.of(testEnvRule.env().getProjectId());

// Interval is set in the monarch request when query metric timestamps.
// Restrict it to before we send to request and 1 minute after we send the request. If
// Restrict it to before we send to request and 3 minute after we send the request. If
// it turns out to be still flaky we can increase the filter range.
Instant end = Instant.now().plus(Duration.ofMinutes(1));
Instant end = Instant.now().plus(Duration.ofMinutes(3));
TimeInterval interval =
TimeInterval.newBuilder()
.setStartTime(Timestamps.fromMillis(start.toEpochMilli()))
Expand Down Expand Up @@ -271,9 +271,9 @@ public void testBuiltinMetricsWithCustomOTEL() throws Exception {
Collection<MetricData> fromMetricReader = metricReader.collectAllMetrics();

// Interval is set in the monarch request when query metric timestamps.
// Restrict it to before we send to request and 1 minute after we send the request. If
// Restrict it to before we send to request and 3 minute after we send the request. If
// it turns out to be still flaky we can increase the filter range.
Instant end = start.plus(Duration.ofMinutes(1));
Instant end = start.plus(Duration.ofMinutes(3));
TimeInterval interval =
TimeInterval.newBuilder()
.setStartTime(Timestamps.fromMillis(start.toEpochMilli()))
Expand Down
Expand Up @@ -42,6 +42,7 @@
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
Expand All @@ -50,7 +51,7 @@

public class UnaryMetricsMetadataIT {
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule();

private BigtableDataClient client;
private InMemoryMetricReader metricReader;

Expand Down Expand Up @@ -147,14 +148,16 @@ public void testFailure() throws Exception {
}
}

List<MetricData> metrics =
metricReader.collectAllMetrics().stream()
.filter(m -> m.getName().contains(BuiltinMetricsConstants.OPERATION_LATENCIES_NAME))
.collect(Collectors.toList());
MetricData metricData = null;
for (MetricData md : metricReader.collectAllMetrics()) {
if (md.getName().contains(BuiltinMetricsConstants.OPERATION_LATENCIES_NAME)) {
metricData = md;
break;
}
}

assertThat(metrics.size()).isEqualTo(1);
assertThat(metricData).isNotNull();

MetricData metricData = metrics.get(0);
List<PointData> pointData = new ArrayList<>(metricData.getData().getPoints());
List<String> clusterAttributes =
pointData.stream()
Expand Down

0 comments on commit da09fae

Please sign in to comment.