diff --git a/storage/integration_test.go b/storage/integration_test.go index bc15358dcfe4..d46303209c2b 100644 --- a/storage/integration_test.go +++ b/storage/integration_test.go @@ -636,37 +636,51 @@ func TestIntegration_DoNotDetectDirectConnectivityWhenDisabled(t *testing.T) { } func TestIntegration_MetricsEnablement(t *testing.T) { - ctx := skipHTTP("grpc only test") - ctx = skipExtraReadAPIs(ctx, "no reads in test") + var ( + ctx = context.Background() + prefix = grpcTestPrefix + newBucketName = prefix + uidSpace.New() + ) + mr := metric.NewManualReader() - multiTransportTest(ctx, t, func(t *testing.T, ctx context.Context, bucket string, prefix string, client *Client) { - it := client.Bucket(bucket).Objects(ctx, nil) - _, err := it.Next() - if err != iterator.Done { - t.Errorf("Objects.Next: expected iterator.Done got %v", err) - } - rm := metricdata.ResourceMetrics{} - if err := mr.Collect(ctx, &rm); err != nil { - t.Fatalf("ManualReader.Collect: %v", err) - } - metricCheck := map[string]bool{ - "grpc.client.attempt.started": false, - "grpc.client.attempt.duration": false, - "grpc.client.attempt.sent_total_compressed_message_size": false, - "grpc.client.attempt.rcvd_total_compressed_message_size": false, - "grpc.client.call.duration": false, - } - for _, sm := range rm.ScopeMetrics { - for _, m := range sm.Metrics { - metricCheck[m.Name] = true - } + client := testConfigGRPC(ctx, t, withTestMetricReader(mr)) + + b := client.Bucket(newBucketName) + + if err := b.Create(ctx, testutil.ProjID(), nil); err != nil { + t.Fatalf("BucketHandle.Create(%q): %v", newBucketName, err) + } + + it := b.Objects(ctx, nil) + _, err := it.Next() + if err != iterator.Done { + t.Errorf("Objects.Next: expected iterator.Done got %v", err) + } + rm := metricdata.ResourceMetrics{} + if err := mr.Collect(ctx, &rm); err != nil { + t.Fatalf("ManualReader.Collect: %v", err) + } + metricCheck := map[string]bool{ + "grpc.client.attempt.started": false, + "grpc.client.attempt.duration": false, + "grpc.client.attempt.sent_total_compressed_message_size": false, + "grpc.client.attempt.rcvd_total_compressed_message_size": false, + "grpc.client.call.duration": false, + } + for _, sm := range rm.ScopeMetrics { + for _, m := range sm.Metrics { + metricCheck[m.Name] = true } - for k, v := range metricCheck { - if !v { - t.Errorf("metric %v not found", k) - } + } + for k, v := range metricCheck { + if !v { + t.Errorf("metric %v not found", k) } - }, withTestMetricReader(mr)) + } + + if err := mr.Shutdown(ctx); err != nil { + t.Fatalf("manual reader shutdown: %v", err) + } } func TestIntegration_MetricsEnablementInGCE(t *testing.T) {