|
|
@ -26,6 +26,7 @@ import ( |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"encoding/base64" |
|
|
|
"encoding/base64" |
|
|
@ -38,6 +39,10 @@ import ( |
|
|
|
. "gopkg.in/check.v1" |
|
|
|
. "gopkg.in/check.v1" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
|
|
ConcurrencyLevel = 10 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type MyAPIFSCacheSuite struct { |
|
|
|
type MyAPIFSCacheSuite struct { |
|
|
|
root string |
|
|
|
root string |
|
|
|
req *http.Request |
|
|
|
req *http.Request |
|
|
@ -586,21 +591,37 @@ func (s *MyAPIFSCacheSuite) TestHeader(c *C) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s *MyAPIFSCacheSuite) TestPutBucket(c *C) { |
|
|
|
func (s *MyAPIFSCacheSuite) TestPutBucket(c *C) { |
|
|
|
|
|
|
|
// Block 1: Testing for racey access
|
|
|
|
|
|
|
|
// The assertion is removed from this block since the purpose of this block is to find races
|
|
|
|
|
|
|
|
// The purpose this block is not to check for correctness of functionality
|
|
|
|
|
|
|
|
// Run the test with -race flag to utilize this
|
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
|
|
|
|
for i := 0; i < ConcurrencyLevel; i++ { |
|
|
|
|
|
|
|
wg.Add(1) |
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
defer wg.Done() |
|
|
|
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-bucket", 0, nil) |
|
|
|
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-bucket", 0, nil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
request.Header.Add("x-amz-acl", "private") |
|
|
|
|
|
|
|
|
|
|
|
client := http.Client{} |
|
|
|
client := http.Client{} |
|
|
|
response, err := client.Do(request) |
|
|
|
response, err := client.Do(request) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
defer response.Body.Close() |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
}() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
wg.Wait() |
|
|
|
|
|
|
|
|
|
|
|
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-bucket-slash/", 0, nil) |
|
|
|
//Block 2: testing for correctness of the functionality
|
|
|
|
|
|
|
|
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/put-bucket-slash/", 0, nil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
|
|
|
|
request.Header.Add("x-amz-acl", "private") |
|
|
|
|
|
|
|
|
|
|
|
client = http.Client{} |
|
|
|
client := http.Client{} |
|
|
|
response, err = client.Do(request) |
|
|
|
response, err := client.Do(request) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(err, IsNil) |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
c.Assert(response.StatusCode, Equals, http.StatusOK) |
|
|
|
|
|
|
|
response.Body.Close() |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (s *MyAPIFSCacheSuite) TestCopyObject(c *C) { |
|
|
|
func (s *MyAPIFSCacheSuite) TestCopyObject(c *C) { |
|
|
|