router: add singleflight deduplication for concurrent narinfo races
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib682889f34ad4ad4fb331ee2924dc9916a6a6964
This commit is contained in:
parent
e567491856
commit
41b18dd1f8
8 changed files with 90 additions and 18 deletions
|
|
@ -38,7 +38,7 @@ func TestRouteReuseOnSecondRequest(t *testing.T) {
|
|||
|
||||
p := prober.New(0.3)
|
||||
p.RecordLatency(upstream.URL, 10)
|
||||
r := router.New(db, p, time.Hour, 5*time.Second)
|
||||
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
|
||||
ts := httptest.NewServer(server.New(r, p, []config.UpstreamConfig{{URL: upstream.URL}}))
|
||||
defer ts.Close()
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ func TestUpstreamFailoverFallback(t *testing.T) {
|
|||
p.RecordLatency(bad.URL, 1) // bad appears fastest
|
||||
p.RecordLatency(good.URL, 50)
|
||||
|
||||
r := router.New(db, p, time.Hour, 5*time.Second)
|
||||
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
|
||||
ts := httptest.NewServer(server.New(r, p, []config.UpstreamConfig{
|
||||
{URL: bad.URL},
|
||||
{URL: good.URL},
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func makeTestServer(t *testing.T, upstreams ...string) *httptest.Server {
|
|||
upsCfg[i] = config.UpstreamConfig{URL: u}
|
||||
}
|
||||
|
||||
r := router.New(db, p, time.Hour, 5*time.Second)
|
||||
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
|
||||
return httptest.NewServer(server.New(r, p, upsCfg))
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ func TestNARFallbackWhenFirstUpstreamMissing(t *testing.T) {
|
|||
p.RecordLatency(hasIt.URL, 50)
|
||||
|
||||
upsCfg := []config.UpstreamConfig{{URL: missing.URL}, {URL: hasIt.URL}}
|
||||
r := router.New(db, p, time.Hour, 5*time.Second)
|
||||
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
|
||||
ts := httptest.NewServer(server.New(r, p, upsCfg))
|
||||
defer ts.Close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue