mirror of
https://github.com/garethgeorge/backrest.git
synced 2025-12-16 18:45:36 +00:00
fix: repo orchestrator tests
This commit is contained in:
@@ -48,6 +48,11 @@ func (r *RepoOrchestrator) SnapshotsForPlan(ctx context.Context, plan *v1.Plan)
|
|||||||
|
|
||||||
func (r *RepoOrchestrator) Backup(ctx context.Context, plan *v1.Plan, progressCallback func(event *restic.BackupProgressEntry)) (*restic.BackupProgressEntry, error) {
|
func (r *RepoOrchestrator) Backup(ctx context.Context, plan *v1.Plan, progressCallback func(event *restic.BackupProgressEntry)) (*restic.BackupProgressEntry, error) {
|
||||||
zap.L().Debug("repo orchestrator starting backup", zap.String("repo", r.repoConfig.Id))
|
zap.L().Debug("repo orchestrator starting backup", zap.String("repo", r.repoConfig.Id))
|
||||||
|
|
||||||
|
if err := r.repo.Init(ctx); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to init repo: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
snapshots, err := r.SnapshotsForPlan(ctx, plan)
|
snapshots, err := r.SnapshotsForPlan(ctx, plan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get snapshots for plan: %w", err)
|
return nil, fmt.Errorf("failed to get snapshots for plan: %w", err)
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func TestSnapshotParenting(t *testing.T) {
|
|||||||
|
|
||||||
orchestrator := newRepoOrchestrator(r, restic.NewRepo(r, restic.WithFlags("--no-cache")))
|
orchestrator := newRepoOrchestrator(r, restic.NewRepo(r, restic.WithFlags("--no-cache")))
|
||||||
|
|
||||||
for i := 0; i < 4; i ++{
|
for i := 0; i < 4; i++ {
|
||||||
for _, plan := range plans {
|
for _, plan := range plans {
|
||||||
summary, err := orchestrator.Backup(context.Background(), plan, nil)
|
summary, err := orchestrator.Backup(context.Background(), plan, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -105,7 +105,7 @@ func TestSnapshotParenting(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i := 1; i < len(snapshots); i++ {
|
for i := 1; i < len(snapshots); i++ {
|
||||||
prev := snapshots[i - 1]
|
prev := snapshots[i-1]
|
||||||
curr := snapshots[i]
|
curr := snapshots[i]
|
||||||
|
|
||||||
if prev.ToProto().UnixTimeMs >= curr.ToProto().UnixTimeMs {
|
if prev.ToProto().UnixTimeMs >= curr.ToProto().UnixTimeMs {
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ func (r *Repo) init(ctx context.Context) error {
|
|||||||
func (r *Repo) Init(ctx context.Context) error {
|
func (r *Repo) Init(ctx context.Context) error {
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
defer r.mu.Unlock()
|
defer r.mu.Unlock()
|
||||||
r.initialized = false
|
|
||||||
return r.init(ctx)
|
return r.init(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user