Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(all): refactor opencensus test support for spanner #11486

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions spanner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5034,7 +5034,7 @@ func transactionOptionsTestCases() []TransactionOptionsTestCase {
func TestClient_DoForEachRow_ShouldNotEndSpanWithIteratorDoneError(t *testing.T) {
t.Skip("open census spans are no longer exported by gapics")
// This test cannot be parallel, as the TestExporter does not support that.
te := itestutil.NewTestExporter()
te := NewTestExporter()
defer te.Unregister()
minOpened := uint64(1)
_, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{
Expand Down Expand Up @@ -5079,7 +5079,7 @@ func TestClient_DoForEachRow_ShouldNotEndSpanWithIteratorDoneError(t *testing.T)
func TestClient_DoForEachRow_ShouldEndSpanWithQueryError(t *testing.T) {
t.Skip("open census spans are no longer exported by gapics")
// This test cannot be parallel, as the TestExporter does not support that.
te := itestutil.NewTestExporter()
te := NewTestExporter()
defer te.Unregister()
minOpened := uint64(1)
server, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{
Expand Down Expand Up @@ -5857,7 +5857,7 @@ func TestClient_BatchWrite_Options(t *testing.T) {

func checkBatchWriteSpan(t *testing.T, errors []error, code codes.Code) {
// This test cannot be parallel, as the TestExporter does not support that.
te := itestutil.NewTestExporter()
te := NewTestExporter()
defer te.Unregister()
minOpened := uint64(1)
server, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{
Expand Down
3 changes: 2 additions & 1 deletion spanner/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
v1 "cloud.google.com/go/spanner/apiv1"
sppb "cloud.google.com/go/spanner/apiv1/spannerpb"
"cloud.google.com/go/spanner/internal"
stestutil "cloud.google.com/go/spanner/internal/testutil"
pb "cloud.google.com/go/spanner/testdata/protos"
"github.com/google/go-cmp/cmp"
"go.opencensus.io/stats/view"
Expand Down Expand Up @@ -5347,7 +5348,7 @@ func TestIntegration_GFE_Latency(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

te := testutil.NewTestExporter(GFEHeaderMissingCountView, GFELatencyView)
te := stestutil.NewTestExporter(GFEHeaderMissingCountView, GFELatencyView)
setGFELatencyMetricsFlag(true)

client, _, cleanup := prepareIntegrationTest(ctx, t, DefaultSessionPoolConfig, statements[testDialect][singerDDLStatements])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
9 changes: 4 additions & 5 deletions spanner/oc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"testing"
"time"

"cloud.google.com/go/internal/testutil"
"cloud.google.com/go/spanner/apiv1/spannerpb"
"cloud.google.com/go/spanner/internal"
stestutil "cloud.google.com/go/spanner/internal/testutil"
Expand Down Expand Up @@ -92,7 +91,7 @@ func TestOCStats_SessionPool(t *testing.T) {

func testSimpleMetric(t *testing.T, v *view.View, measure, value string) {
DisableGfeLatencyAndHeaderMissingCountViews()
te := testutil.NewTestExporter(v)
te := stestutil.NewTestExporter(v)
defer te.Unregister()

_, client, teardown := setupMockedTestServer(t)
Expand Down Expand Up @@ -143,7 +142,7 @@ func testSimpleMetric(t *testing.T, v *view.View, measure, value string) {

func TestOCStats_SessionPool_SessionsCount(t *testing.T) {
DisableGfeLatencyAndHeaderMissingCountViews()
te := testutil.NewTestExporter(SessionsCountView)
te := stestutil.NewTestExporter(SessionsCountView)
defer te.Unregister()

waitErr := &Error{}
Expand Down Expand Up @@ -217,7 +216,7 @@ func TestOCStats_SessionPool_SessionsCount(t *testing.T) {

func TestOCStats_SessionPool_GetSessionTimeoutsCount(t *testing.T) {
DisableGfeLatencyAndHeaderMissingCountViews()
te := testutil.NewTestExporter(GetSessionTimeoutsCountView)
te := stestutil.NewTestExporter(GetSessionTimeoutsCountView)
defer te.Unregister()

server, client, teardown := setupMockedTestServerWithoutWaitingForMultiplexedSessionInit(t)
Expand Down Expand Up @@ -269,7 +268,7 @@ func TestOCStats_SessionPool_GetSessionTimeoutsCount(t *testing.T) {
}

func TestOCStats_GFE_Latency(t *testing.T) {
te := testutil.NewTestExporter([]*view.View{GFELatencyView, GFEHeaderMissingCountView}...)
te := stestutil.NewTestExporter([]*view.View{GFELatencyView, GFEHeaderMissingCountView}...)
defer te.Unregister()

setGFELatencyMetricsFlag(true)
Expand Down
Loading