Port rebranding update to master #48

Merged
alexvanin merged 2 commits from alexvanin/frostfs-http-gw:fix/1-more-master into master 2023-05-19 07:29:53 +00:00
2 changed files with 22 additions and 37 deletions

View file

@ -38,20 +38,15 @@ type putResponse struct {
const ( const (
testContainerName = "friendly" testContainerName = "friendly"
versionWithNativeNames = "0.27.5"
testListenAddress = "localhost:8082" testListenAddress = "localhost:8082"
testHost = "http://" + testListenAddress testHost = "http://" + testListenAddress
) )
func TestIntegration(t *testing.T) { func TestIntegration(t *testing.T) {
rootCtx := context.Background() rootCtx := context.Background()
aioImage := "nspccdev/neofs-aio-testcontainer:" aioImage := "truecloudlab/frostfs-aio:"
versions := []string{ versions := []string{
"0.29.0", "1.2.5", // frostfs-storage v0.36.0 RC
"0.30.0",
"0.32.0",
"0.34.0",
"latest",
} }
key, err := keys.NewPrivateKeyFromHex("1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb") key, err := keys.NewPrivateKeyFromHex("1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb")
require.NoError(t, err) require.NoError(t, err)
@ -97,10 +92,8 @@ func simplePut(ctx context.Context, t *testing.T, p *pool.Pool, CID cid.ID, vers
url := testHost + "/upload/" + CID.String() url := testHost + "/upload/" + CID.String()
makePutRequestAndCheck(ctx, t, p, CID, url) makePutRequestAndCheck(ctx, t, p, CID, url)
if version >= versionWithNativeNames {
url = testHost + "/upload/" + testContainerName url = testHost + "/upload/" + testContainerName
makePutRequestAndCheck(ctx, t, p, CID, url) makePutRequestAndCheck(ctx, t, p, CID, url)
}
} }
func makePutRequestAndCheck(ctx context.Context, t *testing.T, p *pool.Pool, cnrID cid.ID, url string) { func makePutRequestAndCheck(ctx context.Context, t *testing.T, p *pool.Pool, cnrID cid.ID, url string) {
@ -223,11 +216,9 @@ func simpleGet(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID
require.NoError(t, err) require.NoError(t, err)
checkGetResponse(t, resp, content, attributes) checkGetResponse(t, resp, content, attributes)
if version >= versionWithNativeNames {
resp, err = http.Get(testHost + "/get/" + testContainerName + "/" + id.String()) resp, err = http.Get(testHost + "/get/" + testContainerName + "/" + id.String())
require.NoError(t, err) require.NoError(t, err)
checkGetResponse(t, resp, content, attributes) checkGetResponse(t, resp, content, attributes)
}
} }
func checkGetResponse(t *testing.T, resp *http.Response, content string, attributes map[string]string) { func checkGetResponse(t *testing.T, resp *http.Response, content string, attributes map[string]string) {
@ -277,11 +268,9 @@ func getByAttr(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID
require.NoError(t, err) require.NoError(t, err)
checkGetByAttrResponse(t, resp, content, expectedAttr) checkGetByAttrResponse(t, resp, content, expectedAttr)
if version >= versionWithNativeNames {
resp, err = http.Get(testHost + "/get_by_attribute/" + testContainerName + "/" + keyAttr + "/" + valAttr) resp, err = http.Get(testHost + "/get_by_attribute/" + testContainerName + "/" + keyAttr + "/" + valAttr)
require.NoError(t, err) require.NoError(t, err)
checkGetByAttrResponse(t, resp, content, expectedAttr) checkGetByAttrResponse(t, resp, content, expectedAttr)
}
} }
func getZip(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID user.ID, CID cid.ID, version string) { func getZip(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID user.ID, CID cid.ID, version string) {
@ -296,10 +285,8 @@ func getZip(ctx context.Context, t *testing.T, clientPool *pool.Pool, ownerID us
baseURL := testHost + "/zip/" + CID.String() baseURL := testHost + "/zip/" + CID.String()
makeZipTest(t, baseURL, names, contents) makeZipTest(t, baseURL, names, contents)
if version >= versionWithNativeNames {
baseURL = testHost + "/zip/" + testContainerName baseURL = testHost + "/zip/" + testContainerName
makeZipTest(t, baseURL, names, contents) makeZipTest(t, baseURL, names, contents)
}
} }
func makeZipTest(t *testing.T, baseURL string, names, contents []string) { func makeZipTest(t *testing.T, baseURL string, names, contents []string) {
@ -376,6 +363,7 @@ func getDefaultConfig() *viper.Viper {
v.SetDefault(cfgRPCEndpoint, "http://localhost:30333") v.SetDefault(cfgRPCEndpoint, "http://localhost:30333")
v.SetDefault("server.0.address", testListenAddress) v.SetDefault("server.0.address", testListenAddress)
v.SetDefault(cfgTreeServiceEndpoint, "localhost:8080")
return v return v
} }
@ -407,15 +395,11 @@ func createContainer(ctx context.Context, t *testing.T, clientPool *pool.Pool, o
container.SetCreationTime(&cnr, time.Now()) container.SetCreationTime(&cnr, time.Now())
if version >= versionWithNativeNames {
var domain container.Domain var domain container.Domain
domain.SetName(testContainerName) domain.SetName(testContainerName)
// currently node in aio image knows nothing about new sys attributes cnr.SetAttribute(containerv2.SysAttributeName, domain.Name())
// todo (@dkirillov): #2 use frostfs aio images that supports new attributes cnr.SetAttribute(containerv2.SysAttributeZone, domain.Zone())
cnr.SetAttribute(containerv2.SysAttributeNameNeoFS, domain.Name())
cnr.SetAttribute(containerv2.SysAttributeZoneNeoFS, domain.Zone())
}
var waitPrm pool.WaitParams var waitPrm pool.WaitParams
waitPrm.SetTimeout(15 * time.Second) waitPrm.SetTimeout(15 * time.Second)

View file

@ -16,7 +16,8 @@ type MultipartFile interface {
func fetchMultipartFile(l *zap.Logger, r io.Reader, boundary string) (MultipartFile, error) { func fetchMultipartFile(l *zap.Logger, r io.Reader, boundary string) (MultipartFile, error) {
// To have a custom buffer (3mb) the custom multipart reader is used. // To have a custom buffer (3mb) the custom multipart reader is used.
// https://github.com/nspcc-dev/neofs-http-gw/issues/148 // Default reader uses 4KiB chunks, which slow down upload speed up to 400%
// https://github.com/golang/go/blob/91b9915d3f6f8cd2e9e9fda63f67772803adfa03/src/mime/multipart/multipart.go#L32
reader := multipart.NewReader(r, boundary) reader := multipart.NewReader(r, boundary)
for { for {