Commit 43573797 authored by Alberto Bertogli's avatar Alberto Bertogli

test: Implement retries on the load generator

If the load generator is sending emails too fast, chasquid queue might
hit the maximum size and fail the test.

This patch makes it sleep and retry, to give the server some time to
catch up.

Thanks to Max Mazurov ([email protected]) for reporting this problem.
parent 35c2d1d4
Pipeline #130638451 passed with stages
in 8 minutes and 48 seconds
......@@ -7,6 +7,7 @@ import (
"flag"
"net"
"net/http"
"net/textproto"
"runtime"
"sync"
"time"
......@@ -172,6 +173,7 @@ func one() error {
return err
}
retry:
w, err := client.Data()
if err != nil {
return err
......@@ -182,6 +184,16 @@ func one() error {
}
err = w.Close()
if err != nil {
// If we are sending too fast we might hit chasquid's queue size
// limit. In that case, wait and try again.
// We detect it with error code 451 which is used for this
// situation.
if terr, ok := err.(*textproto.Error); ok {
if terr.Code == 451 {
time.Sleep(10 * time.Millisecond)
goto retry
}
}
return err
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment