github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/test/fast_forward_test.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 // These tests all do one conflict-free operation while a user is unstaged. 6 7 package test 8 9 import ( 10 "fmt" 11 "testing" 12 "time" 13 ) 14 15 // bob goes offline for a while, and alice makes a bunch of changes. 16 func TestFastForwardBasic(t *testing.T) { 17 var busyWork []fileOp 18 iters := 100 19 for i := 0; i < iters; i++ { 20 name := fmt.Sprintf("a%d", i) 21 busyWork = append(busyWork, mkfile(name, "hello"), rm(name)) 22 } 23 24 test(t, 25 users("alice", "bob"), 26 as(alice, 27 mkfile("a/b", "hello"), 28 ), 29 as(bob, 30 read("a/b", "hello"), 31 disableUpdates(), 32 stallOnMDGetForTLF(), 33 ), 34 as(alice, busyWork...), 35 as(alice, 36 write("a/b", "hello world"), 37 ), 38 parallel( 39 as(bob, noSync(), 40 addTime(1*time.Hour), 41 reenableUpdatesNoSync(), 42 ), 43 as(bob, noSync(), 44 // Wait for the background update to fetch the head. 45 waitForStalledMDGetForTLF(), 46 unstallOneMDGetForTLF(), 47 ), 48 ), 49 as(bob, noSync(), 50 // Disable updates as a hack to make sure we wait for 51 // the fast forward to complete (the unpause channel 52 // isn't buffered). 53 disableUpdates(), 54 undoStallOnMDGetForTLF(), 55 reenableUpdatesNoSync(), 56 // Make sure the next sync only calls GetRange once. 57 stallOnMDGetRange(), 58 ), 59 parallel( 60 as(bob, noSync(), 61 waitForStalledMDGetRange(), 62 unstallOneMDGetRange(), 63 ), 64 as(bob, 65 read("a/b", "hello world"), 66 // The sync in complete, so we know GetRange was only 67 // called once. 68 undoStallOnMDGetRange(), 69 ), 70 ), 71 ) 72 }