Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer: clear a dead test replica's reachability record before closing it (#12387)

Chris Luba3fd257a3fd
diff --git a/weed/filer/filechunk_manifest_test.go b/weed/filer/filechunk_manifest_test.go
index 5e82c70459..039399f31e 100644
--- a/weed/filer/filechunk_manifest_test.go
+++ b/weed/filer/filechunk_manifest_test.go
@@ -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},
diff --git a/weed/filer/reader_cache_test.go b/weed/filer/reader_cache_test.go
index 16c3531f50..faf184f878 100644
--- a/weed/filer/reader_cache_test.go
+++ b/weed/filer/reader_cache_test.go
@@ -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"