From 7cb96db47a0be69a2612850ae019104dcc26a8a9 Mon Sep 17 00:00:00 2001 From: Joe Talerico Date: Mon, 30 Oct 2023 15:38:18 -0400 Subject: [PATCH] Add more error checking Adding more error checking of values. Signed-off-by: Joe Talerico --- pkg/archive/archive.go | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index a817f6ba..2eb73b42 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -102,10 +102,34 @@ func BuildDocs(sr result.ScenarioResults, uuid string) ([]interface{}, error) { ClientNodeLabels: r.ClientNodeLabels, AcrossAZ: r.AcrossAZ, } - d.UDPLossPercent, _ = result.Average(r.LossSummary) - d.TCPRetransmit, _ = result.Average(r.RetransmitSummary) - d.Throughput, _ = result.Average(r.ThroughputSummary) - d.Latency, _ = result.Average(r.LatencySummary) + UDPLossPercent, e := result.Average(r.LossSummary) + if e != nil { + logging.Warn("Unable to process udp loss, setting value to zero") + d.UDPLossPercent = 0 + } else { + d.UDPLossPercent = UDPLossPercent + } + TCPRetransmit, e := result.Average(r.RetransmitSummary) + if e != nil { + logging.Warn("Unable to process tcp retransmits, setting value to zero") + d.TCPRetransmit = 0 + } else { + d.TCPRetransmit = TCPRetransmit + } + Throughput, e := result.Average(r.ThroughputSummary) + if e != nil { + logging.Warn("Unable to process throughput, setting value to zero") + d.Throughput = 0 + } else { + d.Throughput = Throughput + } + Latency, e := result.Average(r.LatencySummary) + if e != nil { + logging.Warn("Unable to process latency, setting value to zero") + d.Latency = 0 + } else { + d.Latency = Latency + } docs = append(docs, d) } return docs, nil