Report usage statistics after transfer bench

This commit is contained in:
Jakob Borg 2015-04-30 08:43:57 +02:00
parent 9638dcda0a
commit c9da8237df
8 changed files with 51 additions and 41 deletions

View File

@ -122,7 +122,7 @@ func testFileTypeChange(t *testing.T) {
}
err = receiver.start()
if err != nil {
_ = sender.stop()
sender.stop()
t.Fatal(err)
}
@ -133,27 +133,27 @@ func testFileTypeChange(t *testing.T) {
time.Sleep(time.Second)
continue
}
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
t.Fatal(err)
}
curComp := comp[id2]
if curComp == 100 {
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
break
}
time.Sleep(time.Second)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}
@ -212,7 +212,7 @@ func testFileTypeChange(t *testing.T) {
err = receiver.start()
if err != nil {
_ = sender.stop()
sender.stop()
t.Fatal(err)
}
@ -223,8 +223,8 @@ func testFileTypeChange(t *testing.T) {
time.Sleep(time.Second)
continue
}
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
t.Fatal(err)
}
@ -237,11 +237,11 @@ func testFileTypeChange(t *testing.T) {
time.Sleep(time.Second)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}

View File

@ -148,7 +148,7 @@ func TestStressHTTP(t *testing.T) {
t.Error(firstError)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Error(err)
}

View File

@ -84,7 +84,7 @@ func TestParallellScan(t *testing.T) {
// This is where the real test is currently, since stop() checks for data
// race output in the log.
log.Println("Stopping...")
err = st.stop()
_, err = st.stop()
if err != nil {
t.Fatal(err)
}

View File

@ -63,7 +63,7 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
}
err = receiver.start()
if err != nil {
_ = sender.stop()
sender.stop()
t.Fatal(err)
}
@ -75,19 +75,19 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
time.Sleep(250 * time.Millisecond)
continue
}
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
t.Fatal(err)
}
curComp := comp[id2]
if curComp == 100 {
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}
@ -97,7 +97,7 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
if curComp > prevComp {
if restartReceiver {
log.Printf("Stopping receiver...")
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}
@ -105,7 +105,7 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
if restartSender {
log.Printf("Stopping sender...")
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
@ -141,11 +141,11 @@ func testRestartDuringTransfer(t *testing.T, restartSender, restartReceiver bool
time.Sleep(time.Second)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}

View File

@ -186,7 +186,7 @@ func testSymlinks(t *testing.T) {
}
err = receiver.start()
if err != nil {
_ = sender.stop()
sender.stop()
t.Fatal(err)
}
@ -197,8 +197,8 @@ func testSymlinks(t *testing.T) {
time.Sleep(time.Second)
continue
}
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
t.Fatal(err)
}
@ -211,11 +211,11 @@ func testSymlinks(t *testing.T) {
time.Sleep(time.Second)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}
@ -311,7 +311,7 @@ func testSymlinks(t *testing.T) {
err = receiver.start()
if err != nil {
_ = sender.stop()
sender.stop()
t.Fatal(err)
}
@ -322,8 +322,8 @@ func testSymlinks(t *testing.T) {
time.Sleep(time.Second)
continue
}
_ = sender.stop()
_ = receiver.stop()
sender.stop()
receiver.stop()
t.Fatal(err)
}
@ -336,11 +336,11 @@ func testSymlinks(t *testing.T) {
time.Sleep(time.Second)
}
err = sender.stop()
_, err = sender.stop()
if err != nil {
t.Fatal(err)
}
err = receiver.stop()
_, err = receiver.stop()
if err != nil {
t.Fatal(err)
}

View File

@ -287,7 +287,7 @@ func scStartProcesses() ([]syncthingProcess, error) {
}
err = p[1].start()
if err != nil {
_ = p[0].stop()
p[0].stop()
return nil, err
}
@ -299,8 +299,8 @@ func scStartProcesses() ([]syncthingProcess, error) {
}
err = p[2].start()
if err != nil {
_ = p[0].stop()
_ = p[1].stop()
p[0].stop()
p[1].stop()
return nil, err
}

View File

@ -106,13 +106,13 @@ func (p *syncthingProcess) start() error {
}
}
func (p *syncthingProcess) stop() error {
func (p *syncthingProcess) stop() (*os.ProcessState, error) {
p.cmd.Process.Signal(os.Kill)
p.cmd.Wait()
fd, err := os.Open(p.logfd.Name())
if err != nil {
return err
return p.cmd.ProcessState, err
}
defer fd.Close()
@ -148,7 +148,7 @@ func (p *syncthingProcess) stop() error {
}
}
}
return err
return p.cmd.ProcessState, err
}
func (p *syncthingProcess) get(path string) (*http.Response, error) {

View File

@ -10,6 +10,7 @@ package integration
import (
"log"
"syscall"
"testing"
"time"
)
@ -116,7 +117,10 @@ loop:
}
sender.stop()
receiver.stop()
proc, err := receiver.stop()
if err != nil {
t.Fatal(err)
}
log.Println("Verifying...")
@ -129,5 +133,11 @@ loop:
t.Fatal(err)
}
log.Println("Sync took", t1.Sub(t0))
log.Println("Result: Wall time:", t1.Sub(t0))
if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok {
log.Println("Result: Utime:", time.Duration(rusage.Utime.Nano()))
log.Println("Result: Stime:", time.Duration(rusage.Stime.Nano()))
log.Println("Result: MaxRSS:", rusage.Maxrss/1024, "KiB")
}
}