mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-04 11:07:35 +01:00
filer: clear a dead test replica's reachability record before closing it (#12387)
* filer: clear a dead test replica's reachability record before closing it The read path tries hosts that recently failed last. A dead test server can land on a port an earlier test left marked as failed, so the live replica answered first, nothing failed and the location refresh under test never ran. Have the dead replica answer once through util_http so its record is cleared before it closes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: close the dead test replica when reaching it fails Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: clear the live test replica's reachability record too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
329ccb8bc0
commit
ba3fd257a3
2 files changed
+25
-7
No files matched your search
@@ -652,10 +652,10 @@ func TestFetchWholeChunkRefreshesLocationsAfterPartialFailure(t *testing.T) {
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
liveURL := manifestServer(t, manifestBytes).URL + "/5,abc"
|
||||
dead := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
deadURL := dead.URL
|
||||
dead.Close()
|
||||
live := manifestServer(t, manifestBytes)
|
||||
reachServer(t, live)
|
||||
liveURL := live.URL + "/5,abc"
|
||||
deadURL := deadServerURL(t)
|
||||
|
||||
lookup := &stagedLookup{
|
||||
staleUrls: []string{deadURL + "/5,abc", liveURL},
|
||||
|
||||
@@ -160,9 +160,8 @@ func TestReaderCacheRefreshesLocationsAfterPartialFailure(t *testing.T) {
|
||||
w.Write(payload)
|
||||
}))
|
||||
defer live.Close()
|
||||
dead := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
deadURL := dead.URL
|
||||
dead.Close()
|
||||
reachServer(t, live)
|
||||
deadURL := deadServerURL(t)
|
||||
|
||||
fileId := "3,abc"
|
||||
invalidator := &mockCacheInvalidatorForReaderCache{}
|
||||
@@ -191,6 +190,25 @@ func TestReaderCacheRefreshesLocationsAfterPartialFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// reachServer has srv answer one request. The read path orders replicas by
|
||||
// whether their host recently failed, and srv's port may be one an earlier test
|
||||
// left marked as failed, so the answer clears that record.
|
||||
func reachServer(t *testing.T, srv *httptest.Server) {
|
||||
t.Helper()
|
||||
if _, _, err := util_http.Get(srv.URL); err != nil {
|
||||
t.Fatalf("reach %s: %v", srv.URL, err)
|
||||
}
|
||||
}
|
||||
|
||||
// deadServerURL is a replica that answered once and then went away.
|
||||
func deadServerURL(t *testing.T) string {
|
||||
t.Helper()
|
||||
dead := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
|
||||
defer dead.Close()
|
||||
reachServer(t, dead)
|
||||
return dead.URL
|
||||
}
|
||||
|
||||
func TestReaderCacheRemovesFailedDownloader(t *testing.T) {
|
||||
cache := newMockChunkCacheForReaderCache()
|
||||
fileId := "425141,failed"
|
||||
|
||||
Reference in new issue
Block a user