Skip to content

Parallelize test #1525

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

Merged
merged 42 commits into from
Dec 13, 2023
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
29f86f6
Refactor test cleanup in driver_test.go
shogo82148 Dec 12, 2023
f4000b8
parallelize TestEmptyQuery and TestCRUD
shogo82148 Dec 12, 2023
f49d8d6
parallelize TestNumbersToAny
shogo82148 Dec 12, 2023
7b9d720
parallelize TestInt
shogo82148 Dec 12, 2023
d4c6d67
parallelize TestFloat32
shogo82148 Dec 12, 2023
d1f38fe
parallelize TestFloat64
shogo82148 Dec 12, 2023
7845ed9
parallelize TestFloat64Placeholder
shogo82148 Dec 12, 2023
2a45b17
parallelize TestString
shogo82148 Dec 12, 2023
51cd376
parallelize TestRawBytes
shogo82148 Dec 12, 2023
9fd81fd
parallelize TestRawMessage
shogo82148 Dec 12, 2023
b0de07f
parallelize TestValuer
shogo82148 Dec 12, 2023
daa5b38
parallelize TestValuerWithValidation
shogo82148 Dec 12, 2023
082c897
parallelize TestTimestampMicros
shogo82148 Dec 12, 2023
a932883
parallelize TestNULL
shogo82148 Dec 12, 2023
2242274
parallelize TestUint64
shogo82148 Dec 12, 2023
a360be7
parallelize TestLongData
shogo82148 Dec 12, 2023
01f85ba
parallelize TestContextCancelExec
shogo82148 Dec 12, 2023
06c953a
parallelize TestPingContext
shogo82148 Dec 12, 2023
3deb8b4
parallelize TestContextCancelQuery
shogo82148 Dec 12, 2023
f69130a
parallelize TestContextCancelQueryRow
shogo82148 Dec 12, 2023
dfef6a0
Revert "parallelize TestLongData"
shogo82148 Dec 12, 2023
c9febfc
parallelize TestContextCancelPrepare
shogo82148 Dec 12, 2023
18dca94
parallelize TestContextCancelStmtExec
shogo82148 Dec 12, 2023
5a670dc
parallelize TestContextCancelStmtQuery
shogo82148 Dec 12, 2023
7af63b5
parallelize TestContextCancelBegin
shogo82148 Dec 12, 2023
d7650a1
parallelize TestContextBeginIsolationLevel
shogo82148 Dec 12, 2023
5e17499
parallelize TestContextBeginReadOnly
shogo82148 Dec 12, 2023
987e2b1
parallelize TestValuerWithValueReceiverGivenNilValue
shogo82148 Dec 12, 2023
91622f0
parallelize TestRawBytesAreNotModified
shogo82148 Dec 12, 2023
fb42bbd
parallelize TestFoundRows
shogo82148 Dec 12, 2023
91b4065
parallelize TestRowsClose
shogo82148 Dec 12, 2023
d224202
parallelize TestCloseStmtBeforeRows
shogo82148 Dec 12, 2023
375bfee
parallelize TestStmtMultiRows
shogo82148 Dec 12, 2023
4022dd2
Revert "parallelize TestRawBytesAreNotModified"
shogo82148 Dec 12, 2023
dd2e1fb
parallelize TestStaleConnectionChecks
shogo82148 Dec 12, 2023
a656904
parallelize TestFailingCharset
shogo82148 Dec 12, 2023
b6c2590
parallelize TestColumnsWithAlias
shogo82148 Dec 12, 2023
37fc741
parallelize TestRawBytesResultExceedsBuffer
shogo82148 Dec 12, 2023
b3df7bd
parallelize TestUnixSocketAuthFail
shogo82148 Dec 12, 2023
ae497ae
parallelize TestSkipResults
shogo82148 Dec 12, 2023
8a46603
Add parallel flag to go test command
shogo82148 Dec 12, 2023
5965ccb
Revert "parallelize TestUnixSocketAuthFail"
shogo82148 Dec 13, 2023
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
Prev Previous commit
Next Next commit
parallelize TestContextCancelExec
  • Loading branch information
shogo82148 committed Dec 12, 2023
commit 01f85bafe1929d30b39ba66491838244473ff4c1
12 changes: 6 additions & 6 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2629,16 +2629,16 @@ func TestPingContext(t *testing.T) {
}

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

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

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

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

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

// The second insert query will fail, so the table has no changes.
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM test").Scan(&v); err != nil {
if err := dbt.db.QueryRow("SELECT COUNT(*) FROM " + tbl).Scan(&v); err != nil {
dbt.Fatalf("%s", err.Error())
}
if v != 1 {
Expand Down