From 8577dccd65312eecac353c96d908f8796d49f54c Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 12 Dec 2015 17:35:24 -0600 Subject: [PATCH] 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. --- stress_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/stress_test.go b/stress_test.go index 3b14b587..67642b3e 100644 --- a/stress_test.go +++ b/stress_test.go @@ -44,9 +44,11 @@ func TestStressConnPool(t *testing.T) { {"reset", func(p *pgx.ConnPool, n int) error { p.Reset(); return nil }}, } - actionCount := 5000 + var timer *time.Timer if testing.Short() { - actionCount /= 10 + timer = time.NewTimer(5 * time.Second) + } else { + timer = time.NewTimer(60 * time.Second) } workerCount := 16 @@ -70,8 +72,11 @@ func TestStressConnPool(t *testing.T) { go work() } - for i := 0; i < actionCount; i++ { + var stop bool + for i := 0; !stop; i++ { select { + case <-timer.C: + stop = true case workChan <- i: case err := <-errChan: close(workChan)