diff --git a/containers/Containerfile b/containers/Containerfile index f8d4724..6c2f8f9 100644 --- a/containers/Containerfile +++ b/containers/Containerfile @@ -1,9 +1,12 @@ FROM registry.access.redhat.com/ubi8/ubi:latest as builder -RUN dnf install -y make git unzip gcc +RUN dnf install -y make git unzip gcc openssl-devel RUN git clone https://github.com/wg/wrk.git --depth=1 +RUN git clone https://github.com/giltene/wrk2.git --depth=1 RUN cd wrk && make -j $(nproc) +RUN cd wrk2 && make -j $(nproc) FROM registry.access.redhat.com/ubi8/ubi:latest RUN dnf install -y iproute procps-ng COPY --from=builder /wrk/wrk /usr/bin/wrk +COPY --from=builder /wrk2/wrk /usr/bin/wrk2 COPY json.lua json.lua diff --git a/pkg/config/types.go b/pkg/config/types.go index c0a5d9c..3a06374 100644 --- a/pkg/config/types.go +++ b/pkg/config/types.go @@ -46,4 +46,6 @@ type Config struct { Warmup bool `yaml:"warmup" json:"-"` // RequestTimeout defines the tool request timeout RequestTimeout time.Duration `yaml:"requestTimeout"` + // RequestRate defines the amount of requests to run in parallel + RequestRate int `yaml:"requestRate"` } diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 62cc699..4e20ca9 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -78,6 +78,7 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In return err } clusterMetadata.HAProxyVersion, err = getHAProxyVersion() + log.Infof("HAProxy version: %s", clusterMetadata.HAProxyVersion) if err != nil { return err } diff --git a/pkg/runner/tools/wrk.go b/pkg/runner/tools/wrk.go index 64dbf8e..853739a 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", fmt.Sprintf("%v", cfg.RequestTimeout.Seconds())}, + cmd: []string{"wrk", "-s", "json.lua", "-c", fmt.Sprint(cfg.Connections), "-d", fmt.Sprintf("%v", cfg.Duration.Seconds()), ep, "--timeout", fmt.Sprintf("%v", cfg.RequestTimeout.Seconds())}, res: PodResult{}, } return newWrk diff --git a/pkg/runner/tools/wrk2.go b/pkg/runner/tools/wrk2.go new file mode 100644 index 0000000..913fa1a --- /dev/null +++ b/pkg/runner/tools/wrk2.go @@ -0,0 +1,47 @@ +// Copyright 2023 The ingress-perf Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tools + +import ( + "encoding/json" + "fmt" + + "github.com/cloud-bulldozer/ingress-perf/pkg/config" +) + +type wrk2 struct { + cmd []string + res PodResult +} + +func init() { + toolMap["wrk2"] = Wrk2 +} + +func Wrk2(cfg config.Config, ep string) Tool { + newWrk := &wrk2{ + cmd: []string{"wrk2", "-R", fmt.Sprint(cfg.RequestRate), "-s", "json.lua", "-c", fmt.Sprint(cfg.Connections), "-d", fmt.Sprintf("%v", cfg.Duration.Seconds()), ep, "--timeout", fmt.Sprintf("%v", cfg.RequestTimeout.Seconds())}, + res: PodResult{}, + } + return newWrk +} + +func (w *wrk2) Cmd() []string { + return w.cmd +} + +func (w *wrk2) ParseResult(_, stderr string) (PodResult, error) { + return w.res, json.Unmarshal([]byte(stderr), &w.res) +}