Commit d5463ce5 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'nuget-route-multipart-uploads' into 'master'

Use multipart uploads for nuget packages

See merge request gitlab-org/gitlab-workhorse!451
parents 9a9a83e7 b02565d2
...@@ -208,7 +208,7 @@ func (u *upstream) configureRoutes() { ...@@ -208,7 +208,7 @@ func (u *upstream) configureRoutes() {
route("PUT", apiPattern+`v4/packages/conan/`, filestore.BodyUploader(api, proxy, nil)), route("PUT", apiPattern+`v4/packages/conan/`, filestore.BodyUploader(api, proxy, nil)),
// NuGet Artifact Repository // NuGet Artifact Repository
route("PUT", apiPattern+`v4/projects/[0-9]+/packages/nuget/`, filestore.BodyUploader(api, proxy, nil)), route("PUT", apiPattern+`v4/projects/[0-9]+/packages/nuget/`, upload.Accelerate(api, proxy)),
// We are porting API to disk acceleration // We are porting API to disk acceleration
// we need to declare each routes until we have fixed all the routes on the rails codebase. // we need to declare each routes until we have fixed all the routes on the rails codebase.
......
...@@ -117,18 +117,27 @@ func TestAcceleratedUpload(t *testing.T) { ...@@ -117,18 +117,27 @@ func TestAcceleratedUpload(t *testing.T) {
ws := startWorkhorseServer(ts.URL) ws := startWorkhorseServer(ts.URL)
defer ws.Close() defer ws.Close()
resources := []string{ tests := []struct {
`/example`, method string
`/uploads/personal_snippet`, resource string
`/uploads/user`, }{
`/api/v4/projects/1/wikis/attachments`, {"POST", `/example`},
`/api/graphql`, {"POST", `/uploads/personal_snippet`},
{"POST", `/uploads/user`},
{"POST", `/api/v4/projects/1/wikis/attachments`},
{"POST", `/api/graphql`},
{"PUT", "/api/v4/projects/9001/packages/nuget/v1/files"},
} }
for _, resource := range resources {
for _, tt := range tests {
reqBody, contentType, err := multipartBodyWithFile() reqBody, contentType, err := multipartBodyWithFile()
require.NoError(t, err) require.NoError(t, err)
resp, err := http.Post(ws.URL+resource, contentType, reqBody) req, err := http.NewRequest(tt.method, ws.URL+tt.resource, reqBody)
require.NoError(t, err)
req.Header.Set("Content-Type", contentType)
resp, err := http.DefaultClient.Do(req)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode) require.Equal(t, 200, resp.StatusCode)
...@@ -330,7 +339,6 @@ func testPackageFileUpload(t *testing.T, resource string) { ...@@ -330,7 +339,6 @@ func testPackageFileUpload(t *testing.T, resource string) {
func TestPackageFilesUpload(t *testing.T) { func TestPackageFilesUpload(t *testing.T) {
routes := []string{ routes := []string{
"/api/v4/packages/conan/v1/files", "/api/v4/packages/conan/v1/files",
"/api/v4/projects/9001/packages/nuget/v1/files",
"/api/v4/projects/2412/packages/maven/v1/files", "/api/v4/projects/2412/packages/maven/v1/files",
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment