mirror of
https://github.com/minio/minio.git
synced 2025-02-26 04:49:16 -05:00
Merge pull request #717 from harshavardhana/pr_out_add_rpc_tests
This commit is contained in:
commit
c76d4f6cdd
11
commands.go
11
commands.go
@ -101,7 +101,7 @@ func runController(c *cli.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Unable to determine current user. Reason: %s\n", err)
|
Fatalf("Unable to determine current user. Reason: %s\n", err)
|
||||||
}
|
}
|
||||||
if len(c.Args()) <= 2 || c.Args().First() == "help" {
|
if len(c.Args()) < 2 || c.Args().First() == "help" {
|
||||||
cli.ShowCommandHelpAndExit(c, "controller", 1) // last argument is exit code
|
cli.ShowCommandHelpAndExit(c, "controller", 1) // last argument is exit code
|
||||||
}
|
}
|
||||||
switch c.Args().First() {
|
switch c.Args().First() {
|
||||||
@ -117,7 +117,16 @@ func runController(c *cli.Context) {
|
|||||||
Fatalln(err)
|
Fatalln(err)
|
||||||
}
|
}
|
||||||
Println(string(memstats))
|
Println(string(memstats))
|
||||||
|
case "sysinfo":
|
||||||
|
sysinfo, err := controller.GetSysInfo(c.Args().Tail().First())
|
||||||
|
if err != nil {
|
||||||
|
Fatalln(err)
|
||||||
|
}
|
||||||
|
Println(string(sysinfo))
|
||||||
case "donut":
|
case "donut":
|
||||||
|
if len(c.Args()) <= 2 || c.Args().First() == "help" {
|
||||||
|
cli.ShowCommandHelpAndExit(c, "controller", 1) // last argument is exit code
|
||||||
|
}
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
err := controller.SetDonut(c.Args().Tail().First(), hostname, c.Args().Tail().Tail())
|
err := controller.SetDonut(c.Args().Tail().First(), hostname, c.Args().Tail().Tail())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -47,8 +47,30 @@ func GetDisks(url string) ([]string, error) {
|
|||||||
return reply.Disks, nil
|
return reply.Disks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMemStats get system info of the server at given url
|
// GetMemStats get memory status of the server at given url
|
||||||
func GetMemStats(url string) ([]byte, error) {
|
func GetMemStats(url string) ([]byte, error) {
|
||||||
|
op := RPCOps{
|
||||||
|
Method: "MemStats.Get",
|
||||||
|
Request: rpc.Args{Request: ""},
|
||||||
|
}
|
||||||
|
req, err := NewRequest(url, op, http.DefaultTransport)
|
||||||
|
if err != nil {
|
||||||
|
return nil, iodine.New(err, nil)
|
||||||
|
}
|
||||||
|
resp, err := req.Do()
|
||||||
|
if err != nil {
|
||||||
|
return nil, iodine.New(err, nil)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
var reply rpc.MemStatsReply
|
||||||
|
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
|
||||||
|
return nil, iodine.New(err, nil)
|
||||||
|
}
|
||||||
|
return json.MarshalIndent(reply, "", "\t")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSysInfo get system status of the server at given url
|
||||||
|
func GetSysInfo(url string) ([]byte, error) {
|
||||||
op := RPCOps{
|
op := RPCOps{
|
||||||
Method: "SysInfo.Get",
|
Method: "SysInfo.Get",
|
||||||
Request: rpc.Args{Request: ""},
|
Request: rpc.Args{Request: ""},
|
||||||
@ -96,4 +118,4 @@ func SetDonut(url, hostname string, disks []string) error {
|
|||||||
return reply.Error
|
return reply.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add more functions here for many replies
|
// Add more functions here for other RPC messages
|
||||||
|
@ -64,3 +64,13 @@ func (r RPCRequest) Do() (*http.Response, error) {
|
|||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get - get value of requested header
|
||||||
|
func (r RPCRequest) Get(key string) string {
|
||||||
|
return r.req.Header.Get(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set - set value of a header key
|
||||||
|
func (r *RPCRequest) Set(key, value string) {
|
||||||
|
r.req.Header.Set(key, value)
|
||||||
|
}
|
||||||
|
@ -304,13 +304,15 @@ func (donut API) CreateObject(bucket, key, expectedMD5Sum string, size int64, da
|
|||||||
|
|
||||||
// createObject - PUT object to cache buffer
|
// createObject - PUT object to cache buffer
|
||||||
func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, size int64, data io.Reader) (ObjectMetadata, error) {
|
func (donut API) createObject(bucket, key, contentType, expectedMD5Sum string, size int64, data io.Reader) (ObjectMetadata, error) {
|
||||||
if size > int64(donut.config.MaxSize) {
|
if len(donut.config.NodeDiskMap) == 0 {
|
||||||
generic := GenericObjectError{Bucket: bucket, Object: key}
|
if size > int64(donut.config.MaxSize) {
|
||||||
return ObjectMetadata{}, iodine.New(EntityTooLarge{
|
generic := GenericObjectError{Bucket: bucket, Object: key}
|
||||||
GenericObjectError: generic,
|
return ObjectMetadata{}, iodine.New(EntityTooLarge{
|
||||||
Size: strconv.FormatInt(size, 10),
|
GenericObjectError: generic,
|
||||||
MaxSize: strconv.FormatUint(donut.config.MaxSize, 10),
|
Size: strconv.FormatInt(size, 10),
|
||||||
}, nil)
|
MaxSize: strconv.FormatUint(donut.config.MaxSize, 10),
|
||||||
|
}, nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !IsValidBucket(bucket) {
|
if !IsValidBucket(bucket) {
|
||||||
return ObjectMetadata{}, iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
return ObjectMetadata{}, iodine.New(BucketNameInvalid{Bucket: bucket}, nil)
|
||||||
|
@ -33,22 +33,22 @@ import (
|
|||||||
"github.com/minio/minio/pkg/server/api"
|
"github.com/minio/minio/pkg/server/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func TestAPI(t *testing.T) { TestingT(t) }
|
||||||
|
|
||||||
type MySuite struct{}
|
type MyAPISuite struct{}
|
||||||
|
|
||||||
var _ = Suite(&MySuite{})
|
var _ = Suite(&MyAPISuite{})
|
||||||
|
|
||||||
var testServer *httptest.Server
|
var testAPIServer *httptest.Server
|
||||||
|
|
||||||
func (s *MySuite) SetUpSuite(c *C) {
|
func (s *MyAPISuite) SetUpSuite(c *C) {
|
||||||
httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
|
httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
|
||||||
go startTM(minioAPI)
|
go startTM(minioAPI)
|
||||||
testServer = httptest.NewServer(httpHandler)
|
testAPIServer = httptest.NewServer(httpHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TearDownSuite(c *C) {
|
func (s *MyAPISuite) TearDownSuite(c *C) {
|
||||||
testServer.Close()
|
testAPIServer.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDummyAuthHeader(req *http.Request) {
|
func setDummyAuthHeader(req *http.Request) {
|
||||||
@ -57,8 +57,8 @@ func setDummyAuthHeader(req *http.Request) {
|
|||||||
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestNonExistantBucket(c *C) {
|
func (s *MyAPISuite) TestNonExistantBucket(c *C) {
|
||||||
request, err := http.NewRequest("HEAD", testServer.URL+"/nonexistantbucket", nil)
|
request, err := http.NewRequest("HEAD", testAPIServer.URL+"/nonexistantbucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -68,8 +68,8 @@ func (s *MySuite) TestNonExistantBucket(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusNotFound)
|
c.Assert(response.StatusCode, Equals, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestEmptyObject(c *C) {
|
func (s *MyAPISuite) TestEmptyObject(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/emptyobject", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/emptyobject", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/emptyobject/object", nil)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/emptyobject/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ func (s *MySuite) TestEmptyObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/emptyobject/object", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/emptyobject/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ func (s *MySuite) TestEmptyObject(c *C) {
|
|||||||
c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes()))
|
c.Assert(true, Equals, bytes.Equal(responseBody, buffer.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestBucket(c *C) {
|
func (s *MyAPISuite) TestBucket(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/bucket", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/bucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ func (s *MySuite) TestBucket(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("HEAD", testServer.URL+"/bucket", nil)
|
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/bucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -122,10 +122,9 @@ func (s *MySuite) TestBucket(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func (s *MyAPISuite) TestObject(c *C) {
|
||||||
func (s *MySuite) TestObject(c *C) {
|
|
||||||
buffer := bytes.NewBufferString("hello world")
|
buffer := bytes.NewBufferString("hello world")
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/testobject", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/testobject", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ func (s *MySuite) TestObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/testobject/object", buffer)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/testobject/object", buffer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -143,7 +142,7 @@ func (s *MySuite) TestObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/testobject/object", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/testobject/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -157,10 +156,9 @@ func (s *MySuite) TestObject(c *C) {
|
|||||||
c.Assert(responseBody, DeepEquals, []byte("hello world"))
|
c.Assert(responseBody, DeepEquals, []byte("hello world"))
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
func (s *MySuite) TestMultipleObjects(c *C) {
|
func (s *MyAPISuite) TestMultipleObjects(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/multipleobjects", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -169,7 +167,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/multipleobjects/object", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -182,7 +180,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
|
|
||||||
// get object
|
// get object
|
||||||
buffer1 := bytes.NewBufferString("hello one")
|
buffer1 := bytes.NewBufferString("hello one")
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/multipleobjects/object1", buffer1)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object1", buffer1)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -191,7 +189,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/multipleobjects/object1", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object1", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -206,7 +204,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello one")))
|
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello one")))
|
||||||
|
|
||||||
buffer2 := bytes.NewBufferString("hello two")
|
buffer2 := bytes.NewBufferString("hello two")
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/multipleobjects/object2", buffer2)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object2", buffer2)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -215,7 +213,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/multipleobjects/object2", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object2", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -230,7 +228,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello two")))
|
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello two")))
|
||||||
|
|
||||||
buffer3 := bytes.NewBufferString("hello three")
|
buffer3 := bytes.NewBufferString("hello three")
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/multipleobjects/object3", buffer3)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/multipleobjects/object3", buffer3)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -239,7 +237,7 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/multipleobjects/object3", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/multipleobjects/object3", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -254,8 +252,8 @@ func (s *MySuite) TestMultipleObjects(c *C) {
|
|||||||
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three")))
|
c.Assert(true, Equals, bytes.Equal(responseBody, []byte("hello three")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestNotImplemented(c *C) {
|
func (s *MyAPISuite) TestNotImplemented(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/bucket/object?policy", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/bucket/object?policy", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -266,8 +264,8 @@ func (s *MySuite) TestNotImplemented(c *C) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestHeader(c *C) {
|
func (s *MyAPISuite) TestHeader(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/bucket/object", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/bucket/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -278,8 +276,8 @@ func (s *MySuite) TestHeader(c *C) {
|
|||||||
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPutBucket(c *C) {
|
func (s *MyAPISuite) TestPutBucket(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/put-bucket", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/put-bucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -290,8 +288,8 @@ func (s *MySuite) TestPutBucket(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPutObject(c *C) {
|
func (s *MyAPISuite) TestPutObject(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/put-object", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/put-object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -301,7 +299,7 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/put-object/object", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/put-object/object", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -310,8 +308,8 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestListBuckets(c *C) {
|
func (s *MyAPISuite) TestListBuckets(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -331,8 +329,8 @@ func readListBucket(reader io.Reader) (api.ListBucketsResponse, error) {
|
|||||||
return results, err
|
return results, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
|
func (s *MyAPISuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/innonexistantbucket/object", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -342,8 +340,8 @@ func (s *MySuite) TestNotBeAbleToCreateObjectInNonexistantBucket(c *C) {
|
|||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestHeadOnObject(c *C) {
|
func (s *MyAPISuite) TestHeadOnObject(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/headonobject", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/headonobject", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -353,7 +351,7 @@ func (s *MySuite) TestHeadOnObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/headonobject/object1", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -361,7 +359,7 @@ func (s *MySuite) TestHeadOnObject(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("HEAD", testServer.URL+"/headonobject/object1", nil)
|
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/headonobject/object1", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -370,8 +368,8 @@ func (s *MySuite) TestHeadOnObject(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestHeadOnBucket(c *C) {
|
func (s *MyAPISuite) TestHeadOnBucket(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/headonbucket", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/headonbucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -381,7 +379,7 @@ func (s *MySuite) TestHeadOnBucket(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("HEAD", testServer.URL+"/headonbucket", nil)
|
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/headonbucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -390,8 +388,8 @@ func (s *MySuite) TestHeadOnBucket(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestDateFormat(c *C) {
|
func (s *MyAPISuite) TestDateFormat(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/dateformat", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/dateformat", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -425,8 +423,8 @@ func verifyHeaders(c *C, header http.Header, date time.Time, size int, contentTy
|
|||||||
c.Assert(header.Get("Etag"), Equals, "\""+etag+"\"")
|
c.Assert(header.Get("Etag"), Equals, "\""+etag+"\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
func (s *MyAPISuite) TestXMLNameNotInBucketListJson(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("Accept", "application/json")
|
request.Header.Add("Accept", "application/json")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -441,8 +439,8 @@ func (s *MySuite) TestXMLNameNotInBucketListJson(c *C) {
|
|||||||
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
|
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
func (s *MyAPISuite) TestXMLNameNotInObjectListJson(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/xmlnamenotinobjectlistjson", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/xmlnamenotinobjectlistjson", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("Accept", "application/json")
|
request.Header.Add("Accept", "application/json")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -452,7 +450,7 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/xmlnamenotinobjectlistjson", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/xmlnamenotinobjectlistjson", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("Accept", "application/json")
|
request.Header.Add("Accept", "application/json")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -467,8 +465,8 @@ func (s *MySuite) TestXMLNameNotInObjectListJson(c *C) {
|
|||||||
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
|
c.Assert(strings.Contains(string(byteResults), "XML"), Equals, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestContentTypePersists(c *C) {
|
func (s *MyAPISuite) TestContentTypePersists(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/contenttype-persists", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/contenttype-persists", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -477,7 +475,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/contenttype-persists/one", bytes.NewBufferString("hello world"))
|
||||||
delete(request.Header, "Content-Type")
|
delete(request.Header, "Content-Type")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -487,7 +485,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("HEAD", testServer.URL+"/contenttype-persists/one", nil)
|
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/contenttype-persists/one", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -495,7 +493,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/contenttype-persists/one", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/contenttype-persists/one", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -505,7 +503,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/contenttype-persists/two", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/contenttype-persists/two", bytes.NewBufferString("hello world"))
|
||||||
delete(request.Header, "Content-Type")
|
delete(request.Header, "Content-Type")
|
||||||
request.Header.Add("Content-Type", "application/json")
|
request.Header.Add("Content-Type", "application/json")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@ -515,7 +513,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("HEAD", testServer.URL+"/contenttype-persists/two", nil)
|
request, err = http.NewRequest("HEAD", testAPIServer.URL+"/contenttype-persists/two", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -523,7 +521,7 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/contenttype-persists/two", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/contenttype-persists/two", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -532,8 +530,8 @@ func (s *MySuite) TestContentTypePersists(c *C) {
|
|||||||
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
c.Assert(response.Header.Get("Content-Type"), Equals, "application/octet-stream")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPartialContent(c *C) {
|
func (s *MyAPISuite) TestPartialContent(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/partial-content", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/partial-content", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -542,7 +540,7 @@ func (s *MySuite) TestPartialContent(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/partial-content/bar", bytes.NewBufferString("Hello World"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -552,7 +550,7 @@ func (s *MySuite) TestPartialContent(c *C) {
|
|||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
// prepare request
|
// prepare request
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/partial-content/bar", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/partial-content/bar", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("Accept", "application/json")
|
request.Header.Add("Accept", "application/json")
|
||||||
request.Header.Add("Range", "bytes=6-7")
|
request.Header.Add("Range", "bytes=6-7")
|
||||||
@ -568,8 +566,8 @@ func (s *MySuite) TestPartialContent(c *C) {
|
|||||||
c.Assert(string(partialObject), Equals, "Wo")
|
c.Assert(string(partialObject), Equals, "Wo")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestListObjectsHandlerErrors(c *C) {
|
func (s *MyAPISuite) TestListObjectsHandlerErrors(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/objecthandlererrors-.", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/objecthandlererrors-.", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -578,7 +576,7 @@ func (s *MySuite) TestListObjectsHandlerErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
|
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/objecthandlererrors", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/objecthandlererrors", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -588,8 +586,8 @@ func (s *MySuite) TestListObjectsHandlerErrors(c *C) {
|
|||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPutBucketErrors(c *C) {
|
func (s *MyAPISuite) TestPutBucketErrors(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/putbucket-.", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/putbucket-.", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -599,7 +597,7 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
|
verifyError(c, response, "InvalidBucketName", "The specified bucket is not valid.", http.StatusBadRequest)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/putbucket", nil)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/putbucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -609,7 +607,7 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/putbucket", nil)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/putbucket", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "private")
|
request.Header.Add("x-amz-acl", "private")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -618,7 +616,7 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict)
|
verifyError(c, response, "BucketAlreadyExists", "The requested bucket name is not available.", http.StatusConflict)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/putbucket?acl", nil)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/putbucket?acl", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
request.Header.Add("x-amz-acl", "unknown")
|
request.Header.Add("x-amz-acl", "unknown")
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -628,8 +626,8 @@ func (s *MySuite) TestPutBucketErrors(c *C) {
|
|||||||
verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented)
|
verifyError(c, response, "NotImplemented", "A header you provided implies functionality that is not implemented.", http.StatusNotImplemented)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestGetObjectErrors(c *C) {
|
func (s *MyAPISuite) TestGetObjectErrors(c *C) {
|
||||||
request, err := http.NewRequest("GET", testServer.URL+"/getobjecterrors", nil)
|
request, err := http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -638,7 +636,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchBucket", "The specified bucket does not exist.", http.StatusNotFound)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/getobjecterrors", nil)
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/getobjecterrors", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -647,7 +645,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/getobjecterrors/bar", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors/bar", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -656,7 +654,7 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
|
verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/getobjecterrors-./bar", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/getobjecterrors-./bar", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -666,8 +664,8 @@ func (s *MySuite) TestGetObjectErrors(c *C) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestGetObjectRangeErrors(c *C) {
|
func (s *MyAPISuite) TestGetObjectRangeErrors(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/getobjectrangeerrors", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/getobjectrangeerrors", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -676,7 +674,7 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/getobjectrangeerrors/bar", bytes.NewBufferString("Hello World"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -685,7 +683,7 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/getobjectrangeerrors/bar", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/getobjectrangeerrors/bar", nil)
|
||||||
request.Header.Add("Range", "bytes=7-6")
|
request.Header.Add("Range", "bytes=7-6")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
@ -696,8 +694,8 @@ func (s *MySuite) TestGetObjectRangeErrors(c *C) {
|
|||||||
verifyError(c, response, "InvalidRange", "The requested range cannot be satisfied.", http.StatusRequestedRangeNotSatisfiable)
|
verifyError(c, response, "InvalidRange", "The requested range cannot be satisfied.", http.StatusRequestedRangeNotSatisfiable)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
func (s *MyAPISuite) TestObjectMultipartAbort(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/objectmultipartabort", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartabort", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -706,7 +704,7 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, 200)
|
c.Assert(response.StatusCode, Equals, 200)
|
||||||
|
|
||||||
request, err = http.NewRequest("POST", testServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString(""))
|
request, err = http.NewRequest("POST", testAPIServer.URL+"/objectmultipartabort/object?uploads", bytes.NewBufferString(""))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -721,7 +719,7 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
|||||||
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
||||||
uploadID := newResponse.UploadID
|
uploadID := newResponse.UploadID
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -729,7 +727,7 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartabort/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -737,7 +735,7 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("DELETE", testServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil)
|
request, err = http.NewRequest("DELETE", testAPIServer.URL+"/objectmultipartabort/object?uploadId="+uploadID, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -746,8 +744,8 @@ func (s *MySuite) TestObjectMultipartAbort(c *C) {
|
|||||||
c.Assert(response3.StatusCode, Equals, http.StatusNoContent)
|
c.Assert(response3.StatusCode, Equals, http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestBucketMultipartList(c *C) {
|
func (s *MyAPISuite) TestBucketMultipartList(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/bucketmultipartlist", bytes.NewBufferString(""))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -756,7 +754,7 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, 200)
|
c.Assert(response.StatusCode, Equals, 200)
|
||||||
|
|
||||||
request, err = http.NewRequest("POST", testServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString(""))
|
request, err = http.NewRequest("POST", testAPIServer.URL+"/bucketmultipartlist/object?uploads", bytes.NewBufferString(""))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -771,7 +769,7 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
|
|||||||
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
||||||
uploadID := newResponse.UploadID
|
uploadID := newResponse.UploadID
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -779,7 +777,7 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/bucketmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -787,7 +785,7 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/bucketmultipartlist?uploads", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/bucketmultipartlist?uploads", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -802,8 +800,8 @@ func (s *MySuite) TestBucketMultipartList(c *C) {
|
|||||||
c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist")
|
c.Assert(newResponse3.Bucket, Equals, "bucketmultipartlist")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestObjectMultipartList(c *C) {
|
func (s *MyAPISuite) TestObjectMultipartList(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartlist", bytes.NewBufferString(""))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -812,7 +810,7 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, 200)
|
c.Assert(response.StatusCode, Equals, 200)
|
||||||
|
|
||||||
request, err = http.NewRequest("POST", testServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString(""))
|
request, err = http.NewRequest("POST", testAPIServer.URL+"/objectmultipartlist/object?uploads", bytes.NewBufferString(""))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -827,7 +825,7 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
||||||
uploadID := newResponse.UploadID
|
uploadID := newResponse.UploadID
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -835,7 +833,7 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultipartlist/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -843,7 +841,7 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
c.Assert(response2.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/objectmultipartlist/object?uploadId="+uploadID, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -853,8 +851,8 @@ func (s *MySuite) TestObjectMultipartList(c *C) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestObjectMultipart(c *C) {
|
func (s *MyAPISuite) TestObjectMultipart(c *C) {
|
||||||
request, err := http.NewRequest("PUT", testServer.URL+"/objectmultiparts", nil)
|
request, err := http.NewRequest("PUT", testAPIServer.URL+"/objectmultiparts", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -863,7 +861,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, 200)
|
c.Assert(response.StatusCode, Equals, 200)
|
||||||
|
|
||||||
request, err = http.NewRequest("POST", testServer.URL+"/objectmultiparts/object?uploads", nil)
|
request, err = http.NewRequest("POST", testAPIServer.URL+"/objectmultiparts/object?uploads", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -880,7 +878,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
|
|||||||
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
c.Assert(len(newResponse.UploadID) > 0, Equals, true)
|
||||||
uploadID := newResponse.UploadID
|
uploadID := newResponse.UploadID
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=1", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -889,7 +887,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
c.Assert(response1.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("PUT", testServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
request, err = http.NewRequest("PUT", testAPIServer.URL+"/objectmultiparts/object?uploadId="+uploadID+"&partNumber=2", bytes.NewBufferString("hello world"))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -916,7 +914,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
|
|||||||
encoder := xml.NewEncoder(&completeBuffer)
|
encoder := xml.NewEncoder(&completeBuffer)
|
||||||
encoder.Encode(completeUploads)
|
encoder.Encode(completeUploads)
|
||||||
|
|
||||||
request, err = http.NewRequest("POST", testServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer)
|
request, err = http.NewRequest("POST", testAPIServer.URL+"/objectmultiparts/object?uploadId="+uploadID, &completeBuffer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
@ -924,7 +922,7 @@ func (s *MySuite) TestObjectMultipart(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
request, err = http.NewRequest("GET", testServer.URL+"/objectmultiparts/object", nil)
|
request, err = http.NewRequest("GET", testAPIServer.URL+"/objectmultiparts/object", nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
setDummyAuthHeader(request)
|
setDummyAuthHeader(request)
|
||||||
|
|
||||||
|
@ -114,8 +114,9 @@ func getRPCHandler() http.Handler {
|
|||||||
s.RegisterJSONCodec()
|
s.RegisterJSONCodec()
|
||||||
s.RegisterService(new(rpc.VersionService), "Version")
|
s.RegisterService(new(rpc.VersionService), "Version")
|
||||||
s.RegisterService(new(rpc.SysInfoService), "SysInfo")
|
s.RegisterService(new(rpc.SysInfoService), "SysInfo")
|
||||||
|
s.RegisterService(new(rpc.MemStatsService), "MemStats")
|
||||||
s.RegisterService(new(rpc.DiskInfoService), "DiskInfo")
|
s.RegisterService(new(rpc.DiskInfoService), "DiskInfo")
|
||||||
s.RegisterService(new(rpc.DonutService), "Donut")
|
s.RegisterService(new(rpc.DonutService), "Donut")
|
||||||
// Add new services here
|
// Add new RPC services here
|
||||||
return registerRPC(router.NewRouter(), s)
|
return registerRPC(router.NewRouter(), s)
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,20 @@ type SysInfoService struct{}
|
|||||||
|
|
||||||
// SysInfoReply -
|
// SysInfoReply -
|
||||||
type SysInfoReply struct {
|
type SysInfoReply struct {
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
SysARCH string `json:"sys.arch"`
|
SysARCH string `json:"sys.arch"`
|
||||||
SysOS string `json:"sys.os"`
|
SysOS string `json:"sys.os"`
|
||||||
SysCPUS int `json:"sys.ncpus"`
|
SysCPUS int `json:"sys.ncpus"`
|
||||||
Routines int `json:"goroutines"`
|
Routines int `json:"goroutines"`
|
||||||
GOVersion string `json:"goversion"`
|
GOVersion string `json:"goversion"`
|
||||||
MemStats runtime.MemStats `json:"memstats"`
|
}
|
||||||
|
|
||||||
|
// MemStatsService -
|
||||||
|
type MemStatsService struct{}
|
||||||
|
|
||||||
|
// MemStatsReply -
|
||||||
|
type MemStatsReply struct {
|
||||||
|
runtime.MemStats `json:"memstats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSysInfoReply(sis *SysInfoReply) error {
|
func setSysInfoReply(sis *SysInfoReply) error {
|
||||||
@ -50,11 +57,13 @@ func setSysInfoReply(sis *SysInfoReply) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return iodine.New(err, nil)
|
return iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setMemStatsReply(sis *MemStatsReply) error {
|
||||||
var memStats runtime.MemStats
|
var memStats runtime.MemStats
|
||||||
runtime.ReadMemStats(&memStats)
|
runtime.ReadMemStats(&memStats)
|
||||||
sis.MemStats = memStats
|
sis.MemStats = memStats
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,3 +71,8 @@ func setSysInfoReply(sis *SysInfoReply) error {
|
|||||||
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
|
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
|
||||||
return setSysInfoReply(reply)
|
return setSysInfoReply(reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get method
|
||||||
|
func (s *MemStatsService) Get(r *http.Request, args *Args, reply *MemStatsReply) error {
|
||||||
|
return setMemStatsReply(reply)
|
||||||
|
}
|
||||||
|
101
pkg/server/rpc_test.go
Normal file
101
pkg/server/rpc_test.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Minimalist Object Storage, (C) 2014 Minio, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
jsonrpc "github.com/gorilla/rpc/v2/json"
|
||||||
|
. "github.com/minio/check"
|
||||||
|
"github.com/minio/minio/pkg/controller"
|
||||||
|
"github.com/minio/minio/pkg/server/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRPC(t *testing.T) { TestingT(t) }
|
||||||
|
|
||||||
|
type MyRPCSuite struct{}
|
||||||
|
|
||||||
|
var _ = Suite(&MyRPCSuite{})
|
||||||
|
|
||||||
|
var testRPCServer *httptest.Server
|
||||||
|
|
||||||
|
func (s *MyRPCSuite) SetUpSuite(c *C) {
|
||||||
|
testRPCServer = httptest.NewServer(getRPCHandler())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MyRPCSuite) TearDownSuite(c *C) {
|
||||||
|
testRPCServer.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MyRPCSuite) TestDiskInfo(c *C) {
|
||||||
|
op := controller.RPCOps{
|
||||||
|
Method: "DiskInfo.Get",
|
||||||
|
Request: rpc.Args{Request: ""},
|
||||||
|
}
|
||||||
|
req, err := controller.NewRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
|
resp, err := req.Do()
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(resp.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
var reply rpc.DiskInfoReply
|
||||||
|
err = jsonrpc.DecodeClientResponse(resp.Body, &reply)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
resp.Body.Close()
|
||||||
|
c.Assert(reply, Not(DeepEquals), rpc.DiskInfoReply{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MyRPCSuite) TestMemStats(c *C) {
|
||||||
|
op := controller.RPCOps{
|
||||||
|
Method: "MemStats.Get",
|
||||||
|
Request: rpc.Args{Request: ""},
|
||||||
|
}
|
||||||
|
req, err := controller.NewRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
|
resp, err := req.Do()
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(resp.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
var reply rpc.MemStatsReply
|
||||||
|
err = jsonrpc.DecodeClientResponse(resp.Body, &reply)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
resp.Body.Close()
|
||||||
|
c.Assert(reply, Not(DeepEquals), rpc.MemStatsReply{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MyRPCSuite) TestSysInfo(c *C) {
|
||||||
|
op := controller.RPCOps{
|
||||||
|
Method: "SysInfo.Get",
|
||||||
|
Request: rpc.Args{Request: ""},
|
||||||
|
}
|
||||||
|
req, err := controller.NewRequest(testRPCServer.URL+"/rpc", op, http.DefaultTransport)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(req.Get("Content-Type"), Equals, "application/json")
|
||||||
|
resp, err := req.Do()
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(resp.StatusCode, Equals, http.StatusOK)
|
||||||
|
|
||||||
|
var reply rpc.SysInfoReply
|
||||||
|
err = jsonrpc.DecodeClientResponse(resp.Body, &reply)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
resp.Body.Close()
|
||||||
|
c.Assert(reply, Not(DeepEquals), rpc.SysInfoReply{})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user