From aa09aab953a594b1f43da779ec9e606c3667857a Mon Sep 17 00:00:00 2001 From: Michael Perel Date: Mon, 20 Jul 2020 19:14:34 +0000 Subject: [PATCH] added test for skipping first N --- runner/run_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/runner/run_test.go b/runner/run_test.go index 4c7aaf7d..0c501fa2 100644 --- a/runner/run_test.go +++ b/runner/run_test.go @@ -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()