"regexp"
"sort"
"strings"
+ "time"
)
// ----------------------------------------------------------------------------
//
func NewIndex(dirnames <-chan string, fulltextIndex bool, throttle float64) *Index {
var x Indexer
- th := NewThrottle(throttle, 0.1e9) // run at least 0.1s at a time
+ th := NewThrottle(throttle, 100*time.Millisecond) // run at least 0.1s at a time
// initialize Indexer
// (use some reasonably sized maps to start)
}
// We expect this event to be received almost immediately, but let's wait 1 s to be sure
- time.Sleep(1000e6) // 1000 ms
+ time.Sleep(1 * time.Second)
if eventsReceived == 0 {
t.Fatal("inotify event hasn't been received after 1 second")
}
select {
case <-done:
t.Log("event channel closed")
- case <-time.After(1e9):
+ case <-time.After(1 * time.Second):
t.Fatal("event stream was not closed after 1 second")
}
}
done = true
}()
- time.Sleep(50e6) // 50 ms
+ time.Sleep(50 * time.Millisecond)
if !done {
t.Fatal("double Close() test failed: second Close() call didn't return")
}
norm.NFC.Append(nil, buf...)
success <- true
}()
- timeout := time.After(1e9)
+ timeout := time.After(1 * time.Second)
select {
case <-success:
// test completed before the timeout
if event.Name != name || event.Mask != mask {
t.Fatal("did not receive expected event")
}
- case <-time.After(1e9):
+ case <-time.After(1 * time.Second):
t.Fatal("timed out waiting for event")
}
}
done = true
}()
- time.Sleep(50e6) // 50 ms
+ time.Sleep(50 * time.Millisecond)
if !done {
t.Fatal("double Close() test failed: second Close() call didn't return")
}
// start a timer to produce a time-out signal
tc := make(chan int)
go func() {
- time.Sleep(10e9) // plenty of a safety margin, even for very slow machines
+ time.Sleep(10 * time.Second) // plenty of a safety margin, even for very slow machines
tc <- 0
}()
}
func delayClose(t *testing.T, cl closer, ch chan int, tt pipeTest) {
- time.Sleep(1e6) // 1 ms
+ time.Sleep(1 * time.Millisecond)
var err error
if tt.closeWithError {
err = cl.CloseWithError(tt.err)
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
- ReadTimeout: 10e9,
- WriteTimeout: 10e9,
+ ReadTimeout: 10 * time.Second,
+ WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(s.ListenAndServe())
func TestTLSHandshakeTimeout(t *testing.T) {
ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {}))
- ts.Config.ReadTimeout = 250e6
+ ts.Config.ReadTimeout = 250 * time.Millisecond
ts.StartTLS()
defer ts.Close()
conn, err := net.Dial("tcp", ts.Listener.Addr().String())
// A Server defines parameters for running an HTTP server.
type Server struct {
- Addr string // TCP address to listen on, ":http" if empty
- Handler Handler // handler to invoke, http.DefaultServeMux if nil
- ReadTimeout int64 // the net.Conn.SetReadTimeout value for new connections
- WriteTimeout int64 // the net.Conn.SetWriteTimeout value for new connections
- MaxHeaderBytes int // maximum size of request headers, DefaultMaxHeaderBytes if 0
+ Addr string // TCP address to listen on, ":http" if empty
+ Handler Handler // handler to invoke, http.DefaultServeMux if nil
+ ReadTimeout time.Duration // the net.Conn.SetReadTimeout value for new connections
+ WriteTimeout time.Duration // the net.Conn.SetWriteTimeout value for new connections
+ MaxHeaderBytes int // maximum size of request headers, DefaultMaxHeaderBytes if 0
}
// ListenAndServe listens on the TCP network address srv.Addr and then
return e
}
if srv.ReadTimeout != 0 {
- rw.SetReadTimeout(srv.ReadTimeout)
+ rw.SetReadTimeout(srv.ReadTimeout.Nanoseconds())
}
if srv.WriteTimeout != 0 {
- rw.SetWriteTimeout(srv.WriteTimeout)
+ rw.SetWriteTimeout(srv.WriteTimeout.Nanoseconds())
}
c, err := srv.newConn(rw)
if err != nil {
// it on most fast machines, causing the next fetch() call to
// succeed quickly. But if we do get errors, fetch() will retry 5
// times with some delays between.
- time.Sleep(25e6)
+ time.Sleep(25 * time.Millisecond)
body3 := fetch(3, 5)
)
const (
- second = 1e9
newHttpPath = "/foo"
)
}
func (WriteFailCodec) ReadResponseHeader(*Response) error {
- time.Sleep(120e9)
+ time.Sleep(120 * time.Second)
panic("unreachable")
}
func (WriteFailCodec) ReadResponseBody(interface{}) error {
- time.Sleep(120e9)
+ time.Sleep(120 * time.Second)
panic("unreachable")
}
select {
case <-done:
return
- case <-time.After(5e9):
+ case <-time.After(5 * time.Second):
t.Fatal("deadlock")
}
}
if timeout > 0 && time.Now().After(deadline) {
return errors.New("timeout")
}
- time.Sleep(100 * 1e6) // 100 milliseconds
+ time.Sleep(100 * time.Millisecond)
}
return nil
}
if timeout > 0 && time.Now().After(deadline) {
return errors.New("timeout")
}
- time.Sleep(100 * 1e6) // 100 milliseconds
+ time.Sleep(100 * time.Millisecond)
}
return nil
}
if timeout > 0 && time.Now().After(deadline) {
return errors.New("timeout")
}
- time.Sleep(100 * 1e6)
+ time.Sleep(100 * time.Millisecond)
}
return nil
}
// Expect an error now. Start a timeout.
timeout := make(chan bool, 1) // buffered so closure will not hang around.
go func() {
- time.Sleep(10e9) // very long, to give even really slow machines a chance.
+ time.Sleep(10 * time.Second) // very long, to give even really slow machines a chance.
timeout <- true
}()
select {
go importReceive(imp, t, done)
// wait for export side to try to deliver some values.
- time.Sleep(0.25e9)
+ time.Sleep(250 * time.Millisecond)
ctlch := make(chan int)
if err := imp.ImportNValues("exportedCtl", ctlch, Send, 1, 1); err != nil {
func testFlow(sendDone chan bool, ch <-chan int, N int, t *testing.T) {
go func() {
- time.Sleep(0.5e9)
+ time.Sleep(500 * time.Millisecond)
sendDone <- false
}()