Skip to content

Commit 0004702

Browse files
authoredDec 13, 2023
Parallelize test (go-sql-driver#1525)
* Refactor test cleanup in driver_test.go * parallelize TestEmptyQuery and TestCRUD * parallelize TestNumbersToAny * parallelize TestInt * parallelize TestFloat32 * parallelize TestFloat64 * parallelize TestFloat64Placeholder * parallelize TestString * parallelize TestRawBytes * parallelize TestRawMessage * parallelize TestValuer * parallelize TestValuerWithValidation * parallelize TestTimestampMicros * parallelize TestNULL * parallelize TestUint64 * parallelize TestLongData * parallelize TestContextCancelExec * parallelize TestPingContext * parallelize TestContextCancelQuery * parallelize TestContextCancelQueryRow * Revert "parallelize TestLongData" This reverts commit a360be7. * parallelize TestContextCancelPrepare * parallelize TestContextCancelStmtExec * parallelize TestContextCancelStmtQuery * parallelize TestContextCancelBegin * parallelize TestContextBeginIsolationLevel * parallelize TestContextBeginReadOnly * parallelize TestValuerWithValueReceiverGivenNilValue * parallelize TestRawBytesAreNotModified * parallelize TestFoundRows * parallelize TestRowsClose * parallelize TestCloseStmtBeforeRows * parallelize TestStmtMultiRows * Revert "parallelize TestRawBytesAreNotModified" This reverts commit 91622f0. * parallelize TestStaleConnectionChecks * parallelize TestFailingCharset * parallelize TestColumnsWithAlias * parallelize TestRawBytesResultExceedsBuffer * parallelize TestUnixSocketAuthFail * parallelize TestSkipResults * Add parallel flag to go test command * Revert "parallelize TestUnixSocketAuthFail" This reverts commit b3df7bd.
1 parent d4517c5 commit 0004702

File tree

3 files changed

+198
-138
lines changed

3 files changed

+198
-138
lines changed
 

‎.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
9797
- name: test
9898
run: |
99-
go test -v '-race' '-covermode=atomic' '-coverprofile=coverage.out'
99+
go test -v '-race' '-covermode=atomic' '-coverprofile=coverage.out' -parallel 10
100100
101101
- name: Send coverage
102102
uses: shogo82148/actions-goveralls@v1

‎conncheck_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
func TestStaleConnectionChecks(t *testing.T) {
20-
runTests(t, dsn, func(dbt *DBTest) {
20+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
2121
dbt.mustExec("SET @@SESSION.wait_timeout = 2")
2222

2323
if err := dbt.db.Ping(); err != nil {

‎driver_test.go

+196-136
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package mysql
1111
import (
1212
"bytes"
1313
"context"
14+
"crypto/rand"
1415
"crypto/tls"
1516
"database/sql"
1617
"database/sql/driver"
@@ -149,8 +150,9 @@ func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
149150
}
150151
defer db.Close()
151152

152-
// Previous test may be skipped without dropping the test table
153-
db.Exec("DROP TABLE IF EXISTS test")
153+
cleanup := func() {
154+
db.Exec("DROP TABLE IF EXISTS test")
155+
}
154156

155157
dsn2 := dsn + "&interpolateParams=true"
156158
var db2 *sql.DB
@@ -163,21 +165,80 @@ func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
163165
}
164166

165167
for _, test := range tests {
168+
test := test
166169
t.Run("default", func(t *testing.T) {
167170
dbt := &DBTest{t, db}
168-
defer dbt.db.Exec("DROP TABLE IF EXISTS test")
171+
t.Cleanup(cleanup)
169172
test(dbt)
170173
})
171174
if db2 != nil {
172175
t.Run("interpolateParams", func(t *testing.T) {
173176
dbt2 := &DBTest{t, db2}
174-
defer dbt2.db.Exec("DROP TABLE IF EXISTS test")
177+
t.Cleanup(cleanup)
175178
test(dbt2)
176179
})
177180
}
178181
}
179182
}
180183

184+
// runTestsParallel runs the tests in parallel with a separate database connection for each test.
185+
func runTestsParallel(t *testing.T, dsn string, tests ...func(dbt *DBTest, tableName string)) {
186+
if !available {
187+
t.Skipf("MySQL server not running on %s", netAddr)
188+
}
189+
190+
newTableName := func(t *testing.T) string {
191+
t.Helper()
192+
var buf [8]byte
193+
if _, err := rand.Read(buf[:]); err != nil {
194+
t.Fatal(err)
195+
}
196+
return fmt.Sprintf("test_%x", buf[:])
197+
}
198+
199+
t.Parallel()
200+
for _, test := range tests {
201+
test := test
202+
203+
t.Run("default", func(t *testing.T) {
204+
t.Parallel()
205+
206+
tableName := newTableName(t)
207+
db, err := sql.Open("mysql", dsn)
208+
if err != nil {
209+
t.Fatalf("error connecting: %s", err.Error())
210+
}
211+
t.Cleanup(func() {
212+
db.Exec("DROP TABLE IF EXISTS " + tableName)
213+
db.Close()
214+
})
215+
216+
dbt := &DBTest{t, db}
217+
test(dbt, tableName)
218+
})
219+
220+
dsn2 := dsn + "&interpolateParams=true"
221+
if _, err := ParseDSN(dsn2); err == errInvalidDSNUnsafeCollation {
222+
t.Run("interpolateParams", func(t *testing.T) {
223+
t.Parallel()
224+
225+
tableName := newTableName(t)
226+
db, err := sql.Open("mysql", dsn2)
227+
if err != nil {
228+
t.Fatalf("error connecting: %s", err.Error())
229+
}
230+
t.Cleanup(func() {
231+
db.Exec("DROP TABLE IF EXISTS " + tableName)
232+
db.Close()
233+
})
234+
235+
dbt := &DBTest{t, db}
236+
test(dbt, tableName)
237+
})
238+
}
239+
}
240+
}
241+
181242
func (dbt *DBTest) fail(method, query string, err error) {
182243
dbt.Helper()
183244
if len(query) > 300 {
@@ -216,7 +277,7 @@ func maybeSkip(t *testing.T, err error, skipErrno uint16) {
216277
}
217278

218279
func TestEmptyQuery(t *testing.T) {
219-
runTests(t, dsn, func(dbt *DBTest) {
280+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
220281
// just a comment, no query
221282
rows := dbt.mustQuery("--")
222283
defer rows.Close()
@@ -228,20 +289,20 @@ func TestEmptyQuery(t *testing.T) {
228289
}
229290

230291
func TestCRUD(t *testing.T) {
231-
runTests(t, dsn, func(dbt *DBTest) {
292+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
232293
// Create Table
233-
dbt.mustExec("CREATE TABLE test (value BOOL)")
294+
dbt.mustExec("CREATE TABLE " + tbl + " (value BOOL)")
234295

235296
// Test for unexpected data
236297
var out bool
237-
rows := dbt.mustQuery("SELECT * FROM test")
298+
rows := dbt.mustQuery("SELECT * FROM " + tbl)
238299
if rows.Next() {
239300
dbt.Error("unexpected data in empty table")
240301
}
241302
rows.Close()
242303

243304
// Create Data
244-
res := dbt.mustExec("INSERT INTO test VALUES (1)")
305+
res := dbt.mustExec("INSERT INTO " + tbl + " VALUES (1)")
245306
count, err := res.RowsAffected()
246307
if err != nil {
247308
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -259,7 +320,7 @@ func TestCRUD(t *testing.T) {
259320
}
260321

261322
// Read
262-
rows = dbt.mustQuery("SELECT value FROM test")
323+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
263324
if rows.Next() {
264325
rows.Scan(&out)
265326
if true != out {
@@ -275,7 +336,7 @@ func TestCRUD(t *testing.T) {
275336
rows.Close()
276337

277338
// Update
278-
res = dbt.mustExec("UPDATE test SET value = ? WHERE value = ?", false, true)
339+
res = dbt.mustExec("UPDATE "+tbl+" SET value = ? WHERE value = ?", false, true)
279340
count, err = res.RowsAffected()
280341
if err != nil {
281342
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -285,7 +346,7 @@ func TestCRUD(t *testing.T) {
285346
}
286347

287348
// Check Update
288-
rows = dbt.mustQuery("SELECT value FROM test")
349+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
289350
if rows.Next() {
290351
rows.Scan(&out)
291352
if false != out {
@@ -301,7 +362,7 @@ func TestCRUD(t *testing.T) {
301362
rows.Close()
302363

303364
// Delete
304-
res = dbt.mustExec("DELETE FROM test WHERE value = ?", false)
365+
res = dbt.mustExec("DELETE FROM "+tbl+" WHERE value = ?", false)
305366
count, err = res.RowsAffected()
306367
if err != nil {
307368
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -311,7 +372,7 @@ func TestCRUD(t *testing.T) {
311372
}
312373

313374
// Check for unexpected rows
314-
res = dbt.mustExec("DELETE FROM test")
375+
res = dbt.mustExec("DELETE FROM " + tbl)
315376
count, err = res.RowsAffected()
316377
if err != nil {
317378
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -325,13 +386,13 @@ func TestCRUD(t *testing.T) {
325386
// TestNumbers test that selecting numeric columns.
326387
// Both of textRows and binaryRows should return same type and value.
327388
func TestNumbersToAny(t *testing.T) {
328-
runTests(t, dsn, func(dbt *DBTest) {
329-
dbt.mustExec("CREATE TABLE `test` (id INT PRIMARY KEY, b BOOL, i8 TINYINT, " +
389+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
390+
dbt.mustExec("CREATE TABLE " + tbl + " (id INT PRIMARY KEY, b BOOL, i8 TINYINT, " +
330391
"i16 SMALLINT, i32 INT, i64 BIGINT, f32 FLOAT, f64 DOUBLE)")
331-
dbt.mustExec("INSERT INTO `test` VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5)")
392+
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5)")
332393

333394
// Use binaryRows for intarpolateParams=false and textRows for intarpolateParams=true.
334-
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64 FROM `test` WHERE id=?", 1)
395+
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64 FROM "+tbl+" WHERE id=?", 1)
335396
if !rows.Next() {
336397
dbt.Fatal("no data")
337398
}
@@ -410,19 +471,19 @@ func TestMultiQuery(t *testing.T) {
410471
}
411472

412473
func TestInt(t *testing.T) {
413-
runTests(t, dsn, func(dbt *DBTest) {
474+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
414475
types := [5]string{"TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT"}
415476
in := int64(42)
416477
var out int64
417478
var rows *sql.Rows
418479

419480
// SIGNED
420481
for _, v := range types {
421-
dbt.mustExec("CREATE TABLE test (value " + v + ")")
482+
dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ")")
422483

423-
dbt.mustExec("INSERT INTO test VALUES (?)", in)
484+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
424485

425-
rows = dbt.mustQuery("SELECT value FROM test")
486+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
426487
if rows.Next() {
427488
rows.Scan(&out)
428489
if in != out {
@@ -433,16 +494,16 @@ func TestInt(t *testing.T) {
433494
}
434495
rows.Close()
435496

436-
dbt.mustExec("DROP TABLE IF EXISTS test")
497+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
437498
}
438499

439500
// UNSIGNED ZEROFILL
440501
for _, v := range types {
441-
dbt.mustExec("CREATE TABLE test (value " + v + " ZEROFILL)")
502+
dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + " ZEROFILL)")
442503

443-
dbt.mustExec("INSERT INTO test VALUES (?)", in)
504+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
444505

445-
rows = dbt.mustQuery("SELECT value FROM test")
506+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
446507
if rows.Next() {
447508
rows.Scan(&out)
448509
if in != out {
@@ -453,21 +514,21 @@ func TestInt(t *testing.T) {
453514
}
454515
rows.Close()
455516

456-
dbt.mustExec("DROP TABLE IF EXISTS test")
517+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
457518
}
458519
})
459520
}
460521

461522
func TestFloat32(t *testing.T) {
462-
runTests(t, dsn, func(dbt *DBTest) {
523+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
463524
types := [2]string{"FLOAT", "DOUBLE"}
464525
in := float32(42.23)
465526
var out float32
466527
var rows *sql.Rows
467528
for _, v := range types {
468-
dbt.mustExec("CREATE TABLE test (value " + v + ")")
469-
dbt.mustExec("INSERT INTO test VALUES (?)", in)
470-
rows = dbt.mustQuery("SELECT value FROM test")
529+
dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ")")
530+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
531+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
471532
if rows.Next() {
472533
rows.Scan(&out)
473534
if in != out {
@@ -477,21 +538,21 @@ func TestFloat32(t *testing.T) {
477538
dbt.Errorf("%s: no data", v)
478539
}
479540
rows.Close()
480-
dbt.mustExec("DROP TABLE IF EXISTS test")
541+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
481542
}
482543
})
483544
}
484545

485546
func TestFloat64(t *testing.T) {
486-
runTests(t, dsn, func(dbt *DBTest) {
547+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
487548
types := [2]string{"FLOAT", "DOUBLE"}
488549
var expected float64 = 42.23
489550
var out float64
490551
var rows *sql.Rows
491552
for _, v := range types {
492-
dbt.mustExec("CREATE TABLE test (value " + v + ")")
493-
dbt.mustExec("INSERT INTO test VALUES (42.23)")
494-
rows = dbt.mustQuery("SELECT value FROM test")
553+
dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ")")
554+
dbt.mustExec("INSERT INTO " + tbl + " VALUES (42.23)")
555+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
495556
if rows.Next() {
496557
rows.Scan(&out)
497558
if expected != out {
@@ -501,21 +562,21 @@ func TestFloat64(t *testing.T) {
501562
dbt.Errorf("%s: no data", v)
502563
}
503564
rows.Close()
504-
dbt.mustExec("DROP TABLE IF EXISTS test")
565+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
505566
}
506567
})
507568
}
508569

509570
func TestFloat64Placeholder(t *testing.T) {
510-
runTests(t, dsn, func(dbt *DBTest) {
571+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
511572
types := [2]string{"FLOAT", "DOUBLE"}
512573
var expected float64 = 42.23
513574
var out float64
514575
var rows *sql.Rows
515576
for _, v := range types {
516-
dbt.mustExec("CREATE TABLE test (id int, value " + v + ")")
517-
dbt.mustExec("INSERT INTO test VALUES (1, 42.23)")
518-
rows = dbt.mustQuery("SELECT value FROM test WHERE id = ?", 1)
577+
dbt.mustExec("CREATE TABLE " + tbl + " (id int, value " + v + ")")
578+
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, 42.23)")
579+
rows = dbt.mustQuery("SELECT value FROM "+tbl+" WHERE id = ?", 1)
519580
if rows.Next() {
520581
rows.Scan(&out)
521582
if expected != out {
@@ -525,24 +586,24 @@ func TestFloat64Placeholder(t *testing.T) {
525586
dbt.Errorf("%s: no data", v)
526587
}
527588
rows.Close()
528-
dbt.mustExec("DROP TABLE IF EXISTS test")
589+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
529590
}
530591
})
531592
}
532593

533594
func TestString(t *testing.T) {
534-
runTests(t, dsn, func(dbt *DBTest) {
595+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
535596
types := [6]string{"CHAR(255)", "VARCHAR(255)", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT"}
536597
in := "κόσμε üöäßñóùéàâÿœ'îë Árvíztűrő いろはにほへとちりぬるを イロハニホヘト דג סקרן чащах น่าฟังเอย"
537598
var out string
538599
var rows *sql.Rows
539600

540601
for _, v := range types {
541-
dbt.mustExec("CREATE TABLE test (value " + v + ") CHARACTER SET utf8")
602+
dbt.mustExec("CREATE TABLE " + tbl + " (value " + v + ") CHARACTER SET utf8")
542603

543-
dbt.mustExec("INSERT INTO test VALUES (?)", in)
604+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
544605

545-
rows = dbt.mustQuery("SELECT value FROM test")
606+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
546607
if rows.Next() {
547608
rows.Scan(&out)
548609
if in != out {
@@ -553,11 +614,11 @@ func TestString(t *testing.T) {
553614
}
554615
rows.Close()
555616

556-
dbt.mustExec("DROP TABLE IF EXISTS test")
617+
dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
557618
}
558619

559620
// BLOB
560-
dbt.mustExec("CREATE TABLE test (id int, value BLOB) CHARACTER SET utf8")
621+
dbt.mustExec("CREATE TABLE " + tbl + " (id int, value BLOB) CHARACTER SET utf8")
561622

562623
id := 2
563624
in = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " +
@@ -568,9 +629,9 @@ func TestString(t *testing.T) {
568629
"sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, " +
569630
"sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. " +
570631
"Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
571-
dbt.mustExec("INSERT INTO test VALUES (?, ?)", id, in)
632+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?, ?)", id, in)
572633

573-
err := dbt.db.QueryRow("SELECT value FROM test WHERE id = ?", id).Scan(&out)
634+
err := dbt.db.QueryRow("SELECT value FROM "+tbl+" WHERE id = ?", id).Scan(&out)
574635
if err != nil {
575636
dbt.Fatalf("Error on BLOB-Query: %s", err.Error())
576637
} else if out != in {
@@ -580,7 +641,7 @@ func TestString(t *testing.T) {
580641
}
581642

582643
func TestRawBytes(t *testing.T) {
583-
runTests(t, dsn, func(dbt *DBTest) {
644+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
584645
v1 := []byte("aaa")
585646
v2 := []byte("bbb")
586647
rows := dbt.mustQuery("SELECT ?, ?", v1, v2)
@@ -609,7 +670,7 @@ func TestRawBytes(t *testing.T) {
609670
}
610671

611672
func TestRawMessage(t *testing.T) {
612-
runTests(t, dsn, func(dbt *DBTest) {
673+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
613674
v1 := json.RawMessage("{}")
614675
v2 := json.RawMessage("[]")
615676
rows := dbt.mustQuery("SELECT ?, ?", v1, v2)
@@ -640,14 +701,14 @@ func (tv testValuer) Value() (driver.Value, error) {
640701
}
641702

642703
func TestValuer(t *testing.T) {
643-
runTests(t, dsn, func(dbt *DBTest) {
704+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
644705
in := testValuer{"a_value"}
645706
var out string
646707
var rows *sql.Rows
647708

648-
dbt.mustExec("CREATE TABLE test (value VARCHAR(255)) CHARACTER SET utf8")
649-
dbt.mustExec("INSERT INTO test VALUES (?)", in)
650-
rows = dbt.mustQuery("SELECT value FROM test")
709+
dbt.mustExec("CREATE TABLE " + tbl + " (value VARCHAR(255)) CHARACTER SET utf8")
710+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
711+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
651712
if rows.Next() {
652713
rows.Scan(&out)
653714
if in.value != out {
@@ -657,8 +718,6 @@ func TestValuer(t *testing.T) {
657718
dbt.Errorf("Valuer: no data")
658719
}
659720
rows.Close()
660-
661-
dbt.mustExec("DROP TABLE IF EXISTS test")
662721
})
663722
}
664723

@@ -675,15 +734,15 @@ func (tv testValuerWithValidation) Value() (driver.Value, error) {
675734
}
676735

677736
func TestValuerWithValidation(t *testing.T) {
678-
runTests(t, dsn, func(dbt *DBTest) {
737+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
679738
in := testValuerWithValidation{"a_value"}
680739
var out string
681740
var rows *sql.Rows
682741

683-
dbt.mustExec("CREATE TABLE testValuer (value VARCHAR(255)) CHARACTER SET utf8")
684-
dbt.mustExec("INSERT INTO testValuer VALUES (?)", in)
742+
dbt.mustExec("CREATE TABLE " + tbl + " (value VARCHAR(255)) CHARACTER SET utf8")
743+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?)", in)
685744

686-
rows = dbt.mustQuery("SELECT value FROM testValuer")
745+
rows = dbt.mustQuery("SELECT value FROM " + tbl)
687746
defer rows.Close()
688747

689748
if rows.Next() {
@@ -695,19 +754,17 @@ func TestValuerWithValidation(t *testing.T) {
695754
dbt.Errorf("Valuer: no data")
696755
}
697756

698-
if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", testValuerWithValidation{""}); err == nil {
757+
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", testValuerWithValidation{""}); err == nil {
699758
dbt.Errorf("Failed to check valuer error")
700759
}
701760

702-
if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", nil); err != nil {
761+
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", nil); err != nil {
703762
dbt.Errorf("Failed to check nil")
704763
}
705764

706-
if _, err := dbt.db.Exec("INSERT INTO testValuer VALUES (?)", map[string]bool{}); err == nil {
765+
if _, err := dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", map[string]bool{}); err == nil {
707766
dbt.Errorf("Failed to check not valuer")
708767
}
709-
710-
dbt.mustExec("DROP TABLE IF EXISTS testValuer")
711768
})
712769
}
713770

@@ -941,7 +998,7 @@ func TestTimestampMicros(t *testing.T) {
941998
f0 := format[:19]
942999
f1 := format[:21]
9431000
f6 := format[:26]
944-
runTests(t, dsn, func(dbt *DBTest) {
1001+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
9451002
// check if microseconds are supported.
9461003
// Do not use timestamp(x) for that check - before 5.5.6, x would mean display width
9471004
// and not precision.
@@ -956,7 +1013,7 @@ func TestTimestampMicros(t *testing.T) {
9561013
return
9571014
}
9581015
_, err := dbt.db.Exec(`
959-
CREATE TABLE test (
1016+
CREATE TABLE ` + tbl + ` (
9601017
value0 TIMESTAMP NOT NULL DEFAULT '` + f0 + `',
9611018
value1 TIMESTAMP(1) NOT NULL DEFAULT '` + f1 + `',
9621019
value6 TIMESTAMP(6) NOT NULL DEFAULT '` + f6 + `'
@@ -965,10 +1022,10 @@ func TestTimestampMicros(t *testing.T) {
9651022
if err != nil {
9661023
dbt.Error(err)
9671024
}
968-
defer dbt.mustExec("DROP TABLE IF EXISTS test")
969-
dbt.mustExec("INSERT INTO test SET value0=?, value1=?, value6=?", f0, f1, f6)
1025+
defer dbt.mustExec("DROP TABLE IF EXISTS " + tbl)
1026+
dbt.mustExec("INSERT INTO "+tbl+" SET value0=?, value1=?, value6=?", f0, f1, f6)
9701027
var res0, res1, res6 string
971-
rows := dbt.mustQuery("SELECT * FROM test")
1028+
rows := dbt.mustQuery("SELECT * FROM " + tbl)
9721029
defer rows.Close()
9731030
if !rows.Next() {
9741031
dbt.Errorf("test contained no selectable values")
@@ -990,7 +1047,7 @@ func TestTimestampMicros(t *testing.T) {
9901047
}
9911048

9921049
func TestNULL(t *testing.T) {
993-
runTests(t, dsn, func(dbt *DBTest) {
1050+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
9941051
nullStmt, err := dbt.db.Prepare("SELECT NULL")
9951052
if err != nil {
9961053
dbt.Fatal(err)
@@ -1122,12 +1179,12 @@ func TestNULL(t *testing.T) {
11221179
}
11231180

11241181
// Insert NULL
1125-
dbt.mustExec("CREATE TABLE test (dummmy1 int, value int, dummy2 int)")
1182+
dbt.mustExec("CREATE TABLE " + tbl + " (dummmy1 int, value int, dummy2 int)")
11261183

1127-
dbt.mustExec("INSERT INTO test VALUES (?, ?, ?)", 1, nil, 2)
1184+
dbt.mustExec("INSERT INTO "+tbl+" VALUES (?, ?, ?)", 1, nil, 2)
11281185

11291186
var out interface{}
1130-
rows := dbt.mustQuery("SELECT * FROM test")
1187+
rows := dbt.mustQuery("SELECT * FROM " + tbl)
11311188
defer rows.Close()
11321189
if rows.Next() {
11331190
rows.Scan(&out)
@@ -1151,7 +1208,7 @@ func TestUint64(t *testing.T) {
11511208
shigh = int64(uhigh)
11521209
stop = ^shigh
11531210
)
1154-
runTests(t, dsn, func(dbt *DBTest) {
1211+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
11551212
stmt, err := dbt.db.Prepare(`SELECT ?, ?, ? ,?, ?, ?, ?, ?`)
11561213
if err != nil {
11571214
dbt.Fatal(err)
@@ -1347,20 +1404,20 @@ func TestLoadData(t *testing.T) {
13471404
})
13481405
}
13491406

1350-
func TestFoundRows(t *testing.T) {
1351-
runTests(t, dsn, func(dbt *DBTest) {
1352-
dbt.mustExec("CREATE TABLE test (id INT NOT NULL ,data INT NOT NULL)")
1353-
dbt.mustExec("INSERT INTO test (id, data) VALUES (0, 0),(0, 0),(1, 0),(1, 0),(1, 1)")
1407+
func TestFoundRows1(t *testing.T) {
1408+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
1409+
dbt.mustExec("CREATE TABLE " + tbl + " (id INT NOT NULL ,data INT NOT NULL)")
1410+
dbt.mustExec("INSERT INTO " + tbl + " (id, data) VALUES (0, 0),(0, 0),(1, 0),(1, 0),(1, 1)")
13541411

1355-
res := dbt.mustExec("UPDATE test SET data = 1 WHERE id = 0")
1412+
res := dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 0")
13561413
count, err := res.RowsAffected()
13571414
if err != nil {
13581415
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
13591416
}
13601417
if count != 2 {
13611418
dbt.Fatalf("Expected 2 affected rows, got %d", count)
13621419
}
1363-
res = dbt.mustExec("UPDATE test SET data = 1 WHERE id = 1")
1420+
res = dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 1")
13641421
count, err = res.RowsAffected()
13651422
if err != nil {
13661423
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -1369,19 +1426,22 @@ func TestFoundRows(t *testing.T) {
13691426
dbt.Fatalf("Expected 2 affected rows, got %d", count)
13701427
}
13711428
})
1372-
runTests(t, dsn+"&clientFoundRows=true", func(dbt *DBTest) {
1373-
dbt.mustExec("CREATE TABLE test (id INT NOT NULL ,data INT NOT NULL)")
1374-
dbt.mustExec("INSERT INTO test (id, data) VALUES (0, 0),(0, 0),(1, 0),(1, 0),(1, 1)")
1429+
}
1430+
1431+
func TestFoundRows2(t *testing.T) {
1432+
runTestsParallel(t, dsn+"&clientFoundRows=true", func(dbt *DBTest, tbl string) {
1433+
dbt.mustExec("CREATE TABLE " + tbl + " (id INT NOT NULL ,data INT NOT NULL)")
1434+
dbt.mustExec("INSERT INTO " + tbl + " (id, data) VALUES (0, 0),(0, 0),(1, 0),(1, 0),(1, 1)")
13751435

1376-
res := dbt.mustExec("UPDATE test SET data = 1 WHERE id = 0")
1436+
res := dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 0")
13771437
count, err := res.RowsAffected()
13781438
if err != nil {
13791439
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
13801440
}
13811441
if count != 2 {
13821442
dbt.Fatalf("Expected 2 matched rows, got %d", count)
13831443
}
1384-
res = dbt.mustExec("UPDATE test SET data = 1 WHERE id = 1")
1444+
res = dbt.mustExec("UPDATE " + tbl + " SET data = 1 WHERE id = 1")
13851445
count, err = res.RowsAffected()
13861446
if err != nil {
13871447
dbt.Fatalf("res.RowsAffected() returned error: %s", err.Error())
@@ -1507,7 +1567,7 @@ func TestCharset(t *testing.T) {
15071567
}
15081568

15091569
func TestFailingCharset(t *testing.T) {
1510-
runTests(t, dsn+"&charset=none", func(dbt *DBTest) {
1570+
runTestsParallel(t, dsn+"&charset=none", func(dbt *DBTest, _ string) {
15111571
// run query to really establish connection...
15121572
_, err := dbt.db.Exec("SELECT 1")
15131573
if err == nil {
@@ -1556,7 +1616,7 @@ func TestCollation(t *testing.T) {
15561616
}
15571617

15581618
func TestColumnsWithAlias(t *testing.T) {
1559-
runTests(t, dsn+"&columnsWithAlias=true", func(dbt *DBTest) {
1619+
runTestsParallel(t, dsn+"&columnsWithAlias=true", func(dbt *DBTest, _ string) {
15601620
rows := dbt.mustQuery("SELECT 1 AS A")
15611621
defer rows.Close()
15621622
cols, _ := rows.Columns()
@@ -1580,7 +1640,7 @@ func TestColumnsWithAlias(t *testing.T) {
15801640
}
15811641

15821642
func TestRawBytesResultExceedsBuffer(t *testing.T) {
1583-
runTests(t, dsn, func(dbt *DBTest) {
1643+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
15841644
// defaultBufSize from buffer.go
15851645
expected := strings.Repeat("abc", defaultBufSize)
15861646

@@ -1639,7 +1699,7 @@ func TestTimezoneConversion(t *testing.T) {
16391699
// Special cases
16401700

16411701
func TestRowsClose(t *testing.T) {
1642-
runTests(t, dsn, func(dbt *DBTest) {
1702+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
16431703
rows, err := dbt.db.Query("SELECT 1")
16441704
if err != nil {
16451705
dbt.Fatal(err)
@@ -1664,7 +1724,7 @@ func TestRowsClose(t *testing.T) {
16641724
// dangling statements
16651725
// http://code.google.com/p/go/issues/detail?id=3865
16661726
func TestCloseStmtBeforeRows(t *testing.T) {
1667-
runTests(t, dsn, func(dbt *DBTest) {
1727+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
16681728
stmt, err := dbt.db.Prepare("SELECT 1")
16691729
if err != nil {
16701730
dbt.Fatal(err)
@@ -1705,7 +1765,7 @@ func TestCloseStmtBeforeRows(t *testing.T) {
17051765
// It is valid to have multiple Rows for the same Stmt
17061766
// http://code.google.com/p/go/issues/detail?id=3734
17071767
func TestStmtMultiRows(t *testing.T) {
1708-
runTests(t, dsn, func(dbt *DBTest) {
1768+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
17091769
stmt, err := dbt.db.Prepare("SELECT 1 UNION SELECT 0")
17101770
if err != nil {
17111771
dbt.Fatal(err)
@@ -2507,7 +2567,7 @@ func TestExecMultipleResults(t *testing.T) {
25072567
// tests if rows are set in a proper state if some results were ignored before
25082568
// calling rows.NextResultSet.
25092569
func TestSkipResults(t *testing.T) {
2510-
runTests(t, dsn, func(dbt *DBTest) {
2570+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
25112571
rows := dbt.mustQuery("SELECT 1, 2")
25122572
defer rows.Close()
25132573

@@ -2562,7 +2622,7 @@ func TestQueryMultipleResults(t *testing.T) {
25622622
}
25632623

25642624
func TestPingContext(t *testing.T) {
2565-
runTests(t, dsn, func(dbt *DBTest) {
2625+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
25662626
ctx, cancel := context.WithCancel(context.Background())
25672627
cancel()
25682628
if err := dbt.db.PingContext(ctx); err != context.Canceled {
@@ -2572,16 +2632,16 @@ func TestPingContext(t *testing.T) {
25722632
}
25732633

25742634
func TestContextCancelExec(t *testing.T) {
2575-
runTests(t, dsn, func(dbt *DBTest) {
2576-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2635+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2636+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
25772637
ctx, cancel := context.WithCancel(context.Background())
25782638

25792639
// Delay execution for just a bit until db.ExecContext has begun.
25802640
defer time.AfterFunc(250*time.Millisecond, cancel).Stop()
25812641

25822642
// This query will be canceled.
25832643
startTime := time.Now()
2584-
if _, err := dbt.db.ExecContext(ctx, "INSERT INTO test VALUES (SLEEP(1))"); err != context.Canceled {
2644+
if _, err := dbt.db.ExecContext(ctx, "INSERT INTO "+tbl+" VALUES (SLEEP(1))"); err != context.Canceled {
25852645
dbt.Errorf("expected context.Canceled, got %v", err)
25862646
}
25872647
if d := time.Since(startTime); d > 500*time.Millisecond {
@@ -2593,22 +2653,22 @@ func TestContextCancelExec(t *testing.T) {
25932653

25942654
// Check how many times the query is executed.
25952655
var v int
2596-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2656+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
25972657
dbt.Fatalf("%s", err.Error())
25982658
}
25992659
if v != 1 { // TODO: need to kill the query, and v should be 0.
26002660
dbt.Skipf("[WARN] expected val to be 1, got %d", v)
26012661
}
26022662

26032663
// Context is already canceled, so error should come before execution.
2604-
if _, err := dbt.db.ExecContext(ctx, "INSERT INTO test VALUES (1)"); err == nil {
2664+
if _, err := dbt.db.ExecContext(ctx, "INSERT INTO "+tbl+" VALUES (1)"); err == nil {
26052665
dbt.Error("expected error")
26062666
} else if err.Error() != "context canceled" {
26072667
dbt.Fatalf("unexpected error: %s", err)
26082668
}
26092669

26102670
// The second insert query will fail, so the table has no changes.
2611-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2671+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
26122672
dbt.Fatalf("%s", err.Error())
26132673
}
26142674
if v != 1 {
@@ -2618,16 +2678,16 @@ func TestContextCancelExec(t *testing.T) {
26182678
}
26192679

26202680
func TestContextCancelQuery(t *testing.T) {
2621-
runTests(t, dsn, func(dbt *DBTest) {
2622-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2681+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2682+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
26232683
ctx, cancel := context.WithCancel(context.Background())
26242684

26252685
// Delay execution for just a bit until db.ExecContext has begun.
26262686
defer time.AfterFunc(250*time.Millisecond, cancel).Stop()
26272687

26282688
// This query will be canceled.
26292689
startTime := time.Now()
2630-
if _, err := dbt.db.QueryContext(ctx, "INSERT INTO test VALUES (SLEEP(1))"); err != context.Canceled {
2690+
if _, err := dbt.db.QueryContext(ctx, "INSERT INTO "+tbl+" VALUES (SLEEP(1))"); err != context.Canceled {
26312691
dbt.Errorf("expected context.Canceled, got %v", err)
26322692
}
26332693
if d := time.Since(startTime); d > 500*time.Millisecond {
@@ -2639,20 +2699,20 @@ func TestContextCancelQuery(t *testing.T) {
26392699

26402700
// Check how many times the query is executed.
26412701
var v int
2642-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2702+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
26432703
dbt.Fatalf("%s", err.Error())
26442704
}
26452705
if v != 1 { // TODO: need to kill the query, and v should be 0.
26462706
dbt.Skipf("[WARN] expected val to be 1, got %d", v)
26472707
}
26482708

26492709
// Context is already canceled, so error should come before execution.
2650-
if _, err := dbt.db.QueryContext(ctx, "INSERT INTO test VALUES (1)"); err != context.Canceled {
2710+
if _, err := dbt.db.QueryContext(ctx, "INSERT INTO "+tbl+" VALUES (1)"); err != context.Canceled {
26512711
dbt.Errorf("expected context.Canceled, got %v", err)
26522712
}
26532713

26542714
// The second insert query will fail, so the table has no changes.
2655-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2715+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
26562716
dbt.Fatalf("%s", err.Error())
26572717
}
26582718
if v != 1 {
@@ -2662,12 +2722,12 @@ func TestContextCancelQuery(t *testing.T) {
26622722
}
26632723

26642724
func TestContextCancelQueryRow(t *testing.T) {
2665-
runTests(t, dsn, func(dbt *DBTest) {
2666-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2667-
dbt.mustExec("INSERT INTO test VALUES (1), (2), (3)")
2725+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2726+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
2727+
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1), (2), (3)")
26682728
ctx, cancel := context.WithCancel(context.Background())
26692729

2670-
rows, err := dbt.db.QueryContext(ctx, "SELECT v FROM test")
2730+
rows, err := dbt.db.QueryContext(ctx, "SELECT v FROM "+tbl)
26712731
if err != nil {
26722732
dbt.Fatalf("%s", err.Error())
26732733
}
@@ -2695,7 +2755,7 @@ func TestContextCancelQueryRow(t *testing.T) {
26952755
}
26962756

26972757
func TestContextCancelPrepare(t *testing.T) {
2698-
runTests(t, dsn, func(dbt *DBTest) {
2758+
runTestsParallel(t, dsn, func(dbt *DBTest, _ string) {
26992759
ctx, cancel := context.WithCancel(context.Background())
27002760
cancel()
27012761
if _, err := dbt.db.PrepareContext(ctx, "SELECT 1"); err != context.Canceled {
@@ -2705,10 +2765,10 @@ func TestContextCancelPrepare(t *testing.T) {
27052765
}
27062766

27072767
func TestContextCancelStmtExec(t *testing.T) {
2708-
runTests(t, dsn, func(dbt *DBTest) {
2709-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2768+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2769+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
27102770
ctx, cancel := context.WithCancel(context.Background())
2711-
stmt, err := dbt.db.PrepareContext(ctx, "INSERT INTO test VALUES (SLEEP(1))")
2771+
stmt, err := dbt.db.PrepareContext(ctx, "INSERT INTO "+tbl+" VALUES (SLEEP(1))")
27122772
if err != nil {
27132773
dbt.Fatalf("unexpected error: %v", err)
27142774
}
@@ -2730,7 +2790,7 @@ func TestContextCancelStmtExec(t *testing.T) {
27302790

27312791
// Check how many times the query is executed.
27322792
var v int
2733-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2793+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
27342794
dbt.Fatalf("%s", err.Error())
27352795
}
27362796
if v != 1 { // TODO: need to kill the query, and v should be 0.
@@ -2740,10 +2800,10 @@ func TestContextCancelStmtExec(t *testing.T) {
27402800
}
27412801

27422802
func TestContextCancelStmtQuery(t *testing.T) {
2743-
runTests(t, dsn, func(dbt *DBTest) {
2744-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2803+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2804+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
27452805
ctx, cancel := context.WithCancel(context.Background())
2746-
stmt, err := dbt.db.PrepareContext(ctx, "INSERT INTO test VALUES (SLEEP(1))")
2806+
stmt, err := dbt.db.PrepareContext(ctx, "INSERT INTO "+tbl+" VALUES (SLEEP(1))")
27472807
if err != nil {
27482808
dbt.Fatalf("unexpected error: %v", err)
27492809
}
@@ -2765,7 +2825,7 @@ func TestContextCancelStmtQuery(t *testing.T) {
27652825

27662826
// Check how many times the query is executed.
27672827
var v int
2768-
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
2828+
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
27692829
dbt.Fatalf("%s", err.Error())
27702830
}
27712831
if v != 1 { // TODO: need to kill the query, and v should be 0.
@@ -2779,8 +2839,8 @@ func TestContextCancelBegin(t *testing.T) {
27792839
t.Skip(`FIXME: it sometime fails with "expected driver.ErrBadConn, got sql: connection is already closed" on windows and macOS`)
27802840
}
27812841

2782-
runTests(t, dsn, func(dbt *DBTest) {
2783-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2842+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2843+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
27842844
ctx, cancel := context.WithCancel(context.Background())
27852845
conn, err := dbt.db.Conn(ctx)
27862846
if err != nil {
@@ -2797,7 +2857,7 @@ func TestContextCancelBegin(t *testing.T) {
27972857

27982858
// This query will be canceled.
27992859
startTime := time.Now()
2800-
if _, err := tx.ExecContext(ctx, "INSERT INTO test VALUES (SLEEP(1))"); err != context.Canceled {
2860+
if _, err := tx.ExecContext(ctx, "INSERT INTO "+tbl+" VALUES (SLEEP(1))"); err != context.Canceled {
28012861
dbt.Errorf("expected context.Canceled, got %v", err)
28022862
}
28032863
if d := time.Since(startTime); d > 500*time.Millisecond {
@@ -2835,8 +2895,8 @@ func TestContextCancelBegin(t *testing.T) {
28352895
}
28362896

28372897
func TestContextBeginIsolationLevel(t *testing.T) {
2838-
runTests(t, dsn, func(dbt *DBTest) {
2839-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2898+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2899+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
28402900
ctx, cancel := context.WithCancel(context.Background())
28412901
defer cancel()
28422902

@@ -2854,13 +2914,13 @@ func TestContextBeginIsolationLevel(t *testing.T) {
28542914
dbt.Fatal(err)
28552915
}
28562916

2857-
_, err = tx1.ExecContext(ctx, "INSERT INTO test VALUES (1)")
2917+
_, err = tx1.ExecContext(ctx, "INSERT INTO "+tbl+" VALUES (1)")
28582918
if err != nil {
28592919
dbt.Fatal(err)
28602920
}
28612921

28622922
var v int
2863-
row := tx2.QueryRowContext(ctx, "SELECT COUNT(*) FROM test")
2923+
row := tx2.QueryRowContext(ctx, "SELECT COUNT(*) FROM "+tbl)
28642924
if err := row.Scan(&v); err != nil {
28652925
dbt.Fatal(err)
28662926
}
@@ -2874,7 +2934,7 @@ func TestContextBeginIsolationLevel(t *testing.T) {
28742934
dbt.Fatal(err)
28752935
}
28762936

2877-
row = tx2.QueryRowContext(ctx, "SELECT COUNT(*) FROM test")
2937+
row = tx2.QueryRowContext(ctx, "SELECT COUNT(*) FROM "+tbl)
28782938
if err := row.Scan(&v); err != nil {
28792939
dbt.Fatal(err)
28802940
}
@@ -2887,8 +2947,8 @@ func TestContextBeginIsolationLevel(t *testing.T) {
28872947
}
28882948

28892949
func TestContextBeginReadOnly(t *testing.T) {
2890-
runTests(t, dsn, func(dbt *DBTest) {
2891-
dbt.mustExec("CREATE TABLE test (v INTEGER)")
2950+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
2951+
dbt.mustExec("CREATE TABLE " + tbl + " (v INTEGER)")
28922952
ctx, cancel := context.WithCancel(context.Background())
28932953
defer cancel()
28942954

@@ -2903,14 +2963,14 @@ func TestContextBeginReadOnly(t *testing.T) {
29032963
}
29042964

29052965
// INSERT queries fail in a READ ONLY transaction.
2906-
_, err = tx.ExecContext(ctx, "INSERT INTO test VALUES (1)")
2966+
_, err = tx.ExecContext(ctx, "INSERT INTO "+tbl+" VALUES (1)")
29072967
if _, ok := err.(*MySQLError); !ok {
29082968
dbt.Errorf("expected MySQLError, got %v", err)
29092969
}
29102970

29112971
// SELECT queries can be executed.
29122972
var v int
2913-
row := tx.QueryRowContext(ctx, "SELECT COUNT(*) FROM test")
2973+
row := tx.QueryRowContext(ctx, "SELECT COUNT(*) FROM "+tbl)
29142974
if err := row.Scan(&v); err != nil {
29152975
dbt.Fatal(err)
29162976
}
@@ -3147,9 +3207,9 @@ func TestRowsColumnTypes(t *testing.T) {
31473207
}
31483208

31493209
func TestValuerWithValueReceiverGivenNilValue(t *testing.T) {
3150-
runTests(t, dsn, func(dbt *DBTest) {
3151-
dbt.mustExec("CREATE TABLE test (value VARCHAR(255))")
3152-
dbt.db.Exec("INSERT INTO test VALUES (?)", (*testValuer)(nil))
3210+
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
3211+
dbt.mustExec("CREATE TABLE " + tbl + " (value VARCHAR(255))")
3212+
dbt.db.Exec("INSERT INTO "+tbl+" VALUES (?)", (*testValuer)(nil))
31533213
// This test will panic on the INSERT if ConvertValue() does not check for typed nil before calling Value()
31543214
})
31553215
}

0 commit comments

Comments
 (0)
Please sign in to comment.