Fix unit tests.

This commit is contained in:
Ben Johnson
2020-12-29 12:56:50 -07:00
parent 41448ceb89
commit 6f604e29b0
4 changed files with 16 additions and 17 deletions

View File

@@ -74,7 +74,7 @@ func (c *GenerationsCommand) Run(ctx context.Context, args []string) (err error)
for _, r := range db.Replicas { for _, r := range db.Replicas {
generations, err := r.Generations(ctx) generations, err := r.Generations(ctx)
if err != nil { if err != nil {
log.Printf("%s: cannot list generations", r.Name(), err) log.Printf("%s: cannot list generations: %s", r.Name(), err)
continue continue
} }

4
db.go
View File

@@ -512,7 +512,7 @@ func (db *DB) Sync() (err error) {
changed = true changed = true
if err := db.checkpoint(info, forceCheckpoint); err != nil { if err := db.checkpoint(info, forceCheckpoint); err != nil {
return fmt.Errorf("checkpoint: force=%v err=%w", err) return fmt.Errorf("checkpoint: force=%v err=%w", forceCheckpoint, err)
} }
} }
@@ -1054,7 +1054,7 @@ func (db *DB) Restore(ctx context.Context, opt RestoreOptions) error {
tmpPath := outputPath + ".tmp" tmpPath := outputPath + ".tmp"
// Copy snapshot to output path. // Copy snapshot to output path.
logger.Printf("restoring snapshot from %s://%s/%s to %s", r.Name(), generation, minWALIndex, tmpPath) logger.Printf("restoring snapshot from %s://%s/%016x to %s", r.Name(), generation, minWALIndex, tmpPath)
if !opt.DryRun { if !opt.DryRun {
if err := db.restoreSnapshot(ctx, r, pos.Generation, pos.Index, tmpPath); err != nil { if err := db.restoreSnapshot(ctx, r, pos.Generation, pos.Index, tmpPath); err != nil {
return fmt.Errorf("cannot restore snapshot: %w", err) return fmt.Errorf("cannot restore snapshot: %w", err)

File diff suppressed because one or more lines are too long

View File

@@ -238,7 +238,7 @@ func (r *FileReplica) Stop() {
func (r *FileReplica) monitor(ctx context.Context) { func (r *FileReplica) monitor(ctx context.Context) {
// Clear old temporary files that my have been left from a crash. // Clear old temporary files that my have been left from a crash.
if err := removeTmpFiles(r.dst); err != nil { if err := removeTmpFiles(r.dst); err != nil {
log.Printf("%s(%s): cannot remove tmp files: %w", r.db.Path(), r.Name(), err) log.Printf("%s(%s): cannot remove tmp files: %s", r.db.Path(), r.Name(), err)
} }
// Continuously check for new data to replicate. // Continuously check for new data to replicate.
@@ -261,7 +261,7 @@ func (r *FileReplica) monitor(ctx context.Context) {
// Determine position, if necessary. // Determine position, if necessary.
if pos.IsZero() { if pos.IsZero() {
if pos, err = r.pos(); err != nil { if pos, err = r.pos(); err != nil {
log.Printf("%s(%s): cannot determine position: %w", r.db.Path(), r.Name(), err) log.Printf("%s(%s): cannot determine position: %s", r.db.Path(), r.Name(), err)
continue continue
} else if pos.IsZero() { } else if pos.IsZero() {
log.Printf("%s(%s): no generation, waiting for data", r.db.Path(), r.Name()) log.Printf("%s(%s): no generation, waiting for data", r.db.Path(), r.Name())