Simplify per review comments
@@ -18,8 +18,6 @@ package locust
import (
"fmt"
- "strings"
- "time"
redskyappsv1alpha1 "github.com/thestormforge/optimize-controller/api/apps/v1alpha1"
"github.com/thestormforge/optimize-controller/redskyctl/internal/commands/generate/experiment/k8s"
@@ -173,26 +171,10 @@ func runTime(s *redskyappsv1alpha1.LocustScenario) *corev1.EnvVar {
return nil
}
- // Locust only accepts non-fractional hours, minutes, and seconds (no unit implies seconds)
+ // Just give Locust the number of seconds
// See: https://github.com/locustio/locust/blob/1f30d36d8f8d646eccb55aab7080fa69bf35c0d7/locust/util/timespan.py
- d := s.RunTime.Round(time.Second)
- var buf strings.Builder
- if h := d / time.Hour; h > 0 {
- _, _ = fmt.Fprintf(&buf, "%dh", h)
- d -= h * time.Hour
- }
- if m := d / time.Minute; m > 0 {
- _, _ = fmt.Fprintf(&buf, "%dm", m)
- d -= m * time.Minute
- }
- if buf.Len() == 0 {
- _, _ = fmt.Fprintf(&buf, "%d", d/time.Second)
- } else if d > 0 {
- _, _ = fmt.Fprintf(&buf, "%ds", d/time.Second)
- }
-
return &corev1.EnvVar{
Name: "RUN_TIME",
- Value: buf.String(),
+ Value: fmt.Sprintf("%.0f", s.RunTime.Seconds()),
}
}
