Skip to content

Commit

Permalink
updated to reflect int instead of uint
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelperel committed Jul 21, 2020
2 parents 40d44c6 + f0cb23d commit b99d0f4
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 16 deletions.
4 changes: 2 additions & 2 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type RunConfig struct {
name string
cpus int
tags []byte
skipFirst uint
skipFirst int
}

// Option controls some aspect of run
Expand Down Expand Up @@ -455,7 +455,7 @@ func WithCPUs(c uint) Option {
func WithSkipFirst(c uint) Option {
return func(o *RunConfig) error {
if c > 0 {
o.skipFirst = uint(c)
o.skipFirst = int(c)
}

return nil
Expand Down
22 changes: 11 additions & 11 deletions runner/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 200, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, 0, c.qps)
assert.Equal(t, uint(0), c.skipFirst)
assert.Equal(t, false, c.binary)
assert.Equal(t, 0, c.skipFirst)
assert.Equal(t, time.Duration(0), c.z)
assert.Equal(t, time.Duration(0), c.keepaliveTime)
assert.Equal(t, time.Duration(20*time.Second), c.timeout)
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 100, c.n)
assert.Equal(t, 20, c.c)
assert.Equal(t, 5, c.qps)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, false, c.binary)
assert.Equal(t, time.Duration(5*time.Minute), c.z)
assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime)
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 100, c.n)
assert.Equal(t, 20, c.c)
assert.Equal(t, 5, c.qps)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, true, c.binary)
assert.Equal(t, time.Duration(5*time.Minute), c.z)
assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime)
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 100, c.n)
assert.Equal(t, 20, c.c)
assert.Equal(t, 5, c.qps)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, false, c.binary)
assert.Equal(t, time.Duration(5*time.Minute), c.z)
assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime)
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 200, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, 0, c.qps)
assert.Equal(t, uint(0), c.skipFirst)
assert.Equal(t, 0, c.skipFirst)
assert.Equal(t, time.Duration(0), c.z)
assert.Equal(t, time.Duration(0), c.keepaliveTime)
assert.Equal(t, time.Duration(20*time.Second), c.timeout)
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 200, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, 0, c.qps)
assert.Equal(t, uint(0), c.skipFirst)
assert.Equal(t, 0, c.skipFirst)
assert.Equal(t, false, c.binary)
assert.Equal(t, time.Duration(0), c.z)
assert.Equal(t, time.Duration(0), c.keepaliveTime)
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 200, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, 0, c.qps)
assert.Equal(t, uint(0), c.skipFirst)
assert.Equal(t, 0, c.skipFirst)
assert.Equal(t, 1, c.nConns)
assert.Equal(t, false, c.binary)
assert.Equal(t, time.Duration(0), c.z)
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, 200, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, 0, c.qps)
assert.Equal(t, uint(0), c.skipFirst)
assert.Equal(t, 0, c.skipFirst)
assert.Equal(t, 5, c.nConns)
assert.Equal(t, false, c.binary)
assert.Equal(t, time.Duration(0), c.z)
Expand Down Expand Up @@ -392,7 +392,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, []string{"../../testdata", "."}, c.importPaths)
assert.Equal(t, 5000, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, 12*time.Second, c.z)
assert.Equal(t, 500*time.Millisecond, c.streamInterval)
assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data)
Expand All @@ -411,7 +411,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, []string{"../../testdata", "."}, c.importPaths)
assert.Equal(t, 5000, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, 12*time.Second, c.z)
assert.Equal(t, 500*time.Millisecond, c.streamInterval)
assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data)
Expand All @@ -430,7 +430,7 @@ func TestRunConfig_newRunConfig(t *testing.T) {
assert.Equal(t, []string{"../../testdata", "."}, c.importPaths)
assert.Equal(t, 5000, c.n)
assert.Equal(t, 50, c.c)
assert.Equal(t, uint(5), c.skipFirst)
assert.Equal(t, 5, c.skipFirst)
assert.Equal(t, 12*time.Second, c.z)
assert.Equal(t, 500*time.Millisecond, c.streamInterval)
assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data)
Expand Down
4 changes: 2 additions & 2 deletions runner/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func newReporter(results chan *callResult, c *RunConfig) *Reporter {

// Run runs the reporter
func (r *Reporter) Run() {
var skipCount uint
var skipCount int

for res := range r.results {
if skipCount < r.config.skipFirst {
Expand Down Expand Up @@ -185,7 +185,7 @@ func (r *Reporter) Finalize(stopReason StopReason, total time.Duration) *Report
Key: r.config.key,
CName: r.config.cname,
SkipTLS: r.config.skipVerify,
SkipFirst: r.config.skipFirst,
SkipFirst: uint(r.config.skipFirst),
Insecure: r.config.insecure,
Authority: r.config.authority,
Total: uint(r.config.n),
Expand Down
45 changes: 45 additions & 0 deletions runner/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,51 @@ func TestRunUnary(t *testing.T) {
assert.Equal(t, 1, count)
})

t.Run("test skip first N", func(t *testing.T) {
gs.ResetCounters()

data := make(map[string]interface{})
data["name"] = "bob"

report, err := Run(
"helloworld.Greeter.SayHello",
internal.TestLocalhost,
WithProtoFile("../testdata/greeter.proto", []string{}),
WithTotalRequests(10),
WithConcurrency(1),
WithTimeout(time.Duration(20*time.Second)),
WithDialTimeout(time.Duration(20*time.Second)),
WithData(data),
WithSkipFirst(5),
WithInsecure(true),
)

assert.NoError(t, err)

assert.NotNil(t, report)

assert.Equal(t, 5, int(report.Count))
assert.NotZero(t, report.Average)
assert.NotZero(t, report.Fastest)
assert.NotZero(t, report.Slowest)
assert.NotZero(t, report.Rps)
assert.Empty(t, report.Name)
assert.NotEmpty(t, report.Date)
assert.NotEmpty(t, report.Options)
assert.NotEmpty(t, report.Details)
assert.Equal(t, true, report.Options.Insecure)
assert.NotEmpty(t, report.LatencyDistribution)
assert.Equal(t, ReasonNormalEnd, report.EndReason)
assert.Empty(t, report.ErrorDist)

assert.NotEqual(t, report.Average, report.Slowest)
assert.NotEqual(t, report.Average, report.Fastest)
assert.NotEqual(t, report.Slowest, report.Fastest)

count := gs.GetCount(callType)
assert.Equal(t, 10, count)
})

t.Run("test N and Name", func(t *testing.T) {
gs.ResetCounters()

Expand Down
6 changes: 5 additions & 1 deletion www/docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,8 @@ Show context-sensitive help (also try --help-long and --help-man).

### `-e`, `--enable-compression`

Enable gzip compression on requests.
Enable gzip compression on requests.

### '--skipFirst'

Skip the first n responses from the report. Helps remove initial warm-up requests from skewing the results.
1 change: 1 addition & 0 deletions www/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Flags:
--name= User specified name for the test.
--tags= JSON representation of user-defined string tags.
--cpus=12 Number of cpu cores to use.
--skipFirst=0 Skip the first n responses from the report. Helps remove initial warm-up requests from skewing the results.
--debug= The path to debug log file.
-e, --enable-compression Enable Gzip compression on requests.
-v, --version Show application version.
Expand Down

0 comments on commit b99d0f4

Please sign in to comment.