Skip to content

Commit

Permalink
sql: skip pgbench if not on PATH
Browse files Browse the repository at this point in the history
Currently blocking cockroachdb#8081
  • Loading branch information
dt committed Nov 7, 2016
1 parent eee24c0 commit e871713
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/pgbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"math/rand"
"net/url"
"os/exec"
"testing"
"time"

Expand Down Expand Up @@ -84,6 +85,9 @@ func runPgbenchQueryParallel(b *testing.B, db *gosql.DB) {
}

func execPgbench(b *testing.B, pgUrl url.URL) {
if _, err := exec.LookPath("pgbench"); err != nil {
b.Skip("pgbench is not available on PATH")
}
c, err := pgbench.SetupExec(pgUrl, "bench", 20000, b.N)
if err != nil {
b.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/txn_restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func (rs rollbackStrategy) SQLCommand() string {
// errors.
// This function needs to be called from tests that set
// server.Context.TestingKnobs.ExecutorTestingKnobs.FixTxnPriority = true
func exec(t *testing.T, sqlDB *gosql.DB, rs rollbackStrategy, fn func(*gosql.Tx) bool) {
func retryExec(t *testing.T, sqlDB *gosql.DB, rs rollbackStrategy, fn func(*gosql.Tx) bool) {
tx, err := sqlDB.Begin()
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -775,7 +775,7 @@ CREATE TABLE t.test (k INT PRIMARY KEY, v TEXT);

commitCount := s.MustGetSQLCounter(sql.MetaTxnCommit.Name)
// This is the magic. Run the txn closure until all the retries are exhausted.
exec(t, sqlDB, rs, func(tx *gosql.Tx) bool {
retryExec(t, sqlDB, rs, func(tx *gosql.Tx) bool {
return runTestTxn(t, tc.magicVals, tc.expectedErr, sqlDB, tx, sentinelInsert)
})
checkRestarts(t, tc.magicVals)
Expand Down

0 comments on commit e871713

Please sign in to comment.