Skip to content

Commit

Permalink
Merge #49397 #49429
Browse files Browse the repository at this point in the history
49397: roachtest: run EXPLAIN ANALYZE when tpchvec/perf fails r=yuzefovich a=yuzefovich

**workload: switch TPCH queries mapping from using string to int**

It also exports `NumQueries` and `QueriesByNumber` fields of `tpch`
package to be used by `tpchvec` roachtest.

Release note: None

**roachtest: minor cleanup of tpchbench**

This commit refactors `tpchbench` test slightly in order to hide `tpch`
bench type from the whole `roachtest` package.

Release note: None

**roachtest: run EXPLAIN ANALYZE when tpchvec/perf fails**

We have a mysterious rare failure on query 7 in which `vectorize=on`
performs significantly worse than `vectorize=off`. I'm out of possible
explanations for this, so this commit adds an ability to run `EXPLAIN
ANALYZE` on the query with both `vectorize` options when the slowness
threshold is exceeded. Hopefully it'll give us some insight into the
perf failures.

Addresses: #47401.

Release note: None

49429: *: replace test usages of context.TODO() with context.Background() r=otan a=otan

*: replace test usages of context.TODO() with context.Background()

This commit replaces all usages of context.TODO() with context.Background()
in tests, and adds a lint rule ensuring context.TODO() does not appear.
Tests should always be initiating a new context if they are calling a
function for the first time - it is now "unknown" and hence not a "TODO"
application.

Also added a new test in `lint_test.go` for this.

Release note: None



Co-authored-by: Yahor Yuzefovich <[email protected]>
Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
3 people committed May 22, 2020
3 parents 931cc46 + 50fc566 + f54afe7 commit def9bb7
Show file tree
Hide file tree
Showing 227 changed files with 1,602 additions and 1,566 deletions.
2 changes: 1 addition & 1 deletion pkg/base/node_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestNodeIDContainer(t *testing.T) {
}

for i := 0; i < 2; i++ {
n.Set(context.TODO(), 5)
n.Set(context.Background(), 5)
if val := n.Get(); val != 5 {
t.Errorf("value should be 5, not %d", val)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bench/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ CREATE TABLE bench.insert_distinct (
fmt.Fprintf(&buf, "(%d, %d)", zipf.Uint64(), n)
}

if _, err := db.DB.ExecContext(context.TODO(), buf.String()); err != nil {
if _, err := db.DB.ExecContext(context.Background(), buf.String()); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bench/pgbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func BenchmarkPgbenchExec(b *testing.B) {
defer log.Scope(b).Close(b)
b.Run("Cockroach", func(b *testing.B) {
s, _, _ := serverutils.StartServer(b, base.TestServerArgs{Insecure: true})
defer s.Stopper().Stop(context.TODO())
defer s.Stopper().Stop(context.Background())

pgURL, cleanupFn := sqlutils.PGUrl(
b, s.ServingSQLAddr(), "benchmarkCockroach", url.User(security.RootUser))
Expand Down
8 changes: 4 additions & 4 deletions pkg/blobs/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func BenchmarkStreamingReadFile(b *testing.B) {
rpcContext.TestingAllowNamedRPCToAnonymousServer = true

factory := setUpService(b, rpcContext, localNodeID, remoteNodeID, localExternalDir, remoteExternalDir)
blobClient, err := factory(context.TODO(), remoteNodeID)
blobClient, err := factory(context.Background(), remoteNodeID)
if err != nil {
b.Fatal(err)
}
Expand All @@ -84,7 +84,7 @@ func benchmarkStreamingReadFile(b *testing.B, tc *benchmarkTestCase) {
b.ResetTimer()
b.SetBytes(tc.fileSize)
for i := 0; i < b.N; i++ {
reader, err := tc.blobClient.ReadFile(context.TODO(), tc.fileName)
reader, err := tc.blobClient.ReadFile(context.Background(), tc.fileName)
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func BenchmarkStreamingWriteFile(b *testing.B) {
rpcContext.TestingAllowNamedRPCToAnonymousServer = true

factory := setUpService(b, rpcContext, localNodeID, remoteNodeID, localExternalDir, remoteExternalDir)
blobClient, err := factory(context.TODO(), remoteNodeID)
blobClient, err := factory(context.Background(), remoteNodeID)
if err != nil {
b.Fatal(err)
}
Expand All @@ -134,7 +134,7 @@ func benchmarkStreamingWriteFile(b *testing.B, tc *benchmarkTestCase) {
b.ResetTimer()
b.SetBytes(tc.fileSize)
for i := 0; i < b.N; i++ {
err := tc.blobClient.WriteFile(context.TODO(), tc.fileName, bytes.NewReader(content))
err := tc.blobClient.WriteFile(context.Background(), tc.fileName, bytes.NewReader(content))
if err != nil {
b.Fatal(err)
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/blobs/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func createTestResources(t testing.TB) (string, string, *stop.Stopper, func()) {
return localExternalDir, remoteExternalDir, stopper, func() {
cleanupFn()
cleanupFn2()
stopper.Stop(context.TODO())
stopper.Stop(context.Background())
leaktest.AfterTest(t)()
}
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestBlobClientReadFile(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
ctx := context.Background()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestBlobClientWriteFile(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
ctx := context.Background()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -359,7 +359,7 @@ func TestBlobClientList(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
ctx := context.Background()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestBlobClientDeleteFrom(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
ctx := context.Background()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -517,7 +517,7 @@ func TestBlobClientStat(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
ctx := context.Background()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/blobs/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestBlobServiceList(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ctx := context.TODO()
ctx := context.Background()

t.Run("list-correct-files", func(t *testing.T) {
resp, err := service.List(ctx, &blobspb.GlobRequest{
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestBlobServiceDelete(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ctx := context.TODO()
ctx := context.Background()

t.Run("delete-correct-file", func(t *testing.T) {
_, err := service.Delete(ctx, &blobspb.DeleteRequest{
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestBlobServiceStat(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ctx := context.TODO()
ctx := context.Background()

t.Run("get-correct-file-size", func(t *testing.T) {
resp, err := service.Stat(ctx, &blobspb.StatRequest{
Expand Down
Loading

0 comments on commit def9bb7

Please sign in to comment.