Add test for syncing with 100 configured devices

This commit is contained in:
Jakob Borg
2014-10-21 07:37:38 +02:00
parent e2dc3e9ff3
commit 1e915a2903
2 changed files with 152 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ const (
var env = []string{
"HOME=.",
"STTRACE=model",
"STTRACE=model,protocol",
"STGUIAPIKEY=" + apiKey,
"STNORESTART=1",
"STPERFSTATS=1",
@@ -121,6 +121,32 @@ func (p *syncthingProcess) get(path string) (*http.Response, error) {
return resp, nil
}
func (p *syncthingProcess) post(path string, data io.Reader) (*http.Response, error) {
client := &http.Client{
Timeout: 2 * time.Second,
Transport: &http.Transport{
DisableKeepAlives: true,
},
}
req, err := http.NewRequest("POST", fmt.Sprintf("http://127.0.0.1:%d%s", p.port, path), data)
if err != nil {
return nil, err
}
if p.apiKey != "" {
req.Header.Add("X-API-Key", p.apiKey)
}
if p.csrfToken != "" {
req.Header.Add("X-CSRF-Token", p.csrfToken)
}
req.Header.Add("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
return nil, err
}
return resp, nil
}
func (p *syncthingProcess) peerCompletion() (map[string]int, error) {
resp, err := p.get("/rest/debug/peerCompletion")
if err != nil {