ping kopia to 0.18.2

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
Lyndon-Li
2024-12-03 13:06:26 +08:00
parent b89270f2c1
commit 3cd85f5b43
12 changed files with 566 additions and 263 deletions
@@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v2.39.1. DO NOT EDIT.
package mocks
@@ -26,6 +26,10 @@ type RepositoryWriter struct {
func (_m *RepositoryWriter) ClientOptions() repo.ClientOptions {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ClientOptions")
}
var r0 repo.ClientOptions
if rf, ok := ret.Get(0).(func() repo.ClientOptions); ok {
r0 = rf()
@@ -40,6 +44,10 @@ func (_m *RepositoryWriter) ClientOptions() repo.ClientOptions {
func (_m *RepositoryWriter) Close(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Close")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -50,23 +58,27 @@ func (_m *RepositoryWriter) Close(ctx context.Context) error {
return r0
}
// ConcatenateObjects provides a mock function with given fields: ctx, objectIDs
func (_m *RepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []object.ID) (object.ID, error) {
ret := _m.Called(ctx, objectIDs)
// ConcatenateObjects provides a mock function with given fields: ctx, objectIDs, opt
func (_m *RepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []object.ID, opt repo.ConcatenateOptions) (object.ID, error) {
ret := _m.Called(ctx, objectIDs, opt)
if len(ret) == 0 {
panic("no return value specified for ConcatenateObjects")
}
var r0 object.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, []object.ID) (object.ID, error)); ok {
return rf(ctx, objectIDs)
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) (object.ID, error)); ok {
return rf(ctx, objectIDs, opt)
}
if rf, ok := ret.Get(0).(func(context.Context, []object.ID) object.ID); ok {
r0 = rf(ctx, objectIDs)
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) object.ID); ok {
r0 = rf(ctx, objectIDs, opt)
} else {
r0 = ret.Get(0).(object.ID)
}
if rf, ok := ret.Get(1).(func(context.Context, []object.ID) error); ok {
r1 = rf(ctx, objectIDs)
if rf, ok := ret.Get(1).(func(context.Context, []object.ID, repo.ConcatenateOptions) error); ok {
r1 = rf(ctx, objectIDs, opt)
} else {
r1 = ret.Error(1)
}
@@ -78,6 +90,10 @@ func (_m *RepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []
func (_m *RepositoryWriter) ContentInfo(ctx context.Context, contentID index.ID) (index.Info, error) {
ret := _m.Called(ctx, contentID)
if len(ret) == 0 {
panic("no return value specified for ContentInfo")
}
var r0 index.Info
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, index.ID) (index.Info, error)); ok {
@@ -86,9 +102,7 @@ func (_m *RepositoryWriter) ContentInfo(ctx context.Context, contentID index.ID)
if rf, ok := ret.Get(0).(func(context.Context, index.ID) index.Info); ok {
r0 = rf(ctx, contentID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(index.Info)
}
r0 = ret.Get(0).(index.Info)
}
if rf, ok := ret.Get(1).(func(context.Context, index.ID) error); ok {
@@ -104,6 +118,10 @@ func (_m *RepositoryWriter) ContentInfo(ctx context.Context, contentID index.ID)
func (_m *RepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID) error {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for DeleteManifest")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID) error); ok {
r0 = rf(ctx, id)
@@ -118,6 +136,10 @@ func (_m *RepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID)
func (_m *RepositoryWriter) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) {
ret := _m.Called(ctx, labels)
if len(ret) == 0 {
panic("no return value specified for FindManifests")
}
var r0 []*manifest.EntryMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) ([]*manifest.EntryMetadata, error)); ok {
@@ -144,6 +166,10 @@ func (_m *RepositoryWriter) FindManifests(ctx context.Context, labels map[string
func (_m *RepositoryWriter) Flush(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Flush")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -158,6 +184,10 @@ func (_m *RepositoryWriter) Flush(ctx context.Context) error {
func (_m *RepositoryWriter) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) {
ret := _m.Called(ctx, id, data)
if len(ret) == 0 {
panic("no return value specified for GetManifest")
}
var r0 *manifest.EntryMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) (*manifest.EntryMetadata, error)); ok {
@@ -184,6 +214,10 @@ func (_m *RepositoryWriter) GetManifest(ctx context.Context, id manifest.ID, dat
func (_m *RepositoryWriter) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer {
ret := _m.Called(ctx, opt)
if len(ret) == 0 {
panic("no return value specified for NewObjectWriter")
}
var r0 object.Writer
if rf, ok := ret.Get(0).(func(context.Context, object.WriterOptions) object.Writer); ok {
r0 = rf(ctx, opt)
@@ -200,6 +234,10 @@ func (_m *RepositoryWriter) NewObjectWriter(ctx context.Context, opt object.Writ
func (_m *RepositoryWriter) NewWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error) {
ret := _m.Called(ctx, opt)
if len(ret) == 0 {
panic("no return value specified for NewWriter")
}
var r0 context.Context
var r1 repo.RepositoryWriter
var r2 error
@@ -240,6 +278,10 @@ func (_m *RepositoryWriter) OnSuccessfulFlush(callback repo.RepositoryWriterCall
func (_m *RepositoryWriter) OpenObject(ctx context.Context, id object.ID) (object.Reader, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for OpenObject")
}
var r0 object.Reader
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, object.ID) (object.Reader, error)); ok {
@@ -266,6 +308,10 @@ func (_m *RepositoryWriter) OpenObject(ctx context.Context, id object.ID) (objec
func (_m *RepositoryWriter) PrefetchContents(ctx context.Context, contentIDs []index.ID, hint string) []index.ID {
ret := _m.Called(ctx, contentIDs, hint)
if len(ret) == 0 {
panic("no return value specified for PrefetchContents")
}
var r0 []index.ID
if rf, ok := ret.Get(0).(func(context.Context, []index.ID, string) []index.ID); ok {
r0 = rf(ctx, contentIDs, hint)
@@ -282,6 +328,10 @@ func (_m *RepositoryWriter) PrefetchContents(ctx context.Context, contentIDs []i
func (_m *RepositoryWriter) PrefetchObjects(ctx context.Context, objectIDs []object.ID, hint string) ([]index.ID, error) {
ret := _m.Called(ctx, objectIDs, hint)
if len(ret) == 0 {
panic("no return value specified for PrefetchObjects")
}
var r0 []index.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) ([]index.ID, error)); ok {
@@ -308,6 +358,10 @@ func (_m *RepositoryWriter) PrefetchObjects(ctx context.Context, objectIDs []obj
func (_m *RepositoryWriter) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
ret := _m.Called(ctx, labels, payload)
if len(ret) == 0 {
panic("no return value specified for PutManifest")
}
var r0 manifest.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
@@ -332,6 +386,10 @@ func (_m *RepositoryWriter) PutManifest(ctx context.Context, labels map[string]s
func (_m *RepositoryWriter) Refresh(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Refresh")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -346,6 +404,10 @@ func (_m *RepositoryWriter) Refresh(ctx context.Context) error {
func (_m *RepositoryWriter) ReplaceManifests(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
ret := _m.Called(ctx, labels, payload)
if len(ret) == 0 {
panic("no return value specified for ReplaceManifests")
}
var r0 manifest.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
@@ -370,6 +432,10 @@ func (_m *RepositoryWriter) ReplaceManifests(ctx context.Context, labels map[str
func (_m *RepositoryWriter) Time() time.Time {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for Time")
}
var r0 time.Time
if rf, ok := ret.Get(0).(func() time.Time); ok {
r0 = rf()
@@ -389,6 +455,10 @@ func (_m *RepositoryWriter) UpdateDescription(d string) {
func (_m *RepositoryWriter) VerifyObject(ctx context.Context, id object.ID) ([]index.ID, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for VerifyObject")
}
var r0 []index.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, object.ID) ([]index.ID, error)); ok {
@@ -411,13 +481,12 @@ func (_m *RepositoryWriter) VerifyObject(ctx context.Context, id object.ID) ([]i
return r0, r1
}
type mockConstructorTestingTNewRepositoryWriter interface {
// NewRepositoryWriter creates a new instance of RepositoryWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewRepositoryWriter(t interface {
mock.TestingT
Cleanup(func())
}
// NewRepositoryWriter creates a new instance of RepositoryWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewRepositoryWriter(t mockConstructorTestingTNewRepositoryWriter) *RepositoryWriter {
}) *RepositoryWriter {
mock := &RepositoryWriter{}
mock.Mock.Test(t)
@@ -1,4 +1,4 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
// Code generated by mockery v2.39.1. DO NOT EDIT.
package mocks
@@ -36,6 +36,10 @@ type DirectRepositoryWriter struct {
func (_m *DirectRepositoryWriter) AlsoLogToContentLog(ctx context.Context) context.Context {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for AlsoLogToContentLog")
}
var r0 context.Context
if rf, ok := ret.Get(0).(func(context.Context) context.Context); ok {
r0 = rf(ctx)
@@ -52,6 +56,10 @@ func (_m *DirectRepositoryWriter) AlsoLogToContentLog(ctx context.Context) conte
func (_m *DirectRepositoryWriter) BlobReader() blob.Reader {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for BlobReader")
}
var r0 blob.Reader
if rf, ok := ret.Get(0).(func() blob.Reader); ok {
r0 = rf()
@@ -68,6 +76,10 @@ func (_m *DirectRepositoryWriter) BlobReader() blob.Reader {
func (_m *DirectRepositoryWriter) BlobStorage() blob.Storage {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for BlobStorage")
}
var r0 blob.Storage
if rf, ok := ret.Get(0).(func() blob.Storage); ok {
r0 = rf()
@@ -84,6 +96,10 @@ func (_m *DirectRepositoryWriter) BlobStorage() blob.Storage {
func (_m *DirectRepositoryWriter) BlobVolume() blob.Volume {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for BlobVolume")
}
var r0 blob.Volume
if rf, ok := ret.Get(0).(func() blob.Volume); ok {
r0 = rf()
@@ -100,6 +116,10 @@ func (_m *DirectRepositoryWriter) BlobVolume() blob.Volume {
func (_m *DirectRepositoryWriter) ClientOptions() repo.ClientOptions {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ClientOptions")
}
var r0 repo.ClientOptions
if rf, ok := ret.Get(0).(func() repo.ClientOptions); ok {
r0 = rf()
@@ -114,6 +134,10 @@ func (_m *DirectRepositoryWriter) ClientOptions() repo.ClientOptions {
func (_m *DirectRepositoryWriter) Close(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Close")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -124,23 +148,27 @@ func (_m *DirectRepositoryWriter) Close(ctx context.Context) error {
return r0
}
// ConcatenateObjects provides a mock function with given fields: ctx, objectIDs
func (_m *DirectRepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []object.ID) (object.ID, error) {
ret := _m.Called(ctx, objectIDs)
// ConcatenateObjects provides a mock function with given fields: ctx, objectIDs, opt
func (_m *DirectRepositoryWriter) ConcatenateObjects(ctx context.Context, objectIDs []object.ID, opt repo.ConcatenateOptions) (object.ID, error) {
ret := _m.Called(ctx, objectIDs, opt)
if len(ret) == 0 {
panic("no return value specified for ConcatenateObjects")
}
var r0 object.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, []object.ID) (object.ID, error)); ok {
return rf(ctx, objectIDs)
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) (object.ID, error)); ok {
return rf(ctx, objectIDs, opt)
}
if rf, ok := ret.Get(0).(func(context.Context, []object.ID) object.ID); ok {
r0 = rf(ctx, objectIDs)
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, repo.ConcatenateOptions) object.ID); ok {
r0 = rf(ctx, objectIDs, opt)
} else {
r0 = ret.Get(0).(object.ID)
}
if rf, ok := ret.Get(1).(func(context.Context, []object.ID) error); ok {
r1 = rf(ctx, objectIDs)
if rf, ok := ret.Get(1).(func(context.Context, []object.ID, repo.ConcatenateOptions) error); ok {
r1 = rf(ctx, objectIDs, opt)
} else {
r1 = ret.Error(1)
}
@@ -152,6 +180,10 @@ func (_m *DirectRepositoryWriter) ConcatenateObjects(ctx context.Context, object
func (_m *DirectRepositoryWriter) ConfigFilename() string {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ConfigFilename")
}
var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
@@ -166,6 +198,10 @@ func (_m *DirectRepositoryWriter) ConfigFilename() string {
func (_m *DirectRepositoryWriter) ContentInfo(ctx context.Context, contentID index.ID) (index.Info, error) {
ret := _m.Called(ctx, contentID)
if len(ret) == 0 {
panic("no return value specified for ContentInfo")
}
var r0 index.Info
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, index.ID) (index.Info, error)); ok {
@@ -174,9 +210,7 @@ func (_m *DirectRepositoryWriter) ContentInfo(ctx context.Context, contentID ind
if rf, ok := ret.Get(0).(func(context.Context, index.ID) index.Info); ok {
r0 = rf(ctx, contentID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(index.Info)
}
r0 = ret.Get(0).(index.Info)
}
if rf, ok := ret.Get(1).(func(context.Context, index.ID) error); ok {
@@ -192,6 +226,10 @@ func (_m *DirectRepositoryWriter) ContentInfo(ctx context.Context, contentID ind
func (_m *DirectRepositoryWriter) ContentManager() *content.WriteManager {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ContentManager")
}
var r0 *content.WriteManager
if rf, ok := ret.Get(0).(func() *content.WriteManager); ok {
r0 = rf()
@@ -208,6 +246,10 @@ func (_m *DirectRepositoryWriter) ContentManager() *content.WriteManager {
func (_m *DirectRepositoryWriter) ContentReader() content.Reader {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ContentReader")
}
var r0 content.Reader
if rf, ok := ret.Get(0).(func() content.Reader); ok {
r0 = rf()
@@ -224,6 +266,10 @@ func (_m *DirectRepositoryWriter) ContentReader() content.Reader {
func (_m *DirectRepositoryWriter) DeleteManifest(ctx context.Context, id manifest.ID) error {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for DeleteManifest")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID) error); ok {
r0 = rf(ctx, id)
@@ -238,6 +284,10 @@ func (_m *DirectRepositoryWriter) DeleteManifest(ctx context.Context, id manifes
func (_m *DirectRepositoryWriter) DeriveKey(purpose []byte, keyLength int) []byte {
ret := _m.Called(purpose, keyLength)
if len(ret) == 0 {
panic("no return value specified for DeriveKey")
}
var r0 []byte
if rf, ok := ret.Get(0).(func([]byte, int) []byte); ok {
r0 = rf(purpose, keyLength)
@@ -259,6 +309,10 @@ func (_m *DirectRepositoryWriter) DisableIndexRefresh() {
func (_m *DirectRepositoryWriter) FindManifests(ctx context.Context, labels map[string]string) ([]*manifest.EntryMetadata, error) {
ret := _m.Called(ctx, labels)
if len(ret) == 0 {
panic("no return value specified for FindManifests")
}
var r0 []*manifest.EntryMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string) ([]*manifest.EntryMetadata, error)); ok {
@@ -285,6 +339,10 @@ func (_m *DirectRepositoryWriter) FindManifests(ctx context.Context, labels map[
func (_m *DirectRepositoryWriter) Flush(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Flush")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -299,6 +357,10 @@ func (_m *DirectRepositoryWriter) Flush(ctx context.Context) error {
func (_m *DirectRepositoryWriter) FormatManager() *format.Manager {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for FormatManager")
}
var r0 *format.Manager
if rf, ok := ret.Get(0).(func() *format.Manager); ok {
r0 = rf()
@@ -315,6 +377,10 @@ func (_m *DirectRepositoryWriter) FormatManager() *format.Manager {
func (_m *DirectRepositoryWriter) GetManifest(ctx context.Context, id manifest.ID, data interface{}) (*manifest.EntryMetadata, error) {
ret := _m.Called(ctx, id, data)
if len(ret) == 0 {
panic("no return value specified for GetManifest")
}
var r0 *manifest.EntryMetadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, manifest.ID, interface{}) (*manifest.EntryMetadata, error)); ok {
@@ -341,6 +407,10 @@ func (_m *DirectRepositoryWriter) GetManifest(ctx context.Context, id manifest.I
func (_m *DirectRepositoryWriter) IndexBlobs(ctx context.Context, includeInactive bool) ([]indexblob.Metadata, error) {
ret := _m.Called(ctx, includeInactive)
if len(ret) == 0 {
panic("no return value specified for IndexBlobs")
}
var r0 []indexblob.Metadata
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, bool) ([]indexblob.Metadata, error)); ok {
@@ -367,6 +437,10 @@ func (_m *DirectRepositoryWriter) IndexBlobs(ctx context.Context, includeInactiv
func (_m *DirectRepositoryWriter) NewDirectWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.DirectRepositoryWriter, error) {
ret := _m.Called(ctx, opt)
if len(ret) == 0 {
panic("no return value specified for NewDirectWriter")
}
var r0 context.Context
var r1 repo.DirectRepositoryWriter
var r2 error
@@ -402,6 +476,10 @@ func (_m *DirectRepositoryWriter) NewDirectWriter(ctx context.Context, opt repo.
func (_m *DirectRepositoryWriter) NewObjectWriter(ctx context.Context, opt object.WriterOptions) object.Writer {
ret := _m.Called(ctx, opt)
if len(ret) == 0 {
panic("no return value specified for NewObjectWriter")
}
var r0 object.Writer
if rf, ok := ret.Get(0).(func(context.Context, object.WriterOptions) object.Writer); ok {
r0 = rf(ctx, opt)
@@ -418,6 +496,10 @@ func (_m *DirectRepositoryWriter) NewObjectWriter(ctx context.Context, opt objec
func (_m *DirectRepositoryWriter) NewWriter(ctx context.Context, opt repo.WriteSessionOptions) (context.Context, repo.RepositoryWriter, error) {
ret := _m.Called(ctx, opt)
if len(ret) == 0 {
panic("no return value specified for NewWriter")
}
var r0 context.Context
var r1 repo.RepositoryWriter
var r2 error
@@ -453,6 +535,10 @@ func (_m *DirectRepositoryWriter) NewWriter(ctx context.Context, opt repo.WriteS
func (_m *DirectRepositoryWriter) ObjectFormat() format.ObjectFormat {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for ObjectFormat")
}
var r0 format.ObjectFormat
if rf, ok := ret.Get(0).(func() format.ObjectFormat); ok {
r0 = rf()
@@ -472,6 +558,10 @@ func (_m *DirectRepositoryWriter) OnSuccessfulFlush(callback repo.RepositoryWrit
func (_m *DirectRepositoryWriter) OpenObject(ctx context.Context, id object.ID) (object.Reader, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for OpenObject")
}
var r0 object.Reader
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, object.ID) (object.Reader, error)); ok {
@@ -498,6 +588,10 @@ func (_m *DirectRepositoryWriter) OpenObject(ctx context.Context, id object.ID)
func (_m *DirectRepositoryWriter) PrefetchContents(ctx context.Context, contentIDs []index.ID, hint string) []index.ID {
ret := _m.Called(ctx, contentIDs, hint)
if len(ret) == 0 {
panic("no return value specified for PrefetchContents")
}
var r0 []index.ID
if rf, ok := ret.Get(0).(func(context.Context, []index.ID, string) []index.ID); ok {
r0 = rf(ctx, contentIDs, hint)
@@ -514,6 +608,10 @@ func (_m *DirectRepositoryWriter) PrefetchContents(ctx context.Context, contentI
func (_m *DirectRepositoryWriter) PrefetchObjects(ctx context.Context, objectIDs []object.ID, hint string) ([]index.ID, error) {
ret := _m.Called(ctx, objectIDs, hint)
if len(ret) == 0 {
panic("no return value specified for PrefetchObjects")
}
var r0 []index.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, []object.ID, string) ([]index.ID, error)); ok {
@@ -540,6 +638,10 @@ func (_m *DirectRepositoryWriter) PrefetchObjects(ctx context.Context, objectIDs
func (_m *DirectRepositoryWriter) PutManifest(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
ret := _m.Called(ctx, labels, payload)
if len(ret) == 0 {
panic("no return value specified for PutManifest")
}
var r0 manifest.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
@@ -564,6 +666,10 @@ func (_m *DirectRepositoryWriter) PutManifest(ctx context.Context, labels map[st
func (_m *DirectRepositoryWriter) Refresh(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Refresh")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
@@ -578,6 +684,10 @@ func (_m *DirectRepositoryWriter) Refresh(ctx context.Context) error {
func (_m *DirectRepositoryWriter) ReplaceManifests(ctx context.Context, labels map[string]string, payload interface{}) (manifest.ID, error) {
ret := _m.Called(ctx, labels, payload)
if len(ret) == 0 {
panic("no return value specified for ReplaceManifests")
}
var r0 manifest.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, map[string]string, interface{}) (manifest.ID, error)); ok {
@@ -602,6 +712,10 @@ func (_m *DirectRepositoryWriter) ReplaceManifests(ctx context.Context, labels m
func (_m *DirectRepositoryWriter) Throttler() throttling.SettableThrottler {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for Throttler")
}
var r0 throttling.SettableThrottler
if rf, ok := ret.Get(0).(func() throttling.SettableThrottler); ok {
r0 = rf()
@@ -618,6 +732,10 @@ func (_m *DirectRepositoryWriter) Throttler() throttling.SettableThrottler {
func (_m *DirectRepositoryWriter) Time() time.Time {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for Time")
}
var r0 time.Time
if rf, ok := ret.Get(0).(func() time.Time); ok {
r0 = rf()
@@ -632,6 +750,10 @@ func (_m *DirectRepositoryWriter) Time() time.Time {
func (_m *DirectRepositoryWriter) Token(password string) (string, error) {
ret := _m.Called(password)
if len(ret) == 0 {
panic("no return value specified for Token")
}
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
@@ -656,6 +778,10 @@ func (_m *DirectRepositoryWriter) Token(password string) (string, error) {
func (_m *DirectRepositoryWriter) UniqueID() []byte {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for UniqueID")
}
var r0 []byte
if rf, ok := ret.Get(0).(func() []byte); ok {
r0 = rf()
@@ -677,6 +803,10 @@ func (_m *DirectRepositoryWriter) UpdateDescription(d string) {
func (_m *DirectRepositoryWriter) VerifyObject(ctx context.Context, id object.ID) ([]index.ID, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for VerifyObject")
}
var r0 []index.ID
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, object.ID) ([]index.ID, error)); ok {
@@ -699,13 +829,12 @@ func (_m *DirectRepositoryWriter) VerifyObject(ctx context.Context, id object.ID
return r0, r1
}
type mockConstructorTestingTNewDirectRepositoryWriter interface {
// NewDirectRepositoryWriter creates a new instance of DirectRepositoryWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewDirectRepositoryWriter(t interface {
mock.TestingT
Cleanup(func())
}
// NewDirectRepositoryWriter creates a new instance of DirectRepositoryWriter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewDirectRepositoryWriter(t mockConstructorTestingTNewDirectRepositoryWriter) *DirectRepositoryWriter {
}) *DirectRepositoryWriter {
mock := &DirectRepositoryWriter{}
mock.Mock.Test(t)
+17 -16
View File
@@ -72,9 +72,7 @@ type kopiaObjectWriter struct {
rawWriter object.Writer
}
type openOptions struct {
allowIndexWriteOnLoad bool
}
type openOptions struct{}
const (
defaultLogInterval = time.Second * 10
@@ -320,10 +318,11 @@ func (kr *kopiaRepository) NewObjectWriter(ctx context.Context, opt udmrepo.Obje
}
writer := kr.rawWriter.NewObjectWriter(kopia.SetupKopiaLog(ctx, kr.logger), object.WriterOptions{
Description: opt.Description,
Prefix: index.IDPrefix(opt.Prefix),
AsyncWrites: opt.AsyncWrites,
Compressor: getCompressorForObject(opt),
Description: opt.Description,
Prefix: index.IDPrefix(opt.Prefix),
AsyncWrites: opt.AsyncWrites,
Compressor: getCompressorForObject(opt),
MetadataCompressor: getMetadataCompressor(),
})
if writer == nil {
@@ -399,7 +398,9 @@ func (kr *kopiaRepository) ConcatenateObjects(ctx context.Context, objectIDs []u
rawIDs = append(rawIDs, rawID)
}
result, err := kr.rawWriter.ConcatenateObjects(ctx, rawIDs)
result, err := kr.rawWriter.ConcatenateObjects(ctx, rawIDs, repo.ConcatenateOptions{
Compressor: getMetadataCompressor(),
})
if err != nil {
return udmrepo.ID(""), errors.Wrap(err, "error to concatenate objects")
}
@@ -515,10 +516,15 @@ func (kow *kopiaObjectWriter) Close() error {
}
// getCompressorForObject returns the compressor for an object, at present, we don't support compression
func getCompressorForObject(opt udmrepo.ObjectWriteOptions) compression.Name {
func getCompressorForObject(_ udmrepo.ObjectWriteOptions) compression.Name {
return ""
}
// getMetadataCompressor returns the compressor for metadata, return kopia's default since we don't support compression
func getMetadataCompressor() compression.Name {
return "zstd-fastest"
}
func getManifestEntryFromKopia(mani *manifest.EntryMetadata) *udmrepo.ManifestEntryMetadata {
return &udmrepo.ManifestEntryMetadata{
ID: udmrepo.ID(mani.ID),
@@ -554,13 +560,8 @@ func (lt *logThrottle) shouldLog() bool {
return false
}
func openKopiaRepo(ctx context.Context, configFile string, password string, options *openOptions) (repo.Repository, error) {
allowIndexWriteOnLoad := false
if options != nil {
allowIndexWriteOnLoad = options.allowIndexWriteOnLoad
}
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{AllowWriteOnIndexLoad: allowIndexWriteOnLoad})
func openKopiaRepo(ctx context.Context, configFile string, password string, _ *openOptions) (repo.Repository, error) {
r, err := kopiaRepoOpen(ctx, configFile, password, &repo.Options{})
if os.IsNotExist(err) {
return nil, errors.Wrap(err, "error to open repo, repo doesn't exist")
}
@@ -770,7 +770,7 @@ func TestConcatenateObjects(t *testing.T) {
if tc.rawWriter != nil {
require.NotNil(t, tc.rawWriter)
tc.rawWriter.On("ConcatenateObjects", mock.Anything, mock.Anything).Return(object.ID{}, tc.rawWriterRetErr)
tc.rawWriter.On("ConcatenateObjects", mock.Anything, mock.Anything, mock.Anything).Return(object.ID{}, tc.rawWriterRetErr)
}
if tc.setWriter {
+36 -15
View File
@@ -23,6 +23,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/vmware-tanzu/velero/pkg/uploader"
"github.com/kopia/kopia/snapshot/snapshotfs"
)
// Throttle throttles controlle the interval of output result
@@ -41,11 +43,6 @@ func (t *Throttle) ShouldOutput() bool {
return false
}
func (p *Progress) InitThrottle(interval time.Duration) {
p.outputThrottle.throttle = 0
p.outputThrottle.interval = interval
}
// Progress represents a backup or restore counters.
type Progress struct {
// all int64 must precede all int32 due to alignment requirements on ARM
@@ -59,13 +56,29 @@ type Progress struct {
ignoredErrorCount int32 //the total errors has ignored
// +checkatomic
fatalErrorCount int32 //the total errors has occurred
estimatedFileCount int32 // +checklocksignore the total count of files to be processed
estimatedFileCount int64 // +checklocksignore the total count of files to be processed
estimatedTotalBytes int64 // +checklocksignore the total size of files to be processed
// +checkatomic
processedBytes int64 // which statistic all bytes has been processed currently
outputThrottle Throttle // which control the frequency of update progress
Updater uploader.ProgressUpdater //which kopia progress will call the UpdateProgress interface, the third party will implement the interface to do the progress update
Log logrus.FieldLogger // output info into log when backup
processedBytes int64 // which statistic all bytes has been processed currently
outputThrottle Throttle // which control the frequency of update progress
updater uploader.ProgressUpdater //which kopia progress will call the UpdateProgress interface, the third party will implement the interface to do the progress update
log logrus.FieldLogger // output info into log when backup
estimationParam snapshotfs.EstimationParameters
}
func NewProgress(updater uploader.ProgressUpdater, interval time.Duration, log logrus.FieldLogger) *Progress {
return &Progress{
outputThrottle: Throttle{
throttle: 0,
interval: interval,
},
updater: updater,
estimationParam: snapshotfs.EstimationParameters{
Type: snapshotfs.EstimationTypeClassic,
AdaptiveThreshold: 300000,
},
log: log,
}
}
// UploadedBytes the total bytes has uploaded currently
@@ -80,17 +93,17 @@ func (p *Progress) UploadedBytes(numBytes int64) {
func (p *Progress) Error(path string, err error, isIgnored bool) {
if isIgnored {
atomic.AddInt32(&p.ignoredErrorCount, 1)
p.Log.Warnf("Ignored error when processing %v: %v", path, err)
p.log.Warnf("Ignored error when processing %v: %v", path, err)
} else {
atomic.AddInt32(&p.fatalErrorCount, 1)
p.Log.Errorf("Error when processing %v: %v", path, err)
p.log.Errorf("Error when processing %v: %v", path, err)
}
}
// EstimatedDataSize statistic the total size of files to be processed and total files to be processed
func (p *Progress) EstimatedDataSize(fileCount int, totalBytes int64) {
func (p *Progress) EstimatedDataSize(fileCount int64, totalBytes int64) {
atomic.StoreInt64(&p.estimatedTotalBytes, totalBytes)
atomic.StoreInt32(&p.estimatedFileCount, int32(fileCount))
atomic.StoreInt64(&p.estimatedFileCount, fileCount)
p.UpdateProgress()
}
@@ -98,7 +111,7 @@ func (p *Progress) EstimatedDataSize(fileCount int, totalBytes int64) {
// UpdateProgress which calls Updater UpdateProgress interface, update progress by third-party implementation
func (p *Progress) UpdateProgress() {
if p.outputThrottle.ShouldOutput() {
p.Updater.UpdateProgress(&uploader.Progress{TotalBytes: p.estimatedTotalBytes, BytesDone: p.processedBytes})
p.updater.UpdateProgress(&uploader.Progress{TotalBytes: p.estimatedTotalBytes, BytesDone: p.processedBytes})
}
}
@@ -153,3 +166,11 @@ func (p *Progress) ProgressBytes(processedBytes int64, totalBytes int64) {
}
func (p *Progress) FinishedFile(fname string, err error) {}
func (p *Progress) EstimationParameters() snapshotfs.EstimationParameters {
return p.estimationParam
}
func (p *Progress) Enabled() bool {
return true
}
+18 -9
View File
@@ -39,11 +39,16 @@ func TestThrottle_ShouldOutput(t *testing.T) {
{interval: time.Second, expectedOutput: true},
{interval: time.Second, throttle: time.Now().UnixNano() + int64(time.Nanosecond*100000000), expectedOutput: false},
}
p := new(Progress)
for _, tc := range testCases {
// Setup
p.InitThrottle(tc.interval)
p.outputThrottle.throttle = tc.throttle
p := &Progress{
outputThrottle: Throttle{
interval: tc.interval,
throttle: tc.throttle,
},
}
// Perform the test
output := p.outputThrottle.ShouldOutput()
@@ -65,14 +70,18 @@ func TestProgress(t *testing.T) {
{interval: time.Second},
{interval: time.Second, throttle: time.Now().UnixNano() + int64(time.Nanosecond*10000)},
}
p := new(Progress)
p.Log = logrus.New()
p.Updater = &fakeProgressUpdater{}
for _, tc := range testCases {
// Setup
p.InitThrottle(tc.interval)
p.outputThrottle.throttle = tc.throttle
p.InitThrottle(time.Second)
p := &Progress{
outputThrottle: Throttle{
interval: tc.interval,
throttle: tc.throttle,
},
updater: &fakeProgressUpdater{},
log: logrus.New(),
}
// All below calls put together for the implementation are empty or just very simple and just want to cover testing
// If wanting to write unit tests for some functions could remove it and with writing new function alone
p.UpdateProgress()
+1 -1
View File
@@ -237,7 +237,7 @@ func (sr *shimRepository) Flush(ctx context.Context) error {
return sr.udmRepo.Flush(ctx)
}
func (sr *shimRepository) ConcatenateObjects(ctx context.Context, objectIDs []object.ID) (object.ID, error) {
func (sr *shimRepository) ConcatenateObjects(ctx context.Context, objectIDs []object.ID, opt repo.ConcatenateOptions) (object.ID, error) {
if len(objectIDs) == 0 {
return object.EmptyID, errors.New("object list is empty")
}
+1 -1
View File
@@ -338,7 +338,7 @@ func TestConcatenateObjects(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
_, err := NewShimRepo(tc.backupRepo).ConcatenateObjects(ctx, tc.objectIDs)
_, err := NewShimRepo(tc.backupRepo).ConcatenateObjects(ctx, tc.objectIDs, repo.ConcatenateOptions{})
if tc.expectedError != "" {
assert.EqualError(t, err, tc.expectedError)
+2 -8
View File
@@ -136,11 +136,7 @@ func (kp *kopiaProvider) RunBackup(
})
repoWriter := kopia.NewShimRepo(kp.bkRepo)
kpUploader := snapshotfs.NewUploader(repoWriter)
progress := new(kopia.Progress)
progress.InitThrottle(backupProgressCheckInterval)
progress.Updater = updater
progress.Log = log
kpUploader.Progress = progress
kpUploader.Progress = kopia.NewProgress(updater, backupProgressCheckInterval, log)
kpUploader.FailFast = true
quit := make(chan struct{})
log.Info("Starting backup")
@@ -222,9 +218,7 @@ func (kp *kopiaProvider) RunRestore(
})
repoWriter := kopia.NewShimRepo(kp.bkRepo)
progress := new(kopia.Progress)
progress.InitThrottle(restoreProgressCheckInterval)
progress.Updater = updater
progress := kopia.NewProgress(updater, restoreProgressCheckInterval, log)
restoreCancel := make(chan struct{})
quit := make(chan struct{})