forked from yihuang/grocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
options_backup_test.go
59 lines (44 loc) · 1.79 KB
/
options_backup_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package grocksdb
import (
"math"
"testing"
"github.com/stretchr/testify/require"
)
func TestBackupableDBOptions(t *testing.T) {
opts := NewBackupableDBOptions("/tmp/v1")
defer opts.Destroy()
env := NewDefaultEnv()
defer env.Destroy()
opts.SetEnv(env)
opts.SetBackupDir("/tmp/v2")
require.True(t, opts.IsShareTableFiles()) // check default value
opts.ShareTableFiles(false)
require.False(t, opts.IsShareTableFiles())
require.True(t, opts.IsSync())
opts.SetSync(false)
require.False(t, opts.IsSync())
require.False(t, opts.IsDestroyOldData())
opts.DestroyOldData(true)
require.True(t, opts.IsDestroyOldData())
require.True(t, opts.IsBackupLogFiles())
opts.BackupLogFiles(false)
require.False(t, opts.IsBackupLogFiles())
require.EqualValues(t, 0, opts.GetBackupRateLimit())
opts.SetBackupRateLimit(531 << 10)
require.EqualValues(t, 531<<10, opts.GetBackupRateLimit())
require.EqualValues(t, 0, opts.GetRestoreRateLimit())
opts.SetRestoreRateLimit(53 << 10)
require.EqualValues(t, 53<<10, opts.GetRestoreRateLimit())
require.EqualValues(t, 1, opts.GetMaxBackgroundOperations())
opts.SetMaxBackgroundOperations(3)
require.EqualValues(t, 3, opts.GetMaxBackgroundOperations())
require.EqualValues(t, 4194304, opts.GetCallbackTriggerIntervalSize())
opts.SetCallbackTriggerIntervalSize(800 << 10)
require.EqualValues(t, 800<<10, opts.GetCallbackTriggerIntervalSize())
require.EqualValues(t, math.MaxInt32, opts.GetMaxValidBackupsToOpen())
opts.SetMaxValidBackupsToOpen(29)
require.EqualValues(t, 29, opts.GetMaxValidBackupsToOpen())
require.EqualValues(t, 0x80000002, opts.GetShareFilesWithChecksumNaming())
opts.SetShareFilesWithChecksumNaming(UseDBSessionID | LegacyCrc32cAndFileSize)
require.EqualValues(t, UseDBSessionID|LegacyCrc32cAndFileSize, opts.GetShareFilesWithChecksumNaming())
}