Skip to content

Commit

Permalink
Remaining lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Sep 12, 2024
1 parent b9033f8 commit 9cfb6f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/cmd/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,16 @@ func (r *restorer) restoreFromDecoder(ctx context.Context) error {
}

totalTime := time.Since(relationshipWriteStart)
// This shouldn't realistically overflow.
writtenAndSkipped, _ := safecast.ToUint64(r.writtenRels + r.skippedRels)
log.Info().
Int64("batches", r.writtenBatches).
Int64("relationships_loaded", r.writtenRels).
Int64("relationships_skipped", r.skippedRels).
Int64("duplicate_relationships", r.duplicateRels).
Int64("relationships_filtered_out", r.filteredOutRels).
Int64("retried_errors", r.totalRetries).
Uint64("perSecond", perSec(uint64(r.writtenRels+r.skippedRels), totalTime)).
Uint64("perSecond", perSec(writtenAndSkipped, totalTime)).
Stringer("duration", totalTime).
Msg("finished restore")
return nil
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/restorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,15 @@ func TestRestorer(t *testing.T) {
require.Equal(expectedTouchedRels, c.touchedRels, "unexpected number of touched commits")

// assert on restorer stats
uintExpectedConflicts, err := safecast.ToUint(expectedConflicts)
require.NoError(err)
uintDuplicateBatches, err := safecast.ToUint(r.duplicateBatches)
require.NoError(err)
require.Equal(expectedWrittenRels, int(r.writtenRels), "unexpected number of written relationships")
require.Equal(expectedWrittenBatches, int(r.writtenBatches), "unexpected number of written relationships")
require.Equal(expectedSkippedBatches, int(r.skippedBatches), "unexpected number of conflicting batches skipped")
require.Equal(expectedSkippedRels, int(r.skippedRels), "unexpected number of conflicting relationships skipped")
require.Equal(uint(expectedConflicts)*tt.batchesPerTransaction, uint(r.duplicateBatches), "unexpected number of duplicate batches detected")
require.Equal(uintExpectedConflicts*tt.batchesPerTransaction, uintDuplicateBatches, "unexpected number of duplicate batches detected")
require.Equal(expectedConflicts*batchesPerTransaction*tt.batchSize, int(r.duplicateRels), "unexpected number of duplicate relationships detected")
require.Equal(int64(expectedRetries+expectedConflicts-expectedSkippedBatches), r.totalRetries, "unexpected number of retries")
require.Equal(len(tt.relationships)-len(expectedFilteredRels), int(r.filteredOutRels), "unexpected number of filtered out relationships")
Expand Down

0 comments on commit 9cfb6f5

Please sign in to comment.