mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-09 05:18:23 +01:00
test(volume_server/http): cover oversized upload file-size limit rejection
This commit is contained in:
1 parent
3ce883624e
commit
4d61cbdeed
3 files changed
+34
No files matched your search
@@ -208,6 +208,9 @@ func (c *Cluster) startVolume(dataDir string) error {
|
|||||||
if c.profile.InflightDownloadTimeout > 0 {
|
if c.profile.InflightDownloadTimeout > 0 {
|
||||||
args = append(args, "-inflightDownloadDataTimeout="+c.profile.InflightDownloadTimeout.String())
|
args = append(args, "-inflightDownloadDataTimeout="+c.profile.InflightDownloadTimeout.String())
|
||||||
}
|
}
|
||||||
|
if c.profile.FileSizeLimitMB > 0 {
|
||||||
|
args = append(args, "-fileSizeLimitMB="+strconv.Itoa(c.profile.FileSizeLimitMB))
|
||||||
|
}
|
||||||
|
|
||||||
c.volumeCmd = exec.Command(c.volumeBinary, args...)
|
c.volumeCmd = exec.Command(c.volumeBinary, args...)
|
||||||
c.volumeCmd.Dir = c.baseDir
|
c.volumeCmd.Dir = c.baseDir
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package volume_server_http_test
|
package volume_server_http_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -72,3 +73,32 @@ func TestWriteMalformedMultipartAndMD5Mismatch(t *testing.T) {
|
|||||||
t.Fatalf("content-md5 mismatch response should mention Content-MD5, got %q", string(md5MismatchBody))
|
t.Fatalf("content-md5 mismatch response should mention Content-MD5, got %q", string(md5MismatchBody))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWriteRejectsPayloadOverFileSizeLimit(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping integration test in short mode")
|
||||||
|
}
|
||||||
|
|
||||||
|
profile := matrix.P1()
|
||||||
|
profile.FileSizeLimitMB = 1
|
||||||
|
clusterHarness := framework.StartSingleVolumeCluster(t, profile)
|
||||||
|
conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress())
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
const volumeID = uint32(99)
|
||||||
|
framework.AllocateVolume(t, grpcClient, volumeID, "")
|
||||||
|
|
||||||
|
client := framework.NewHTTPClient()
|
||||||
|
fid := framework.NewFileID(volumeID, 772002, 0x2A3B4C5D)
|
||||||
|
oversizedPayload := bytes.Repeat([]byte("z"), 1024*1024+1)
|
||||||
|
|
||||||
|
oversizedReq := newUploadRequest(t, clusterHarness.VolumeAdminURL()+"/"+fid, oversizedPayload)
|
||||||
|
oversizedResp := framework.DoRequest(t, client, oversizedReq)
|
||||||
|
oversizedBody := framework.ReadAllAndClose(t, oversizedResp)
|
||||||
|
if oversizedResp.StatusCode != http.StatusBadRequest {
|
||||||
|
t.Fatalf("oversized write expected 400, got %d", oversizedResp.StatusCode)
|
||||||
|
}
|
||||||
|
if !strings.Contains(strings.ToLower(string(oversizedBody)), "limited") {
|
||||||
|
t.Fatalf("oversized write response should mention limit, got %q", string(oversizedBody))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ type Profile struct {
|
|||||||
ConcurrentDownloadLimitMB int
|
ConcurrentDownloadLimitMB int
|
||||||
InflightUploadTimeout time.Duration
|
InflightUploadTimeout time.Duration
|
||||||
InflightDownloadTimeout time.Duration
|
InflightDownloadTimeout time.Duration
|
||||||
|
FileSizeLimitMB int
|
||||||
|
|
||||||
ReplicatedLayout bool
|
ReplicatedLayout bool
|
||||||
HasErasureCoding bool
|
HasErasureCoding bool
|
||||||
|
|||||||
Reference in new issue
Block a user