forked from TrueCloudLab/frostfs-s3-gw
[#667] Use separate copies numbers for system containers
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
42d6fc3fc6
commit
949fc0b484
15 changed files with 311 additions and 125 deletions
|
@ -81,6 +81,8 @@ type configMock struct {
|
|||
placementPolicies map[string]netmap.PlacementPolicy
|
||||
copiesNumbers map[string][]uint32
|
||||
defaultCopiesNumbers []uint32
|
||||
corsCopiesNumbers []uint32
|
||||
lifecycleCopiesNumbers []uint32
|
||||
bypassContentEncodingInChunks bool
|
||||
md5Enabled bool
|
||||
tlsTerminationHeader string
|
||||
|
@ -161,13 +163,22 @@ func (c *configMock) ListingKeepaliveThrottle() time.Duration {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (c *configMock) CORSCopiesNumbers() []uint32 {
|
||||
return c.corsCopiesNumbers
|
||||
}
|
||||
|
||||
func (c *configMock) LifecycleCopiesNumbers() []uint32 {
|
||||
return c.lifecycleCopiesNumbers
|
||||
}
|
||||
|
||||
func (c *configMock) putLocationConstraint(constraint string) {
|
||||
c.placementPolicies[constraint] = c.defaultPolicy
|
||||
}
|
||||
|
||||
type handlerConfig struct {
|
||||
cacheCfg *layer.CachesConfig
|
||||
withoutCORS bool
|
||||
cacheCfg *layer.CachesConfig
|
||||
withoutCORS bool
|
||||
withoutLifecycle bool
|
||||
}
|
||||
|
||||
func prepareHandlerContext(t *testing.T) *handlerContext {
|
||||
|
@ -180,11 +191,12 @@ func prepareHandlerContext(t *testing.T) *handlerContext {
|
|||
}
|
||||
}
|
||||
|
||||
func prepareWithoutCORSHandlerContext(t *testing.T) *handlerContext {
|
||||
func prepareWithoutContainersHandlerContext(t *testing.T, cors, lifecycle bool) *handlerContext {
|
||||
log := zaptest.NewLogger(t)
|
||||
hc, err := prepareHandlerContextBase(&handlerConfig{
|
||||
cacheCfg: layer.DefaultCachesConfigs(log),
|
||||
withoutCORS: true,
|
||||
cacheCfg: layer.DefaultCachesConfigs(log),
|
||||
withoutCORS: cors,
|
||||
withoutLifecycle: lifecycle,
|
||||
}, log)
|
||||
require.NoError(t, err)
|
||||
return &handlerContext{
|
||||
|
@ -247,12 +259,18 @@ func prepareHandlerContextBase(config *handlerConfig, log *zap.Logger) (*handler
|
|||
}
|
||||
|
||||
if !config.withoutCORS {
|
||||
layerCfg.CORSCnrInfo, err = createCORSContainer(key, tp)
|
||||
layerCfg.CORSCnrInfo, err = createContainer(key, tp, "cors")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if !config.withoutLifecycle {
|
||||
if layerCfg.LifecycleCnrInfo, err = createContainer(key, tp, "lifecycle"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var pp netmap.PlacementPolicy
|
||||
err = pp.DecodeString("REP 1")
|
||||
if err != nil {
|
||||
|
@ -296,14 +314,13 @@ func prepareHandlerContextBase(config *handlerConfig, log *zap.Logger) (*handler
|
|||
return hc, nil
|
||||
}
|
||||
|
||||
func createCORSContainer(key *keys.PrivateKey, tp *layer.TestFrostFS) (*data.BucketInfo, error) {
|
||||
func createContainer(key *keys.PrivateKey, tp *layer.TestFrostFS, bktName string) (*data.BucketInfo, error) {
|
||||
bearerToken := bearertest.Token()
|
||||
err := bearerToken.Sign(key.PrivateKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bktName := "cors"
|
||||
res, err := tp.CreateContainer(middleware.SetBox(context.Background(), &middleware.Box{AccessBox: &accessbox.Box{
|
||||
Gate: &accessbox.GateData{
|
||||
BearerToken: &bearerToken,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue