satellite/{metainfo,metabase}: prepare feature flag MultipleVersions
We will introduce new logic for creating new objects (BeginObject). Instead of using single version internally (1) we will be selecting first available version during object creation. Because we need to be sure that everything is wired up correctly we need a feature flag to be able to control if new feature is enabled. Change-Id: If0f8496397130811f43bf9db9fdcc2b30cd2e4ca
This commit is contained in:
parent
cc39727f69
commit
4e71dd302a
@ -466,6 +466,7 @@ func (planet *Planet) newSatellite(ctx context.Context, prefix string, index int
|
||||
MinPartSize: config.Metainfo.MinPartSize,
|
||||
MaxNumberOfParts: config.Metainfo.MaxNumberOfParts,
|
||||
ServerSideCopy: config.Metainfo.ServerSideCopy,
|
||||
MultipleVersions: config.Metainfo.MultipleVersions,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -509,6 +509,10 @@ func (c *CommitObject) Verify() error {
|
||||
func (db *DB) CommitObject(ctx context.Context, opts CommitObject) (object Object, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
if db.config.MultipleVersions {
|
||||
return Object{}, Error.New("Unimplemented")
|
||||
}
|
||||
|
||||
if err := opts.Verify(); err != nil {
|
||||
return Object{}, err
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/testcontext"
|
||||
@ -3204,3 +3206,14 @@ func TestCommitObjectWithIncorrectAmountOfParts(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestMultipleVersionsFlag(t *testing.T) {
|
||||
// TODO test will be removed when functionality will be implemented
|
||||
metabasetest.RunWithConfig(t, metabase.Config{
|
||||
ApplicationName: "satellite-test",
|
||||
MultipleVersions: true,
|
||||
}, func(ctx *testcontext.Context, t *testing.T, db *metabase.DB) {
|
||||
_, err := db.CommitObject(ctx, metabase.CommitObject{})
|
||||
require.EqualError(t, err, "metabase: Unimplemented")
|
||||
})
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ type Config struct {
|
||||
// TODO remove this flag when server-side copy implementation will be finished
|
||||
ServerSideCopy bool
|
||||
ServerSideCopyDisabled bool
|
||||
MultipleVersions bool
|
||||
}
|
||||
|
||||
// DB implements a database for storing objects and segments.
|
||||
|
@ -67,6 +67,7 @@ func Run(t *testing.T, fn func(ctx *testcontext.Context, t *testing.T, db *metab
|
||||
MaxNumberOfParts: config.MaxNumberOfParts,
|
||||
ServerSideCopy: config.ServerSideCopy,
|
||||
ServerSideCopyDisabled: config.ServerSideCopyDisabled,
|
||||
MultipleVersions: config.MultipleVersions,
|
||||
}, fn)
|
||||
}
|
||||
|
||||
|
@ -138,4 +138,5 @@ type Config struct {
|
||||
// TODO remove this flag when server-side copy implementation will be finished
|
||||
ServerSideCopy bool `help:"enable code for server-side copy, deprecated. please leave this to true." default:"true"`
|
||||
ServerSideCopyDisabled bool `help:"disable already enabled server-side copy. this is because once server side copy is enabled, delete code should stay changed, even if you want to disable server side copy" default:"false"`
|
||||
MultipleVersions bool `help:"feature flag to enable using multple objects versions in the system internally" default:"false"`
|
||||
}
|
||||
|
@ -29,6 +29,10 @@ import (
|
||||
func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRequest) (resp *pb.ObjectBeginResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
if endpoint.config.MultipleVersions {
|
||||
return nil, rpcstatus.Error(rpcstatus.Unimplemented, "Unimplemented")
|
||||
}
|
||||
|
||||
endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName())
|
||||
|
||||
now := time.Now()
|
||||
|
@ -1826,3 +1826,20 @@ func TestEndpoint_UpdateObjectMetadata(t *testing.T) {
|
||||
require.Equal(t, validKey, objects[0].EncryptedMetadataEncryptedKey)
|
||||
})
|
||||
}
|
||||
|
||||
func TestMultipleVersionsFlag(t *testing.T) {
|
||||
// TODO test will be removed when functionality will be implemented
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1,
|
||||
Reconfigure: testplanet.Reconfigure{
|
||||
Satellite: func(log *zap.Logger, index int, config *satellite.Config) {
|
||||
config.Metainfo.MultipleVersions = true
|
||||
},
|
||||
},
|
||||
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
||||
planet.Satellites[0].Config.Metainfo.MultipleVersions = true
|
||||
_, err := planet.Satellites[0].Metainfo.Endpoint.BeginObject(ctx, &pb.ObjectBeginRequest{})
|
||||
require.Error(t, err)
|
||||
require.True(t, errs2.IsRPC(err, rpcstatus.Unimplemented))
|
||||
})
|
||||
}
|
||||
|
3
scripts/testdata/satellite-config.yaml.lock
vendored
3
scripts/testdata/satellite-config.yaml.lock
vendored
@ -550,6 +550,9 @@ identity.key-path: /root/.local/share/storj/identity/satellite/identity.key
|
||||
# minimum remote segment size
|
||||
# metainfo.min-remote-segment-size: 1.2 KiB
|
||||
|
||||
# feature flag to enable using multple objects versions in the system internally
|
||||
# metainfo.multiple-versions: false
|
||||
|
||||
# toggle flag if overlay is enabled
|
||||
# metainfo.overlay: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user