Skip to content

Commit

Permalink
fix netdns success rate err
Browse files Browse the repository at this point in the history
Signed-off-by: ii2day <ji.li@daocloud.io>
  • Loading branch information
ii2day committed Sep 28, 2023
1 parent 67c6bf7 commit 57ab077
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/pluginManager/netdns/agentExecuteTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (

func ParseSuccessCondition(successCondition *crd.NetSuccessCondition, metricResult *v1beta1.DNSMetrics) (failureReason string, err error) {
switch {
case successCondition.SuccessRate != nil && float64(metricResult.SuccessCounts)/float64(metricResult.SuccessCounts) < *(successCondition.SuccessRate):
failureReason = fmt.Sprintf("Success Rate %v is lower than request %v", float64(metricResult.SuccessCounts)/float64(metricResult.SuccessCounts), *(successCondition.SuccessRate))
case successCondition.SuccessRate != nil && float64(metricResult.SuccessCounts)/float64(metricResult.RequestCounts) < *(successCondition.SuccessRate):
failureReason = fmt.Sprintf("Success Rate %v is lower than request %v", float64(metricResult.SuccessCounts)/float64(metricResult.RequestCounts), *(successCondition.SuccessRate))
case successCondition.MeanAccessDelayInMs != nil && int64(metricResult.Latencies.Mean) > *(successCondition.MeanAccessDelayInMs):
failureReason = fmt.Sprintf("mean delay %v ms is bigger than request %v ms", metricResult.Latencies.Mean, *(successCondition.MeanAccessDelayInMs))
default:
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/common/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func CompareResult(f *frame.Framework, name, taskKind string, podIPs []string, n
if math.Abs(realRequestCount-expectRequestCount)/expectRequestCount > 0.1 {
return GetResultFromReport(r), fmt.Errorf("The error in the number of requests is greater than 0.1,real request count: %d,expect request count:%d", int(realRequestCount), int(expectRequestCount))
}
if float64(m.Metrics.SuccessCounts)/float64(m.Metrics.RequestCounts) != m.SucceedRate {
return GetResultFromReport(r), fmt.Errorf("succeedRate not equal")
}
}
// startTime
shcedule := pluginManager.NewSchedule(*rs.Spec.Schedule.Schedule)
Expand Down Expand Up @@ -272,6 +275,9 @@ func CompareResult(f *frame.Framework, name, taskKind string, podIPs []string, n
if math.Abs(realCount-expectCount)/expectCount > 0.1 {
return GetResultFromReport(r), fmt.Errorf("The error in the number of requests is greater than 0.1,real request count: %d,expect request count:%d", int(realCount), int(expectCount))
}
if float64(m.Metrics.SuccessCounts)/float64(m.Metrics.RequestCounts) != m.SucceedRate {
return GetResultFromReport(r), fmt.Errorf("succeedRate not equal")
}
}
// startTime
shcedule := pluginManager.NewSchedule(*rs.Spec.Schedule.Schedule)
Expand Down Expand Up @@ -334,6 +340,9 @@ func CompareResult(f *frame.Framework, name, taskKind string, podIPs []string, n
if math.Abs(realCount-expectCount)/expectCount > 0.1 {
return GetResultFromReport(r), fmt.Errorf("The error in the number of requests is greater than 0.1, real request count: %d,expect request count:%d ", int(realCount), int(expectCount))
}
if float64(m.Metrics.SuccessCounts)/float64(m.Metrics.RequestCounts) != m.SucceedRate {
return GetResultFromReport(r), fmt.Errorf("succeedRate not equal")
}
}
// startTime
shcedule := pluginManager.NewSchedule(*rs.Spec.Schedule.Schedule)
Expand Down

0 comments on commit 57ab077

Please sign in to comment.