Skip to content

Commit

Permalink
backupccl: deflake TestShowBackup
Browse files Browse the repository at this point in the history
This patch simplifies how TestShowBackup parses the stringed timestamp: it
removes the manual splitting of date and time and parses the stringed timestamp
in one call.

Fixes: #111015

Release note: none
  • Loading branch information
msbutler committed Oct 4, 2023
1 parent 1268ef1 commit 899fb87
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions pkg/ccl/backupccl/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,7 @@ ORDER BY object_type, object_name`, full)
{"t2", "incremental", beforeTS, incTS, "0", "false"},
}, res)

// Different systems output different precisions (i.e. local OS X vs CI).
// Truncate decimal places so Go's very rigid parsing will work.
// TODO(bardin): Consider using a third-party library for this, or some kind
// of time-freezing on the test cluster.
truncateBackupTimeRE := regexp.MustCompile(`^(.*\.[0-9]{2})[0-9]*\+00$`)
matchResult := truncateBackupTimeRE.FindStringSubmatch(beforeTS)
require.NotNil(t, matchResult, "%s does not match %s", beforeTS, truncateBackupTimeRE)
backupTime, err := time.Parse("2006-01-02 15:04:05.00", matchResult[1])
backupTime, err := time.Parse("2006-01-02 15:04:05.999999Z07", beforeTS)
require.NoError(t, err)
backupFolder := backupTime.Format(backupbase.DateBasedIntoFolderName)
resolvedBackupFolder := full + backupFolder
Expand Down

0 comments on commit 899fb87

Please sign in to comment.