No need for more than one client with internal concurrency

This commit is contained in:
Tomás Senart
2013-08-14 21:03:03 +02:00
parent 06a27404fa
commit 0d22f32683
2 changed files with 11 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"net/http"
"net/http/httptest"
"os"
"sync/atomic"
"testing"
"time"
@@ -20,8 +21,11 @@ func TestAttackRate(t *testing.T) {
if err != nil {
t.Fatal(err)
}
attack(targets, "random", 50, 1*time.Second, NewTextReporter())
if hits := atomic.LoadUint64(&hitCount); hits != 50 {
t.Fatalf("Wrong number of hits: want %d, got %d\n", 50, hits)
rate := uint(5000)
rep := NewTextReporter()
attack(targets, "random", rate, 1*time.Second, rep)
if hits := atomic.LoadUint64(&hitCount); uint(hits) != rate {
rep.Report(os.Stdout)
t.Fatalf("Wrong number of hits: want %d, got %d\n", rate, hits)
}
}