Skip to content

Commit

Permalink
Rename SnapshotRestore to Restore
Browse files Browse the repository at this point in the history
  • Loading branch information
e-sumin committed May 21, 2024
1 parent 2547a8d commit 92c4a3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/kopia/command/parse_command_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (

//nolint:lll
snapshotCreateOutputRegEx = `(?P<spinner>[|/\-\\\*]).+[^\d](?P<numHashed>\d+) hashed \((?P<hashedSize>[^\)]+)\), (?P<numCached>\d+) cached \((?P<cachedSize>[^\)]+)\), uploaded (?P<uploadedSize>[^\)]+), (?:estimating...|estimated (?P<estimatedSize>[^\)]+) \((?P<estimatedProgress>[^\)]+)\%\).+)`
snapshotRestoreOutputRegEx = `Processed (?P<processedCount>\d+) \((?P<processedSize>.*)\) of (?P<totalCount>\d+) \((?P<totalSize>.*)\) (?P<dataRate>.*) \((?P<percentage>.*)%\) remaining (?P<remainingTime>.*)\.`
restoreOutputRegEx = `Processed (?P<processedCount>\d+) \((?P<processedSize>.*)\) of (?P<totalCount>\d+) \((?P<totalSize>.*)\) (?P<dataRate>.*) \((?P<percentage>.*)%\) remaining (?P<remainingTime>.*)\.`
extractSnapshotIDRegEx = `Created snapshot with root ([^\s]+) and ID ([^\s]+).*$`
repoTotalSizeFromBlobStatsRegEx = `Total: (\d+)$`
repoCountFromBlobStatsRegEx = `Count: (\d+)$`
Expand Down Expand Up @@ -208,7 +208,7 @@ type SnapshotCreateStats struct {

var (
kopiaProgressPattern = regexp.MustCompile(snapshotCreateOutputRegEx)
kopiaRestorePattern = regexp.MustCompile(snapshotRestoreOutputRegEx)
kopiaRestorePattern = regexp.MustCompile(restoreOutputRegEx)
)

// SnapshotStatsFromSnapshotCreate parses the output of a `kopia snapshot
Expand Down
14 changes: 7 additions & 7 deletions pkg/kopia/command/parse_command_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotCreate(c *C
}
}

func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotRestore(c *C) {
func (kParse *KopiaParseUtilsTestSuite) TestRestoreStatsFromRestoreOutput(c *C) {
type args struct {
snapshotRestoreOutput string
restoreOutput string
}
tests := []struct {
name string
Expand All @@ -452,7 +452,7 @@ func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotRestore(c *
{
name: "Basic test case",
args: args{
snapshotRestoreOutput: "Processed 2 (397.5 MB) of 3 (3.1 GB) 14.9 MB/s (12.6%) remaining 3m3s.",
restoreOutput: "Processed 2 (397.5 MB) of 3 (3.1 GB) 14.9 MB/s (12.6%) remaining 3m3s.",
},
wantStats: &RestoreStats{
FilesProcessed: 2,
Expand All @@ -465,7 +465,7 @@ func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotRestore(c *
{
name: "Real test case",
args: args{
snapshotRestoreOutput: "Processed 2 (13.7 MB) of 2 (3.1 GB) 8.5 MB/s (0.4%) remaining 6m10s.",
restoreOutput: "Processed 2 (13.7 MB) of 2 (3.1 GB) 8.5 MB/s (0.4%) remaining 6m10s.",
},
wantStats: &RestoreStats{
FilesProcessed: 2,
Expand All @@ -478,14 +478,14 @@ func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotRestore(c *
{
name: "Ignore incomplete stats without during estimation",
args: args{
snapshotRestoreOutput: "Processed 2 (32.8 KB) of 2 (3.1 GB).",
restoreOutput: "Processed 2 (32.8 KB) of 2 (3.1 GB).",
},
wantStats: nil,
},
{
name: "Progress is over 100% and still not ready - set 99%",
args: args{
snapshotRestoreOutput: "Processed 2 (13.7 MB) of 2 (3.1 GB) 8.5 MB/s (120.4%) remaining 6m10s.",
restoreOutput: "Processed 2 (13.7 MB) of 2 (3.1 GB) 8.5 MB/s (120.4%) remaining 6m10s.",
},
wantStats: &RestoreStats{
FilesProcessed: 2,
Expand All @@ -497,7 +497,7 @@ func (kParse *KopiaParseUtilsTestSuite) TestSnapshotStatsFromSnapshotRestore(c *
},
}
for _, tt := range tests {
stats := RestoreStatsFromRestoreOutput(tt.args.snapshotRestoreOutput)
stats := RestoreStatsFromRestoreOutput(tt.args.restoreOutput)
c.Check(stats, DeepEquals, tt.wantStats, Commentf("Failed for %s", tt.name))
}
}
Expand Down

0 comments on commit 92c4a3a

Please sign in to comment.