From 12f7476533b078568e8dc2d30ec27f8f61d4d2a6 Mon Sep 17 00:00:00 2001 From: Joe Talerico Date: Thu, 7 Dec 2023 18:01:01 -0500 Subject: [PATCH] Add more validation When sejug was testing microshift he found some corner cases I didn't have code for... Fixing that! Signed-off-by: Joe Talerico --- pkg/k8s/kubernetes.go | 25 ++++++++----------------- pkg/netperf/netperf.go | 7 ++++++- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pkg/k8s/kubernetes.go b/pkg/k8s/kubernetes.go index 681a9a7b..615614be 100644 --- a/pkg/k8s/kubernetes.go +++ b/pkg/k8s/kubernetes.go @@ -107,7 +107,7 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error { } } log.Debugf("Number of nodes with role worker: %d", ncount) - if !s.NodeLocal && ncount < 2 { + if (s.HostNetwork || !s.NodeLocal) && ncount < 2 { return fmt.Errorf(" not enough nodes with label worker= to execute test (current number of nodes: %d).", ncount) } @@ -150,18 +150,6 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error { cdp.NodeAffinity = apiv1.NodeAffinity{ PreferredDuringSchedulingIgnoredDuringExecution: zoneNodeSelectorExpression(z), } - cdp.PodAffinity = apiv1.PodAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []apiv1.PodAffinityTerm{ - { - LabelSelector: &metav1.LabelSelector{ - MatchExpressions: []metav1.LabelSelectorRequirement{ - {Key: "role", Operator: metav1.LabelSelectorOpIn, Values: []string{serverRole}}, - }, - }, - TopologyKey: "kubernetes.io/hostname", - }, - }, - } } cdp.NodeAffinity = apiv1.NodeAffinity{ @@ -345,10 +333,13 @@ func BuildSUT(client *kubernetes.Clientset, s *config.PerfScenarios) error { } sdpHost.PodAntiAffinity = antiAffinity } - if s.HostNetwork { - s.ServerHost, err = deployDeployment(client, sdpHost) - if err != nil { - return err + + if ncount > 1 { + if s.HostNetwork { + s.ServerHost, err = deployDeployment(client, sdpHost) + if err != nil { + return err + } } } s.Server, err = deployDeployment(client, sdp) diff --git a/pkg/netperf/netperf.go b/pkg/netperf/netperf.go index 7bf5be02..abae8aea 100644 --- a/pkg/netperf/netperf.go +++ b/pkg/netperf/netperf.go @@ -130,6 +130,11 @@ func ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { if math.IsNaN(sample.Latency99ptile) { return sample, fmt.Errorf("Latency value is NaN") } - sample.LossPercent = 100 - (recv / send * 100) + // Negative values will mean UDP_STREAM + if sample.Retransmits < 0.0 { + sample.LossPercent = 100 - (recv / send * 100) + } else { + sample.LossPercent = 0 + } return sample, nil }