2015-05-01 12:30:17 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
// +build integration
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
func TestRescanWithDelay(t *testing.T) {
|
2015-05-01 12:30:17 +00:00
|
|
|
log.Println("Cleaning...")
|
|
|
|
err := removeAll("s1", "h1/index*")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Generating files...")
|
|
|
|
err = generateFiles("s1", 50, 18, "../LICENSE")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Generating .stignore...")
|
|
|
|
err = ioutil.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0644)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Starting up...")
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
st := startInstance(t, 1)
|
2015-05-01 12:30:17 +00:00
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
log.Println("Starting scans...")
|
|
|
|
for j := 0; j < 20; j++ {
|
|
|
|
j := j
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
2015-06-18 13:22:45 +00:00
|
|
|
err := st.RescanDelay("default", 1)
|
2015-05-01 12:30:17 +00:00
|
|
|
log.Println(j)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
log.Println("Scans done")
|
|
|
|
time.Sleep(2 * time.Second)
|
|
|
|
|
|
|
|
// This is where the real test is currently, since stop() checks for data
|
|
|
|
// race output in the log.
|
|
|
|
log.Println("Stopping...")
|
2015-06-18 13:22:45 +00:00
|
|
|
checkedStop(t, st)
|
2015-05-01 12:30:17 +00:00
|
|
|
}
|