server: route NAR requests via route cache; extract tryNARUpstream helper
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Icd57a268015d58faa7ffc2b8c711283b6a6a6964
This commit is contained in:
parent
ded9b6d464
commit
118eda08a1
4 changed files with 114 additions and 44 deletions
|
|
@ -39,7 +39,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, 10*time.Minute)
|
||||
ts := httptest.NewServer(server.New(r, p, []config.UpstreamConfig{{URL: upstream.URL}}))
|
||||
ts := httptest.NewServer(server.New(r, p, db, []config.UpstreamConfig{{URL: upstream.URL}}, 30))
|
||||
defer ts.Close()
|
||||
|
||||
resp1, _ := http.Get(ts.URL + "/deadbeef00000000.narinfo")
|
||||
|
|
@ -79,10 +79,10 @@ func TestUpstreamFailoverFallback(t *testing.T) {
|
|||
p.RecordLatency(good.URL, 50)
|
||||
|
||||
r := router.New(db, p, time.Hour, 5*time.Second, 10*time.Minute)
|
||||
ts := httptest.NewServer(server.New(r, p, []config.UpstreamConfig{
|
||||
ts := httptest.NewServer(server.New(r, p, db, []config.UpstreamConfig{
|
||||
{URL: bad.URL},
|
||||
{URL: good.URL},
|
||||
}))
|
||||
}, 30))
|
||||
defer ts.Close()
|
||||
|
||||
resp, err := http.Get(ts.URL + "/cafebabe00000000.narinfo")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue