2014-12-02 21:13:08 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
|
|
|
//
|
2015-03-07 20:36:35 +00:00
|
|
|
// 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,
|
2017-02-09 06:52:18 +00:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2014-12-02 21:13:08 +00:00
|
|
|
|
2021-08-17 08:10:41 +00:00
|
|
|
//go:build integration
|
2014-12-02 21:13:08 +00:00
|
|
|
// +build integration
|
|
|
|
|
2014-12-17 11:31:03 +00:00
|
|
|
package integration
|
2014-12-02 21:13:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2021-11-22 07:59:47 +00:00
|
|
|
"os"
|
2014-12-02 21:13:08 +00:00
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
func TestRescanInParallel(t *testing.T) {
|
2014-12-02 21:13:08 +00:00
|
|
|
log.Println("Cleaning...")
|
2015-03-29 10:55:27 +00:00
|
|
|
err := removeAll("s1", "h1/index*")
|
2014-12-02 21:13:08 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Generating files...")
|
|
|
|
err = generateFiles("s1", 5000, 18, "../LICENSE")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:14:19 +00:00
|
|
|
log.Println("Generating .stignore...")
|
2024-11-19 10:32:56 +00:00
|
|
|
err = os.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0o644)
|
2014-12-02 21:13:08 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
st := startInstance(t, 1)
|
|
|
|
defer checkedStop(t, st)
|
2014-12-02 21:13:08 +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.Rescan("default")
|
2014-12-02 21:13:08 +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)
|
2014-12-02 21:13:08 +00:00
|
|
|
}
|