Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
Merge pull request #46 from libp2p/test-timeout
Browse files Browse the repository at this point in the history
pick test timeout from env var if available.
  • Loading branch information
raulk authored Mar 1, 2019
2 parents 740bd12 + 6fccfa8 commit 698a059
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"io"
"io/ioutil"
mrand "math/rand"
"os"
"runtime/debug"
"strconv"
"sync"
"testing"
"time"
Expand All @@ -25,12 +27,20 @@ var VerboseDebugging = false

var randomness []byte

var StressTestTimeout = 1 * time.Minute

func init() {
// read 1MB of randomness
randomness = make([]byte, 1<<20)
if _, err := crand.Read(randomness); err != nil {
panic(err)
}

if timeout := os.Getenv("TEST_STRESS_TIMEOUT_MS"); timeout != "" {
if v, err := strconv.ParseInt(timeout, 10, 32); err == nil {
StressTestTimeout = time.Duration(v) * time.Millisecond
}
}
}

type Options struct {
Expand Down Expand Up @@ -342,7 +352,7 @@ func SubtestStreamOpenStress(t *testing.T, ta, tb tpt.Transport, maddr ma.Multia
}
}()

timeout := time.After(time.Minute * 1)
timeout := time.After(StressTestTimeout)
done := make(chan struct{})

go func() {
Expand Down

0 comments on commit 698a059

Please sign in to comment.