diff --git a/README.md b/README.md index 052b96b..cc949ae 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Flags: -m, --method string request method (default "GET") --mtls-cert string mTLS cert path --mtls-key string mTLS cert private key path - --parallel Sends reqs in parallel per connection with HTTP/2 + --parallel Sends reqs in parallel per connection with HTTP/2 or HTTP/3 --read-timeout duration Read timeout (default 5s) -r, --requests int Number of requests --skip-verify Skip verify SSL cert signer diff --git a/cmd/payloader/run.go b/cmd/payloader/run.go index 812b12d..097bc99 100644 --- a/cmd/payloader/run.go +++ b/cmd/payloader/run.go @@ -109,7 +109,7 @@ func init() { runCmd.Flags().Int64VarP(&reqs, argRequests, "r", 0, "Number of requests") runCmd.Flags().UintVarP(&conns, argConnections, "c", 1, "Number of simultaneous connections") runCmd.Flags().BoolVarP(&disableKeepAlive, argKeepAlive, "k", false, "Disable keep-alive connections") - runCmd.Flags().BoolVar(¶llel, argParallel, false, "Sends reqs in parallel per connection with HTTP/2") + runCmd.Flags().BoolVar(¶llel, argParallel, false, "Sends reqs in parallel per connection with HTTP/2 or HTTP/3") runCmd.Flags().BoolVar(&skipVerify, argVerifySigner, false, "Skip verify SSL cert signer") runCmd.Flags().DurationVarP(&duration, argTime, "t", 0, "Execution time window, if used with -r will uniformly distribute reqs within time window, without -r reqs are unlimited") diff --git a/config/config.go b/config/config.go index da73b94..7a36cf3 100644 --- a/config/config.go +++ b/config/config.go @@ -14,34 +14,34 @@ import ( ) type Config struct { - Ctx context.Context - ReqURI string - DisableKeepAlive bool - ReqTarget int64 - Conns uint - Duration time.Duration - MTLSKey string - MTLSCert string - SkipVerify bool - ReadTimeout time.Duration - WriteTimeout time.Duration - Method string - Verbose bool - VerboseTicker time.Duration - JwtKID string - JwtKey string - JwtSub string - JwtCustomClaimsJSON string - JwtIss string - JwtAud string - JwtHeader string - JwtsFilename string - SendJWT bool - Headers []string - Body string - BodyFile string - Client string - Parallel bool + Ctx context.Context + ReqURI string + DisableKeepAlive bool + ReqTarget int64 + Conns uint + Duration time.Duration + MTLSKey string + MTLSCert string + SkipVerify bool + ReadTimeout time.Duration + WriteTimeout time.Duration + Method string + Verbose bool + VerboseTicker time.Duration + JwtKID string + JwtKey string + JwtSub string + JwtCustomClaimsJSON string + JwtIss string + JwtAud string + JwtHeader string + JwtsFilename string + SendJWT bool + Headers []string + Body string + BodyFile string + Client string + Parallel bool } func NewConfig(ctx context.Context, reqURI, mTLScert, mTLSKey string, disableKeepAlive bool, reqs int64, conns uint, totalTime time.Duration, skipVerify bool, readTimeout, writeTimeout time.Duration, method string, verbose bool, ticker time.Duration, jwtKID, jwtKey, jwtSub, jwtCustomClaimsJSON, jwtIss, jwtAud, jwtHeader, jwtsFilename string, headers []string, body, bodyFile string, client string, parallel bool) *Config { @@ -145,7 +145,7 @@ func (c *Config) Validate() error { } // Require JwtHeader if JwtKey or JwtsFilename is present - if (c.JwtsFilename != "" || c.JwtKey != "") && c.JwtHeader == "" { + if (c.JwtsFilename != "" || c.JwtKey != "") && c.JwtHeader == "" { return errors.New("config: empty jwt header") } @@ -200,8 +200,8 @@ func (c *Config) Validate() error { } } - if c.Parallel && c.Client != worker.HttpClientNetHTTP2 { - return fmt.Errorf("can only run parallel with %s client", worker.HttpClientNetHTTP2) + if c.Parallel && (c.Client != worker.HttpClientNetHTTP2 && c.Client != worker.HttpClientNetHTTP3) { + return fmt.Errorf("can only run parallel with %s or %s client", worker.HttpClientNetHTTP2, worker.HttpClientNetHTTP3) } if c.VerboseTicker == 0 { diff --git a/pkgs/payloader/payloader_test.go b/pkgs/payloader/payloader_test.go index fd44376..7acebd4 100644 --- a/pkgs/payloader/payloader_test.go +++ b/pkgs/payloader/payloader_test.go @@ -217,13 +217,13 @@ func testPayLoader_Run(t *testing.T, addr, client string, cleanup func()) { }}, }, { - name: "PUT 10 connections for 10 second long test with 100 requests", + name: "PUT 10 connections for 5 second long test with 100 requests", fields: fields{config: &config.Config{ Ctx: context.Background(), ReqURI: addr, Conns: 10, ReqTarget: 100, - Duration: 10 * time.Second, + Duration: 5 * time.Second, ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second, Method: "PUT", @@ -432,7 +432,7 @@ func testPayLoader_Run(t *testing.T, addr, client string, cleanup func()) { }, } - if client == "nethttp2" { + if client == "nethttp2" || client == "nethttp3" { tests = append(tests, tcase{ name: "PARALLEL - GET 10 connections for 210 requests", fields: fields{config: &config.Config{ @@ -464,6 +464,7 @@ func testPayLoader_Run(t *testing.T, addr, client string, cleanup func()) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { p := NewPayLoader(tt.fields.config) got, err := p.Run()