2014-11-16 20:13:20 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
2014-10-21 05:37:38 +00:00
|
|
|
//
|
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-10-21 05:37:38 +00:00
|
|
|
|
2021-08-17 08:10:41 +00:00
|
|
|
//go:build integration
|
2014-10-21 05:37:38 +00:00
|
|
|
// +build integration
|
|
|
|
|
2014-12-17 11:31:03 +00:00
|
|
|
package integration
|
2014-10-21 05:37:38 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
|
|
|
"log"
|
2017-11-05 09:05:18 +00:00
|
|
|
"os"
|
2014-10-21 05:37:38 +00:00
|
|
|
"testing"
|
|
|
|
|
2015-08-06 09:29:25 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/config"
|
2015-09-22 17:38:46 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/protocol"
|
2015-08-06 09:29:25 +00:00
|
|
|
"github.com/syncthing/syncthing/lib/rc"
|
2014-10-21 05:37:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestManyPeers(t *testing.T) {
|
|
|
|
log.Println("Cleaning...")
|
2015-03-29 10:55:27 +00:00
|
|
|
err := removeAll("s1", "s2", "h1/index*", "h2/index*")
|
2014-10-21 05:37:38 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Generating files...")
|
2014-11-29 22:41:06 +00:00
|
|
|
err = generateFiles("s1", 200, 20, "../LICENSE")
|
2014-10-21 05:37:38 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
receiver := startInstance(t, 2)
|
|
|
|
defer checkedStop(t, receiver)
|
2017-11-12 23:54:21 +00:00
|
|
|
receiver.ResumeAll()
|
2014-10-21 05:37:38 +00:00
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
bs, err := receiver.Get("/rest/system/config")
|
2014-10-21 05:37:38 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var cfg config.Configuration
|
2015-06-18 13:22:45 +00:00
|
|
|
if err := json.Unmarshal(bs, &cfg); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2014-10-21 05:37:38 +00:00
|
|
|
|
|
|
|
for len(cfg.Devices) < 100 {
|
|
|
|
bs := make([]byte, 16)
|
|
|
|
ReadRand(bs)
|
|
|
|
id := protocol.NewDeviceID(bs)
|
|
|
|
cfg.Devices = append(cfg.Devices, config.DeviceConfiguration{DeviceID: id})
|
|
|
|
cfg.Folders[0].Devices = append(cfg.Folders[0].Devices, config.FolderDeviceConfiguration{DeviceID: id})
|
|
|
|
}
|
|
|
|
|
2017-11-05 09:05:18 +00:00
|
|
|
os.Rename("h2/config.xml", "h2/config.xml.orig")
|
|
|
|
defer os.Rename("h2/config.xml.orig", "h2/config.xml")
|
2014-10-21 05:37:38 +00:00
|
|
|
|
|
|
|
var buf bytes.Buffer
|
|
|
|
json.NewEncoder(&buf).Encode(cfg)
|
2015-06-18 13:22:45 +00:00
|
|
|
_, err = receiver.Post("/rest/system/config", &buf)
|
2014-10-21 05:37:38 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
sender := startInstance(t, 1)
|
|
|
|
defer checkedStop(t, sender)
|
2017-11-12 23:54:21 +00:00
|
|
|
sender.ResumeAll()
|
2014-10-21 05:37:38 +00:00
|
|
|
|
2015-06-18 13:22:45 +00:00
|
|
|
rc.AwaitSync("default", sender, receiver)
|
2014-10-21 05:37:38 +00:00
|
|
|
|
|
|
|
log.Println("Comparing directories...")
|
|
|
|
err = compareDirectories("s1", "s2")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|