2
0

TestStressConnPool now runs for X iterations

...instead of T time. Also run in parallel.
This commit is contained in:
Jack Christensen
2017-03-03 15:44:17 -06:00
parent 91dea95b68
commit eb484e1368
+9 -8
View File
@@ -3,11 +3,12 @@ package pgx_test
import (
"errors"
"fmt"
"golang.org/x/net/context"
"math/rand"
"testing"
"time"
"golang.org/x/net/context"
"github.com/jackc/fake"
"github.com/jackc/pgx"
)
@@ -23,6 +24,8 @@ type queryRower interface {
}
func TestStressConnPool(t *testing.T) {
t.Parallel()
maxConnections := 8
pool := createConnPool(t, maxConnections)
defer pool.Close()
@@ -49,11 +52,12 @@ func TestStressConnPool(t *testing.T) {
{"canceledExecContext", canceledExecContext},
}
var timer *time.Timer
var actionCount int
if testing.Short() {
timer = time.NewTimer(5 * time.Second)
actionCount = 1000
} else {
timer = time.NewTimer(60 * time.Second)
actionCount = 10000
}
workerCount := 16
@@ -77,11 +81,8 @@ func TestStressConnPool(t *testing.T) {
go work()
}
var stop bool
for i := 0; !stop; i++ {
for i := 0; i < actionCount; i++ {
select {
case <-timer.C:
stop = true
case workChan <- i:
case err := <-errChan:
close(workChan)