forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfast_forward_test.go
72 lines (67 loc) · 1.59 KB
/
fast_forward_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
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2016 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
// These tests all do one conflict-free operation while a user is unstaged.
package test
import (
"fmt"
"testing"
"time"
)
// bob goes offline for a while, and alice makes a bunch of changes.
func TestFastForwardBasic(t *testing.T) {
var busyWork []fileOp
iters := 100
for i := 0; i < iters; i++ {
name := fmt.Sprintf("a%d", i)
busyWork = append(busyWork, mkfile(name, "hello"), rm(name))
}
test(t,
users("alice", "bob"),
as(alice,
mkfile("a/b", "hello"),
),
as(bob,
read("a/b", "hello"),
disableUpdates(),
stallOnMDGetForTLF(),
),
as(alice, busyWork...),
as(alice,
write("a/b", "hello world"),
),
parallel(
as(bob, noSync(),
addTime(1*time.Hour),
reenableUpdatesNoSync(),
),
as(bob, noSync(),
// Wait for the background update to fetch the head.
waitForStalledMDGetForTLF(),
unstallOneMDGetForTLF(),
),
),
as(bob, noSync(),
// Disable updates as a hack to make sure we wait for
// the fast forward to complete (the unpause channel
// isn't buffered).
disableUpdates(),
undoStallOnMDGetForTLF(),
reenableUpdatesNoSync(),
// Make sure the next sync only calls GetRange once.
stallOnMDGetRange(),
),
parallel(
as(bob, noSync(),
waitForStalledMDGetRange(),
unstallOneMDGetRange(),
),
as(bob,
read("a/b", "hello world"),
// The sync in complete, so we know GetRange was only
// called once.
undoStallOnMDGetRange(),
),
),
)
}