Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallel feature for http3 #40

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/payloader/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(&parallel, argParallel, false, "Sends reqs in parallel per connection with HTTP/2")
runCmd.Flags().BoolVar(&parallel, 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")
Expand Down
62 changes: 31 additions & 31 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions pkgs/payloader/payloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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()
Expand Down