From b3748679e3c92b36bc9542ebd33757693b5adfec Mon Sep 17 00:00:00 2001 From: Raul Sevilla Date: Wed, 12 Jul 2023 13:25:37 +0200 Subject: [PATCH] Custom request timeout Signed-off-by: Raul Sevilla --- README.md | 23 ++++++++++++----------- config/standard.yml | 1 + pkg/config/config.go | 4 +++- pkg/config/types.go | 2 ++ pkg/runner/tools/wrk.go | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index cea6d12..d21ceeb 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,18 @@ Ingress-perf configuration is defined in a YAML file, holding an array of the fo | Field Name | Type | Description | Default Value | |------------------|------------------|----------------------------------------------------------------------------------------------------------|---------------| -| `Termination` | `string` | Defines the type of benchmark termination. Allowed values are `http`, `edge`, `reencrypt` and `reencrypt`. | N/A | -| `Connections` | `int` | Defines the number of connections per client. | `0` | -| `Samples` | `int` | Defines the number of samples per scenario. | `0` | -| `Duration` | `time.Duration` | Defines the duration of each sample. | `""` | -| `Path` | `string` | Defines the scenario endpoint path, for example: `/1024.html`, `/2048.html`. | `""` | -| `Concurrency` | `int32` | Defines the number of clients that will concurrently run the benchmark scenario. | `0` | -| `Tool` | `string` | Defines the tool to run the benchmark scenario. | `""` | -| `ServerReplicas` | `int32` | Defines the number of server (nginx) replicas backed by the routes. | `0` | -| `Tuning` | `string` | Defines a tuning patch for the default `IngressController` object. | `""` | -| `Delay` | `time.Duration` | Defines a delay between samples. | `0s` | -| `Warmup` | `bool` | Enables warmup: indexing will be disabled in this scenario. The default value is `false`. | `false` | +| `termination` | `string` | Defines the type of benchmark termination. Allowed values are `http`, `edge`, `reencrypt` and `reencrypt`. | N/A | +| `connections` | `int` | Defines the number of connections per client. | `0` | +| `samples` | `int` | Defines the number of samples per scenario. | `0` | +| `duration` | `time.Duration` | Defines the duration of each sample. | `""` | +| `path` | `string` | Defines the scenario endpoint path, for example: `/1024.html`, `/2048.html`. | `""` | +| `concurrency` | `int32` | Defines the number of clients that will concurrently run the benchmark scenario. | `0` | +| `tool` | `string` | Defines the tool to run the benchmark scenario. | `""` | +| `serverReplicas` | `int32` | Defines the number of server (nginx) replicas backed by the routes. | `0` | +| `tuningPatch` | `string` | Defines a JSON merge tuning patch for the default `IngressController` object. | `""` | +| `delay` | `time.Duration` | Defines a delay between samples. | `0s` | +| `warmup` | `bool` | Enables warmup: indexing will be disabled in this scenario. | `false` | +| `requestTimeout` | `time.Duration` | Request timeout | `1s` | ## Supported tools diff --git a/config/standard.yml b/config/standard.yml index 1af9202..09d4310 100644 --- a/config/standard.yml +++ b/config/standard.yml @@ -9,6 +9,7 @@ concurrency: 1 tool: wrk serverReplicas: 90 + requestTimeout: 2s tuningPatch: '{"spec":{"nodePlacement": {"nodeSelector": {"matchLabels": {"node-role.kubernetes.io/infra": ""}}}, "replicas": 2}}' warmup: true diff --git a/pkg/config/config.go b/pkg/config/config.go index c3932e6..d8fd350 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -16,6 +16,7 @@ package config import ( "os" + "time" yaml "gopkg.in/yaml.v3" ) @@ -24,7 +25,8 @@ import ( func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { type ConfigDefaulted Config defaultCfg := ConfigDefaulted{ - Warmup: false, // Disable warmup by default + Warmup: false, // Disable warmup by default + RequestTimeout: time.Second, } if err := unmarshal(&defaultCfg); err != nil { return err diff --git a/pkg/config/types.go b/pkg/config/types.go index f9766d0..623ee17 100644 --- a/pkg/config/types.go +++ b/pkg/config/types.go @@ -42,4 +42,6 @@ type Config struct { Delay time.Duration `yaml:"delay"` // Warmup enables warmup: Indexing will be disabled in this scenario. Default is false Warmup bool `yaml:"warmup" json:"-"` + // RequestTimeout defines the tool request timeout + RequestTimeout time.Duration `yaml:"requestTimeout"` } diff --git a/pkg/runner/tools/wrk.go b/pkg/runner/tools/wrk.go index 629c374..64dbf8e 100644 --- a/pkg/runner/tools/wrk.go +++ b/pkg/runner/tools/wrk.go @@ -32,7 +32,7 @@ func init() { func Wrk(cfg config.Config, ep string) Tool { newWrk := &wrk{ - cmd: []string{"wrk", "-s", "json.lua", "-c", fmt.Sprint(cfg.Connections), "-d", fmt.Sprintf("%v", cfg.Duration.Seconds()), "--latency", ep, "--timeout=1s"}, + cmd: []string{"wrk", "-s", "json.lua", "-c", fmt.Sprint(cfg.Connections), "-d", fmt.Sprintf("%v", cfg.Duration.Seconds()), "--latency", ep, "--timeout", fmt.Sprintf("%v", cfg.RequestTimeout.Seconds())}, res: PodResult{}, } return newWrk