MCPcopy
hub / github.com/syncthing/syncthing / TestSyncCluster

Function TestSyncCluster

test/sync_test.go:29–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestSyncCluster(t *testing.T) {
30 // This tests syncing files back and forth between three cluster members.
31 // Their configs are in h1, h2 and h3. The folder "default" is shared
32 // between all and stored in s1, s2 and s3 respectively.
33 //
34 // Another folder is shared between 1 and 2 only, in s12-1 and s12-2. A
35 // third folders is shared between 2 and 3, in s23-2 and s23-3.
36
37 // When -short is passed, keep it more reasonable.
38 timeLimit := longTimeLimit
39 if testing.Short() {
40 timeLimit = shortTimeLimit
41 }
42
43 const (
44 numFiles = 100
45 fileSizeExp = 20
46 )
47 rand.Seed(42)
48
49 log.Printf("Testing with numFiles=%d, fileSizeExp=%d, timeLimit=%v", numFiles, fileSizeExp, timeLimit)
50
51 log.Println("Cleaning...")
52 err := removeAll("s1", "s12-1",
53 "s2", "s12-2", "s23-2",
54 "s3", "s23-3",
55 "h1/index*", "h2/index*", "h3/index*")
56 if err != nil {
57 t.Fatal(err)
58 }
59
60 // Create initial folder contents. All three devices have stuff in
61 // "default", which should be merged. The other two folders are initially
62 // empty on one side.
63
64 log.Println("Generating files...")
65
66 err = generateFiles("s1", numFiles, fileSizeExp, "../LICENSE")
67 if err != nil {
68 t.Fatal(err)
69 }
70 err = generateFiles("s12-1", numFiles, fileSizeExp, "../LICENSE")
71 if err != nil {
72 t.Fatal(err)
73 }
74
75 // We'll use this file for appending data without modifying the time stamp.
76 fd, err := os.Create("s1/test-appendfile")
77 if err != nil {
78 t.Fatal(err)
79 }
80 _, err = fd.WriteString("hello\n")
81 if err != nil {
82 t.Fatal(err)
83 }
84 err = fd.Close()
85 if err != nil {
86 t.Fatal(err)

Callers

nothing calls this directly

Calls 15

removeAllFunction · 0.85
directoryContentsFunction · 0.85
mergeDirectoryContentsFunction · 0.85
startInstanceFunction · 0.85
checkedStopFunction · 0.85
scSyncAndCompareFunction · 0.85
alterFilesFunction · 0.85
ShortMethod · 0.80
SeedMethod · 0.80
FatalMethod · 0.80
ResumeAllMethod · 0.80
RescanDelayMethod · 0.80

Tested by

no test coverage detected