From 40d44c676d214c9ea2e3c5c3e9ac15b0b911d68e Mon Sep 17 00:00:00 2001 From: Michael Perel Date: Tue, 21 Jul 2020 03:40:17 +0000 Subject: [PATCH] added options tests --- runner/options_test.go | 14 ++++++++++++++ testdata/config.json | 1 + testdata/config.toml | 1 + 3 files changed, 16 insertions(+) diff --git a/runner/options_test.go b/runner/options_test.go index 5ecd6028..c74fc214 100644 --- a/runner/options_test.go +++ b/runner/options_test.go @@ -47,6 +47,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, false, c.binary) assert.Equal(t, time.Duration(0), c.z) assert.Equal(t, time.Duration(0), c.keepaliveTime) @@ -70,6 +71,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { WithTotalRequests(100), WithConcurrency(20), WithQPS(5), + WithSkipFirst(5), WithRunDuration(time.Duration(5*time.Minute)), WithKeepalive(time.Duration(60*time.Second)), WithTimeout(time.Duration(10*time.Second)), @@ -89,6 +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, false, c.binary) assert.Equal(t, time.Duration(5*time.Minute), c.z) assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime) @@ -114,6 +117,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { WithTotalRequests(100), WithConcurrency(20), WithQPS(5), + WithSkipFirst(5), WithRunDuration(time.Duration(5*time.Minute)), WithKeepalive(time.Duration(60*time.Second)), WithTimeout(time.Duration(10*time.Second)), @@ -137,6 +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, true, c.binary) assert.Equal(t, time.Duration(5*time.Minute), c.z) assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime) @@ -183,6 +188,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { WithTotalRequests(100), WithConcurrency(20), WithQPS(5), + WithSkipFirst(5), WithRunDuration(time.Duration(5*time.Minute)), WithKeepalive(time.Duration(60*time.Second)), WithTimeout(time.Duration(10*time.Second)), @@ -205,6 +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, false, c.binary) assert.Equal(t, time.Duration(5*time.Minute), c.z) assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime) @@ -237,6 +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, time.Duration(0), c.z) assert.Equal(t, time.Duration(0), c.keepaliveTime) assert.Equal(t, time.Duration(20*time.Second), c.timeout) @@ -266,6 +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, false, c.binary) assert.Equal(t, time.Duration(0), c.z) assert.Equal(t, time.Duration(0), c.keepaliveTime) @@ -300,6 +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, 1, c.nConns) assert.Equal(t, false, c.binary) assert.Equal(t, time.Duration(0), c.z) @@ -336,6 +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, 5, c.nConns) assert.Equal(t, false, c.binary) assert.Equal(t, time.Duration(0), c.z) @@ -381,6 +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, 12*time.Second, c.z) assert.Equal(t, 500*time.Millisecond, c.streamInterval) assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data) @@ -399,6 +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, 12*time.Second, c.z) assert.Equal(t, 500*time.Millisecond, c.streamInterval) assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data) @@ -417,6 +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, 12*time.Second, c.z) assert.Equal(t, 500*time.Millisecond, c.streamInterval) assert.Equal(t, []byte(`{"name":"Bob {{.TimestampUnix}}"}`), c.data) diff --git a/testdata/config.json b/testdata/config.json index ccb166c9..00d6e79b 100644 --- a/testdata/config.json +++ b/testdata/config.json @@ -1,6 +1,7 @@ { "total": 5000, "concurrency": 50, + "skipFirst": 5, "max-duration": "7s", "duration": "12s", "stream-interval": "500ms", diff --git a/testdata/config.toml b/testdata/config.toml index 6d8a04be..f0e2580d 100644 --- a/testdata/config.toml +++ b/testdata/config.toml @@ -1,6 +1,7 @@ "max-duration" = "7s" total = 5000 concurrency = 50 +skipFirst = 5 proto = "../../testdata/greeter.proto" call = "helloworld.Greeter.SayHello" host = "0.0.0.0:50051"