MCPcopy
hub / github.com/dgraph-io/dgraph / TestCheckBackupReadTsAdvanced

Function TestCheckBackupReadTsAdvanced

worker/backup_test.go:14–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestCheckBackupReadTsAdvanced(t *testing.T) {
15 tests := []struct {
16 name string
17 latestManifest *Manifest
18 readTs uint64
19 wantErr bool
20 }{
21 {
22 // First backup ever: no prior manifest exists, any ReadTs is fine.
23 name: "no prior manifest",
24 latestManifest: &Manifest{},
25 readTs: 100,
26 wantErr: false,
27 },
28 {
29 name: "normal incremental advances chain",
30 latestManifest: &Manifest{
31 ManifestBase: ManifestBase{Type: "full", ReadTs: 100},
32 },
33 readTs: 200,
34 wantErr: false,
35 },
36 {
37 // Repro of the customer's chain corruption: chain reached read_ts
38 // 32M, then Zero state was lost; new ReadTs is far below.
39 name: "regressed ReadTs (Zero state reset)",
40 latestManifest: &Manifest{
41 ManifestBase: ManifestBase{Type: "incremental", ReadTs: 32000000},
42 },
43 readTs: 147784,
44 wantErr: true,
45 },
46 {
47 // Equal ReadTs means the incremental would capture nothing AND
48 // indicates ordering ambiguity — treat as regression.
49 name: "equal ReadTs",
50 latestManifest: &Manifest{
51 ManifestBase: ManifestBase{Type: "full", ReadTs: 1000},
52 },
53 readTs: 1000,
54 wantErr: true,
55 },
56 {
57 // Pre-21.03 manifests store the timestamp in SinceTsDeprecated
58 // rather than ReadTs; ValidReadTs() falls back to that. Make
59 // sure regression detection still triggers.
60 name: "regression detected via deprecated since field",
61 latestManifest: &Manifest{
62 ManifestBase: ManifestBase{Type: "incremental", SinceTsDeprecated: 500},
63 },
64 readTs: 400,
65 wantErr: true,
66 },
67 {
68 // Same as above but ReadTs DOES advance — must not trigger.
69 name: "advance detected via deprecated since field",
70 latestManifest: &Manifest{
71 ManifestBase: ManifestBase{Type: "incremental", SinceTsDeprecated: 500},

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected