mirror of https://github.com/jackc/pgx.git
Make ConnPoll stress test time based
Test now runs for fixed amount of time instead of a fixed number of iterations. This should enable TravisCI to finish the test.extract-for-data
parent
d84ee5c18a
commit
8577dccd65
|
@ -44,9 +44,11 @@ func TestStressConnPool(t *testing.T) {
|
||||||
{"reset", func(p *pgx.ConnPool, n int) error { p.Reset(); return nil }},
|
{"reset", func(p *pgx.ConnPool, n int) error { p.Reset(); return nil }},
|
||||||
}
|
}
|
||||||
|
|
||||||
actionCount := 5000
|
var timer *time.Timer
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
actionCount /= 10
|
timer = time.NewTimer(5 * time.Second)
|
||||||
|
} else {
|
||||||
|
timer = time.NewTimer(60 * time.Second)
|
||||||
}
|
}
|
||||||
workerCount := 16
|
workerCount := 16
|
||||||
|
|
||||||
|
@ -70,8 +72,11 @@ func TestStressConnPool(t *testing.T) {
|
||||||
go work()
|
go work()
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < actionCount; i++ {
|
var stop bool
|
||||||
|
for i := 0; !stop; i++ {
|
||||||
select {
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
stop = true
|
||||||
case workChan <- i:
|
case workChan <- i:
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
close(workChan)
|
close(workChan)
|
||||||
|
|
Loading…
Reference in New Issue