diff --git a/test/filetype_test.go b/test/filetype_test.go index 8c516f855..fe6988332 100644 --- a/test/filetype_test.go +++ b/test/filetype_test.go @@ -107,6 +107,9 @@ func testFileTypeChange(t *testing.T) { receiver := startInstance(t, 2) defer checkedStop(t, receiver) + sender.ResumeAll() + receiver.ResumeAll() + log.Println("Syncing...") rc.AwaitSync("default", sender, receiver) diff --git a/test/http_test.go b/test/http_test.go index e34114d7c..53d1124a7 100644 --- a/test/http_test.go +++ b/test/http_test.go @@ -10,7 +10,6 @@ package integration import ( "bytes" - "encoding/json" "io/ioutil" "net/http" "strings" @@ -20,31 +19,7 @@ import ( "github.com/syncthing/syncthing/lib/rc" ) -var jsonEndpoints = []string{ - "/rest/db/completion?device=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU&folder=default", - "/rest/db/ignores?folder=default", - "/rest/db/need?folder=default", - "/rest/db/status?folder=default", - "/rest/db/browse?folder=default", - "/rest/events?since=-1&limit=5", - "/rest/events/disk?since=-1&limit=5", - "/rest/stats/device", - "/rest/stats/folder", - "/rest/svc/deviceid?id=I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU", - "/rest/svc/lang", - "/rest/svc/report", - "/rest/system/browse?current=.", - "/rest/system/config", - "/rest/system/config/insync", - "/rest/system/connections", - "/rest/system/discovery", - "/rest/system/error", - "/rest/system/ping", - "/rest/system/status", - "/rest/system/version", -} - -func TestGetIndex(t *testing.T) { +func TestHTTPGetIndex(t *testing.T) { p := startInstance(t, 2) defer checkedStop(t, p) @@ -97,7 +72,7 @@ func TestGetIndex(t *testing.T) { res.Body.Close() } -func TestGetIndexAuth(t *testing.T) { +func TestHTTPGetIndexAuth(t *testing.T) { p := startInstance(t, 1) defer checkedStop(t, p) @@ -147,33 +122,7 @@ func TestGetIndexAuth(t *testing.T) { } } -func TestGetJSON(t *testing.T) { - p := startInstance(t, 2) - defer checkedStop(t, p) - - for _, path := range jsonEndpoints { - res, err := http.Get("http://127.0.0.1:8082" + path) - if err != nil { - t.Error(path, err) - continue - } - - if ct := res.Header.Get("Content-Type"); ct != "application/json; charset=utf-8" { - t.Errorf("Incorrect Content-Type %q for %q", ct, path) - continue - } - - var intf interface{} - err = json.NewDecoder(res.Body).Decode(&intf) - res.Body.Close() - - if err != nil { - t.Error(path, err) - } - } -} - -func TestOptions(t *testing.T) { +func TestHTTPOptions(t *testing.T) { p := startInstance(t, 2) defer checkedStop(t, p) @@ -191,7 +140,7 @@ func TestOptions(t *testing.T) { } } -func TestPOSTWithoutCSRF(t *testing.T) { +func TestHTTPPOSTWithoutCSRF(t *testing.T) { p := startInstance(t, 2) defer checkedStop(t, p) diff --git a/test/httpstress_test.go b/test/httpstress_test.go deleted file mode 100644 index dd3904937..000000000 --- a/test/httpstress_test.go +++ /dev/null @@ -1,143 +0,0 @@ -// 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 https://mozilla.org/MPL/2.0/. - -// +build integration - -package integration - -import ( - "bytes" - "crypto/tls" - "errors" - "io/ioutil" - "log" - "net" - "net/http" - "sync" - "testing" - "time" -) - -func TestStressHTTP(t *testing.T) { - log.Println("Cleaning...") - err := removeAll("s2", "h2/index*") - if err != nil { - t.Fatal(err) - } - - log.Println("Starting up...") - - p := startInstance(t, 2) - defer checkedStop(t, p) - - // Create a client with reasonable timeouts on all stages of the request. - - tc := &tls.Config{InsecureSkipVerify: true} - tr := &http.Transport{ - TLSClientConfig: tc, - DisableKeepAlives: true, - ResponseHeaderTimeout: 10 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - } - client := &http.Client{ - Transport: tr, - Timeout: 10 * time.Second, - } - - var ( - requestsOK = map[string]int{} - requestsError = map[string]int{} - firstError error - lock sync.Mutex - ) - - gotError := func(ctx string, err error) { - lock.Lock() - requestsError[ctx]++ - if firstError == nil { - firstError = err - } - lock.Unlock() - } - - requestOK := func(ctx string) { - lock.Lock() - requestsOK[ctx]++ - lock.Unlock() - } - - log.Println("Testing...") - - var wg sync.WaitGroup - t0 := time.Now() - - // One thread with immediately closed connections - wg.Add(1) - go func() { - defer wg.Done() - for time.Since(t0).Seconds() < 30 { - conn, err := net.Dial("tcp", "localhost:8082") - if err != nil { - gotError("Dial", err) - } else { - requestOK("Dial") - conn.Close() - } - - // At most 100 connects/sec - time.Sleep(10 * time.Millisecond) - } - }() - - // 50 threads doing mixed HTTP and HTTPS requests - for i := 0; i < 50; i++ { - i := i - wg.Add(1) - go func() { - defer wg.Done() - for time.Since(t0).Seconds() < 30 { - proto := "http" - if i%2 == 0 { - proto = "https" - } - url := proto + "://localhost:8082/" - resp, err := client.Get(url) - - if err != nil { - gotError("Get "+proto, err) - continue - } - - bs, err := ioutil.ReadAll(resp.Body) - resp.Body.Close() - - if err != nil { - gotError("Read "+proto, err) - continue - } - - if !bytes.Contains(bs, []byte("")) { - err := errors.New("Incorrect response") - gotError("Get "+proto, err) - continue - } - - requestOK(url) - - // At most 100 requests/sec - time.Sleep(10 * time.Millisecond) - } - }() - } - - wg.Wait() - t.Logf("OK: %v reqs", requestsOK) - t.Logf("Err: %v reqs", requestsError) - - if firstError != nil { - t.Error(firstError) - } -}