Skip to content

Commit

Permalink
test(spanner): move testing helper to a test (#5327)
Browse files Browse the repository at this point in the history
Fixes: #5326
  • Loading branch information
codyoss committed Jan 11, 2022
1 parent c47ffb2 commit 88cacd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 13 additions & 0 deletions spanner/integration_test.go
Expand Up @@ -37,9 +37,11 @@ import (
"cloud.google.com/go/civil"
"cloud.google.com/go/internal/testutil"
"cloud.google.com/go/internal/uid"
"cloud.google.com/go/internal/version"
database "cloud.google.com/go/spanner/admin/database/apiv1"
instance "cloud.google.com/go/spanner/admin/instance/apiv1"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
adminpb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
Expand Down Expand Up @@ -3741,3 +3743,14 @@ func blackholeOrAllowDirectPath(t *testing.T, blackholeDP bool) {
t.Logf(string(out))
}
}

func checkCommonTagsGFELatency(t *testing.T, m map[tag.Key]string) {
// We only check prefix because client ID increases if we create
// multiple clients for the same database.
if !strings.HasPrefix(m[tagKeyClientID], "client") {
t.Fatalf("Incorrect client ID: %v", m[tagKeyClientID])
}
if m[tagKeyLibVersion] != version.Repo {
t.Fatalf("Incorrect library version: %v", m[tagKeyLibVersion])
}
}
12 changes: 0 additions & 12 deletions spanner/stats.go
Expand Up @@ -19,7 +19,6 @@ import (
"strconv"
"strings"
"sync"
"testing"

"cloud.google.com/go/internal/version"
"go.opencensus.io/stats"
Expand Down Expand Up @@ -276,17 +275,6 @@ func captureGFELatencyStats(ctx context.Context, md metadata.MD, keyMethod strin
return nil
}

func checkCommonTagsGFELatency(t *testing.T, m map[tag.Key]string) {
// We only check prefix because client ID increases if we create
// multiple clients for the same database.
if !strings.HasPrefix(m[tagKeyClientID], "client") {
t.Fatalf("Incorrect client ID: %v", m[tagKeyClientID])
}
if m[tagKeyLibVersion] != version.Repo {
t.Fatalf("Incorrect library version: %v", m[tagKeyLibVersion])
}
}

func createContextAndCaptureGFELatencyMetrics(ctx context.Context, ct *commonTags, md metadata.MD, keyMethod string) error {
var ctxGFE, err = tag.New(ctx,
tag.Upsert(tagKeyClientID, ct.clientID),
Expand Down

0 comments on commit 88cacd5

Please sign in to comment.