add objects to default loopback bucket
This commit is contained in:
1 parent
edbb33de5b
commit
40477d84c0
5 files changed
+44
-8
No files matched your search
@@ -4,6 +4,8 @@
|
||||
package loopback
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin"
|
||||
)
|
||||
|
||||
@@ -39,21 +41,55 @@ type LoopbackPlugin struct {
|
||||
// NewLoopbackPlugin returns a new loopback plugin.
|
||||
// For storage service testings NewLoopbackPlugin Supports WithMockErrors
|
||||
// and WithMockBuckets as options. If no mock buckets are provided,
|
||||
// a bucket named `default` will be created.
|
||||
// a bucket named `default` will be created with several zero-length files
|
||||
// included.
|
||||
func NewLoopbackPlugin(opt ...TestOption) (*LoopbackPlugin, error) {
|
||||
opts, err := getTestOpts(opt...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
var zero int64 = 0
|
||||
ret := &LoopbackPlugin{
|
||||
TestPluginServer: new(TestPluginServer),
|
||||
LoopbackHost: &LoopbackHost{
|
||||
hostMap: make(map[string][]*loopbackPluginHostInfo),
|
||||
},
|
||||
LoopbackStorage: &LoopbackStorage{
|
||||
chunksSize: opts.withChunkSize,
|
||||
buckets: map[BucketName]Bucket{"default": {}},
|
||||
chunksSize: opts.withChunkSize,
|
||||
buckets: map[BucketName]Bucket{"default": {
|
||||
ObjectName("test-file-1"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
ObjectName("test-file-2"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
ObjectName("test-file-3"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
ObjectName("abc/file-1"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
ObjectName("abc/file-2"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
ObjectName("abc/file-3"): &storagePluginStorageInfo{
|
||||
lastModified: &now,
|
||||
contentLength: &zero,
|
||||
DataChunks: []Chunk{},
|
||||
},
|
||||
}},
|
||||
errs: make([]PluginMockError, 0),
|
||||
putObjectResponse: make([]PluginMockPutObjectResponse, 0),
|
||||
},
|
||||
|
||||
@@ -453,8 +453,8 @@ func (l *LoopbackStorage) deleteObjects(ctx context.Context, req *plgpb.DeleteOb
|
||||
_, ok := bucket[prefix]
|
||||
if ok {
|
||||
delete(bucket, prefix)
|
||||
deleted++
|
||||
}
|
||||
deleted++ // this is outside the if statement because aws always returns a success
|
||||
}
|
||||
return &plgpb.DeleteObjectsResponse{
|
||||
ObjectsDeleted: deleted,
|
||||
|
||||
@@ -1381,7 +1381,7 @@ func TestLoopbackDeleteObjects(t *testing.T) {
|
||||
Recursive: false,
|
||||
},
|
||||
expected: &plgpb.DeleteObjectsResponse{
|
||||
ObjectsDeleted: 0,
|
||||
ObjectsDeleted: 1,
|
||||
},
|
||||
check: func() error {
|
||||
return nil
|
||||
|
||||
@@ -38,7 +38,7 @@ service StoragePluginService {
|
||||
// stores it to an external object store.
|
||||
rpc PutObject(PutObjectRequest) returns (PutObjectResponse);
|
||||
|
||||
// DeleteObjects is a hook that deletes one or many files in an external object store
|
||||
// DeleteObjects deletes one or many files in an external object store
|
||||
// via a provided key prefix.
|
||||
rpc DeleteObjects(DeleteObjectsRequest) returns (DeleteObjectsResponse);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ type StoragePluginServiceClient interface {
|
||||
// PutObject is a hook that reads a file stored on local disk and
|
||||
// stores it to an external object store.
|
||||
PutObject(ctx context.Context, in *PutObjectRequest, opts ...grpc.CallOption) (*PutObjectResponse, error)
|
||||
// DeleteObjects is a hook that deletes one or many files in an external object store
|
||||
// DeleteObjects deletes one or many files in an external object store
|
||||
// via a provided key prefix.
|
||||
DeleteObjects(ctx context.Context, in *DeleteObjectsRequest, opts ...grpc.CallOption) (*DeleteObjectsResponse, error)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ type StoragePluginServiceServer interface {
|
||||
// PutObject is a hook that reads a file stored on local disk and
|
||||
// stores it to an external object store.
|
||||
PutObject(context.Context, *PutObjectRequest) (*PutObjectResponse, error)
|
||||
// DeleteObjects is a hook that deletes one or many files in an external object store
|
||||
// DeleteObjects deletes one or many files in an external object store
|
||||
// via a provided key prefix.
|
||||
DeleteObjects(context.Context, *DeleteObjectsRequest) (*DeleteObjectsResponse, error)
|
||||
mustEmbedUnimplementedStoragePluginServiceServer()
|
||||
|
||||
Reference in new issue
Block a user