mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 22:40:39 +02:00
test: fix HEAD bucket assertions and FUSE failover startup timing (#11967)
test: fix HEAD bucket assertions and warm up failover clusters
This commit is contained in:
1 parent
137d29633b
commit
8f6121694a
2 files changed
+19
-6
No files matched your search
@@ -110,6 +110,21 @@ func startFailoverCluster(t testing.TB, numVolumes, numMounts int) *failoverClus
|
||||
"mount %d not ready\n%s", i, c.tailLog(fmt.Sprintf("mount%d", i)))
|
||||
}
|
||||
require.NoError(t, c.WaitForVolumeServers(60*time.Second))
|
||||
|
||||
// A mounted filesystem and registered volume servers do not yet guarantee
|
||||
// that the lock ring has settled or the first replicated volume is ready.
|
||||
// Exercise the write/read path during setup so the append latency checks
|
||||
// measure failover on a running cluster rather than its cold start.
|
||||
probeName := ".failover-ready"
|
||||
probeData := []byte("ready\n")
|
||||
probePath := filepath.Join(c.MountDir(0), probeName)
|
||||
require.NoError(t, os.WriteFile(probePath, probeData, 0644),
|
||||
"readiness write failed\n%s", c.tailLog("mount0"))
|
||||
for i := 0; i < numMounts; i++ {
|
||||
_, ready := waitForContent(filepath.Join(c.MountDir(i), probeName), probeData, convergeTimeout)
|
||||
require.True(t, ready, "mount %d did not observe readiness write\n%s", i, c.tailLog(fmt.Sprintf("mount%d", i)))
|
||||
}
|
||||
require.NoError(t, os.Remove(probePath))
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@@ -56,19 +55,16 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) {
|
||||
name string
|
||||
filer *fakeLookupFiler
|
||||
wantCode int
|
||||
wantBody string
|
||||
}{
|
||||
{
|
||||
name: "transient lookup failure",
|
||||
filer: &fakeLookupFiler{lookupErr: status.Error(codes.Internal, "filer store unavailable")},
|
||||
wantCode: http.StatusInternalServerError,
|
||||
wantBody: "<Code>InternalError</Code>",
|
||||
},
|
||||
{
|
||||
name: "missing bucket",
|
||||
filer: &fakeLookupFiler{},
|
||||
wantCode: http.StatusNotFound,
|
||||
wantBody: "<Code>NoSuchBucket</Code>",
|
||||
},
|
||||
{
|
||||
name: "existing bucket",
|
||||
@@ -88,8 +84,10 @@ func TestHeadBucketSeparatesLookupFailureFromMissingBucket(t *testing.T) {
|
||||
if rr.Code != tc.wantCode {
|
||||
t.Fatalf("status = %d, want %d: %s", rr.Code, tc.wantCode, rr.Body.String())
|
||||
}
|
||||
if tc.wantBody != "" && !strings.Contains(rr.Body.String(), tc.wantBody) {
|
||||
t.Fatalf("body = %s, want %s", rr.Body.String(), tc.wantBody)
|
||||
// HEAD returns the status without an XML error body, including for
|
||||
// lookup failures and missing buckets.
|
||||
if rr.Body.Len() != 0 {
|
||||
t.Fatalf("HEAD response must have an empty body, got %q", rr.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user