Skip to content

Commit

Permalink
Include HAProxy version on metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Sep 21, 2023
1 parent 4370fc8 commit f777146
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 2 additions & 4 deletions config/standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
- termination: http
connections: 20
samples: 1
duration: 1m
duration: 10s
path: /1024.html
concurrency: 1
tool: wrk
serverReplicas: 90
requestTimeout: 2s
tuningPatch: '{"spec":{"nodePlacement": {"nodeSelector": {"matchLabels": {"node-role.kubernetes.io/infra": ""}}}, "replicas": 2}}'
warmup: true

- termination: http
connections: 200
samples: 2
duration: 2m
duration: 10s
path: /1024.html
concurrency: 1
tool: wrk
Expand Down
3 changes: 1 addition & 2 deletions pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sync"
"time"

ocpmetadata "github.com/cloud-bulldozer/go-commons/ocp-metadata"
"github.com/cloud-bulldozer/go-commons/version"
"github.com/cloud-bulldozer/ingress-perf/pkg/config"
"github.com/cloud-bulldozer/ingress-perf/pkg/runner/tools"
Expand All @@ -36,7 +35,7 @@ import (

var lock = &sync.Mutex{}

func runBenchmark(cfg config.Config, clusterMetadata ocpmetadata.ClusterMetadata) ([]tools.Result, error) {
func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata) ([]tools.Result, error) {
var aggAvgRps, aggAvgLatency, aggP99Latency float64
var timeouts, httpErrors int64
var benchmarkResult []tools.Result
Expand Down
17 changes: 8 additions & 9 deletions pkg/runner/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package runner
import (
"bytes"
"context"
"fmt"
"strings"

log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
Expand All @@ -13,14 +13,14 @@ import (
)

func getHAProxyVersion() (string, error) {
var version string
var stdout, stderr bytes.Buffer
podList, err := clientSet.CoreV1().Pods("openshift-ingress").List(context.TODO(),
v1.ListOptions{LabelSelector: "ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default",
v1.ListOptions{
LabelSelector: "ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default",
FieldSelector: "status.phase=Running"},
)
if err != nil {
return version, err
return "", err
}
routerPod := podList.Items[0]
req := clientSet.CoreV1().RESTClient().Post().
Expand All @@ -33,21 +33,20 @@ func getHAProxyVersion() (string, error) {
Stdin: false,
Stdout: true,
Stderr: true,
Command: []string{"haproxy", "-v"},
Command: []string{"bash", "-c", "rpm -qa | grep haproxy"},
TTY: false,
}, scheme.ParameterCodec)
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", req.URL())
if err != nil {
log.Error(err.Error())
return version, err
return "", err
}
err = exec.StreamWithContext(context.TODO(), remotecommand.StreamOptions{
Stdout: &stdout,
Stderr: &stderr,
})
if err != nil {
return version, err
return "", err
}
fmt.Println(stdout.String())
return version, err
return strings.TrimRight(stdout.String(), "\n"), err
}
6 changes: 3 additions & 3 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In
var kubeconfig string
var benchmarkResult []tools.Result
var comparator comparison.Comparator
var clusterMetadata tools.ClusterMetadata
passed := true
log.Info("Starting ingress-perf")
if os.Getenv("KUBECONFIG") != "" {
Expand All @@ -73,12 +74,11 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In
if err != nil {
return err
}
clusterMetadata, err := ocpMetadata.GetClusterMetadata()
clusterMetadata.ClusterMetadata, err = ocpMetadata.GetClusterMetadata()
if err != nil {
return err
}

_, err = getHAProxyVersion()
clusterMetadata.HAProxyVersion, err = getHAProxyVersion()
if err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/runner/tools/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"github.com/cloud-bulldozer/ingress-perf/pkg/config"
)

type ClusterMetadata struct {
ocpmetadata.ClusterMetadata
HAProxyVersion string `json:"haproxyVersion,omitempty"`
}

type Tool interface {
ParseResult(string, string) (PodResult, error)
Cmd() []string
Expand Down Expand Up @@ -65,5 +70,5 @@ type Result struct {
Requests int64 `json:"requests"`
Timeouts int64 `json:"timeouts"`
Version string `json:"version"`
ocpmetadata.ClusterMetadata
ClusterMetadata
}

0 comments on commit f777146

Please sign in to comment.