Skip to content

Commit 39a88d4

Browse files
committed
fix some, int test still broken
Signed-off-by: Wenqi Mou <[email protected]>
1 parent 206bdb7 commit 39a88d4

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

br/pkg/checkpoint/name.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type TableIdentifier struct {
3030
// GenerateTableNameSuffix generates a unique suffix for checkpoint table names based on restore parameters
3131
func (t *TableIdentifier) GenerateTableNameSuffix() string {
3232
// combine all parameters into a unique string
33-
uniqueStr := fmt.Sprintf("%d-%d-%s-%s-%d-%s",
33+
uniqueStr := fmt.Sprintf("%d-%d-%s-%d-%s",
3434
t.StartTS,
3535
t.EndTS,
3636
t.Filter,

br/pkg/checkpoint/name_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package checkpoint
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestTableIdentifier(t *testing.T) {
10+
identifier := TableIdentifier{
11+
StartTS: 1704067200000, // 2024-01-01 00:00:00
12+
EndTS: 1704153600000, // 2024-01-02 00:00:00
13+
Filter: []string{"db1.table1", "db2.*", "*.table3", "db4.table4"},
14+
UpstreamClusterID: 987654321,
15+
TaskType: "incremental-restore",
16+
}
17+
18+
suffix := identifier.GenerateTableNameSuffix()
19+
20+
// length check, "_" + 16 hex chars
21+
require.Equal(t, 17, len(suffix))
22+
23+
// first item check
24+
require.Equal(t, byte('_'), suffix[0])
25+
26+
// generate again to verify deterministic behavior
27+
secondSuffix := identifier.GenerateTableNameSuffix()
28+
require.Equal(t, secondSuffix, suffix)
29+
30+
// verify that changing any field produces a different suffix
31+
modifiedIdentifier := identifier
32+
modifiedIdentifier.Filter = []string{}
33+
differentSuffix := modifiedIdentifier.GenerateTableNameSuffix()
34+
require.NotEqual(t, suffix, differentSuffix)
35+
}

br/pkg/checkpoint/storage.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ func selectCheckpointChecksum(
249249
) (map[int64]*ChecksumItem, time.Duration, error) {
250250
var pastDureTime time.Duration = 0
251251
checkpointChecksum := make(map[int64]*ChecksumItem)
252-
checkpointChecksums, err := mergeSelectCheckpoint(ctx, execCtx, dbName, GetCheckpointTableName(checkpointChecksumTableNamePrefix, tableSuffix))
252+
checkpointChecksums, err := mergeSelectCheckpoint(ctx, execCtx, dbName,
253+
GetCheckpointTableName(checkpointChecksumTableNamePrefix, tableSuffix))
253254
if err != nil {
254255
return checkpointChecksum, pastDureTime, errors.Trace(err)
255256
}

0 commit comments

Comments
 (0)