From b058e853624181e0808baf279dd8393ece5406bd Mon Sep 17 00:00:00 2001 From: rahul2393 Date: Fri, 24 May 2024 10:17:42 +0530 Subject: [PATCH] test(spanner): fix spanner trace tests (#10253) * test(spanner): fix spanner trace tests * Update cloud.google.com/go version * fix go vet --- spanner/client_test.go | 21 +++++++++------------ spanner/go.mod | 2 +- spanner/go.sum | 4 ++-- spanner/test/opentelemetry/test/go.mod | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/spanner/client_test.go b/spanner/client_test.go index 61915b82b6a6..4dc859e88e5e 100644 --- a/spanner/client_test.go +++ b/spanner/client_test.go @@ -4548,12 +4548,11 @@ func TestClient_DoForEachRow_ShouldNotEndSpanWithIteratorDoneError(t *testing.T) case <-time.After(1 * time.Second): t.Fatal("No stats were exported before timeout") } - // Preferably we would want to lock the TestExporter here, but the mutex TestExporter.mu is not exported, so we - // cannot do that. - if len(te.Spans) == 0 { + spans := te.Spans() + if len(spans) == 0 { t.Fatal("No spans were exported") } - s := te.Spans[len(te.Spans)-1].Status + s := spans[len(spans)-1].Status if s.Code != int32(codes.OK) { t.Errorf("Span status mismatch\nGot: %v\nWant: %v", s.Code, codes.OK) } @@ -4598,12 +4597,11 @@ func TestClient_DoForEachRow_ShouldEndSpanWithQueryError(t *testing.T) { case <-time.After(1 * time.Second): t.Fatal("No stats were exported before timeout") } - // Preferably we would want to lock the TestExporter here, but the mutex TestExporter.mu is not exported, so we - // cannot do that. - if len(te.Spans) == 0 { + spans := te.Spans() + if len(spans) == 0 { t.Fatal("No spans were exported") } - s := te.Spans[len(te.Spans)-1].Status + s := spans[len(spans)-1].Status if s.Code != int32(codes.InvalidArgument) { t.Errorf("Span status mismatch\nGot: %v\nWant: %v", s.Code, codes.InvalidArgument) } @@ -5366,12 +5364,11 @@ func checkBatchWriteSpan(t *testing.T, errors []error, code codes.Code) { case <-time.After(1 * time.Second): t.Fatal("No stats were exported before timeout") } - // Preferably we would want to lock the TestExporter here, but the mutex TestExporter.mu is not exported, so we - // cannot do that. - if len(te.Spans) == 0 { + spans := te.Spans() + if len(spans) == 0 { t.Fatal("No spans were exported") } - s := te.Spans[len(te.Spans)-1].Status + s := spans[len(spans)-1].Status if s.Code != int32(code) { t.Errorf("Span status mismatch\nGot: %v\nWant: %v", s.Code, code) } diff --git a/spanner/go.mod b/spanner/go.mod index 28358a71fad9..ed3475b76d48 100644 --- a/spanner/go.mod +++ b/spanner/go.mod @@ -3,7 +3,7 @@ module cloud.google.com/go/spanner go 1.20 require ( - cloud.google.com/go v0.113.0 + cloud.google.com/go v0.114.0 cloud.google.com/go/iam v1.1.8 cloud.google.com/go/longrunning v0.5.7 github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 diff --git a/spanner/go.sum b/spanner/go.sum index ccd83f609032..06381fd00440 100644 --- a/spanner/go.sum +++ b/spanner/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRY cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= -cloud.google.com/go v0.113.0 h1:g3C70mn3lWfckKBiCVsAshabrDg01pQ0pnX1MNtnMkA= -cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9GzO8= +cloud.google.com/go v0.114.0 h1:OIPFAdfrFDFO2ve2U7r/H5SwSbBzEdrBdE7xkgwc+kY= +cloud.google.com/go v0.114.0/go.mod h1:ZV9La5YYxctro1HTPug5lXH/GefROyW8PPD4T8n9J8E= cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= cloud.google.com/go/accessapproval v1.6.0/go.mod h1:R0EiYnwV5fsRFiKZkPHr6mwyk2wxUJ30nL4j2pcFY2E= diff --git a/spanner/test/opentelemetry/test/go.mod b/spanner/test/opentelemetry/test/go.mod index ae3640d50e9c..4381cd4ef5c7 100644 --- a/spanner/test/opentelemetry/test/go.mod +++ b/spanner/test/opentelemetry/test/go.mod @@ -8,7 +8,7 @@ replace ( ) require ( - cloud.google.com/go v0.113.0 + cloud.google.com/go v0.114.0 cloud.google.com/go/spanner v1.61.0 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/sdk v1.24.0