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

Preliminar support for wrk2 #40

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion containers/Containerfile
Original file line number Diff line number Diff line change
@@ -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
krishvoor marked this conversation as resolved.
Show resolved Hide resolved
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)
krishvoor marked this conversation as resolved.
Show resolved Hide resolved

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
2 changes: 2 additions & 0 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
1 change: 1 addition & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/tools/wrk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions pkg/runner/tools/wrk2.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading