|
|
@ -1833,25 +1833,23 @@ func (s *TestSuiteCommon) TestGetPartialObjectMisAligned(c *C) { |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
|
|
|
|
|
|
|
|
var buffer bytes.Buffer |
|
|
|
var buffer bytes.Buffer |
|
|
|
line := `1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
// data to be written into buffer.
|
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
data := "1234567890" |
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
// seed the random number generator once.
|
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
rand.Seed(3) |
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
// generate a random number between 13 and 200.
|
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
randInt := getRandomRange(13, 200, -1) |
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
// write into buffer till length of the buffer is greater than the generated random number.
|
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
for i := 0; i <= randInt; i += 10 { |
|
|
|
1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, |
|
|
|
buffer.WriteString(data) |
|
|
|
1234567890,1234567890,1234567890,123` |
|
|
|
} |
|
|
|
|
|
|
|
// String content which is used for put object range test.
|
|
|
|
rand.Seed(UTCNow().UnixNano()) |
|
|
|
putBytes := buffer.Bytes() |
|
|
|
// Create a misalgined data.
|
|
|
|
putBytes = putBytes[:randInt] |
|
|
|
for i := 0; i < 13*rand.Intn(1<<16); i++ { |
|
|
|
// randomize the order of bytes in the byte array and create a reader.
|
|
|
|
buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line[:rand.Intn(1<<8)])) |
|
|
|
putBytes = randomizeBytes(putBytes, -1) |
|
|
|
} |
|
|
|
buf := bytes.NewReader(putBytes) |
|
|
|
putContent := buffer.String() |
|
|
|
putContent := string(putBytes) |
|
|
|
buf := bytes.NewReader([]byte(putContent)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectName := "test-big-file" |
|
|
|
objectName := "test-big-file" |
|
|
|
// HTTP request to upload the object.
|
|
|
|
// HTTP request to upload the object.
|
|
|
|
request, err = newTestSignedRequest("PUT", getPutObjectURL(s.endPoint, bucketName, objectName), |
|
|
|
request, err = newTestSignedRequest("PUT", getPutObjectURL(s.endPoint, bucketName, objectName), |
|
|
@ -1882,6 +1880,7 @@ func (s *TestSuiteCommon) TestGetPartialObjectMisAligned(c *C) { |
|
|
|
// request for last 7 bytes of the object.
|
|
|
|
// request for last 7 bytes of the object.
|
|
|
|
{"-7", putContent[len(putContent)-7:]}, |
|
|
|
{"-7", putContent[len(putContent)-7:]}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, t := range testCases { |
|
|
|
for _, t := range testCases { |
|
|
|
// HTTP request to download the object.
|
|
|
|
// HTTP request to download the object.
|
|
|
|
request, err = newTestSignedRequest("GET", getGetObjectURL(s.endPoint, bucketName, objectName), |
|
|
|
request, err = newTestSignedRequest("GET", getGetObjectURL(s.endPoint, bucketName, objectName), |
|
|
|