Skip to content

Commit

Permalink
Simplify the code, introduce mode
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Harsha Voora <[email protected]>
  • Loading branch information
krishvoor committed Nov 21, 2024
1 parent 98d909d commit cf74566
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions udn-density-pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (
// NewUDNDensityPods holds udn-density-pods workload
func NewUDNDensityPods(wh *workloads.WorkloadHelper) *cobra.Command {
var churnPercent, churnCycles, iterations int
var churn, l2, l3 bool
var churn bool
var churnDelay, churnDuration, podReadyThreshold time.Duration
var churnDeletionStrategy string
var metricsProfiles []string
var mode string
var rc int
cmd := &cobra.Command{
Use: "udn-density-pods",
Expand All @@ -48,24 +49,18 @@ func NewUDNDensityPods(wh *workloads.WorkloadHelper) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
setMetrics(cmd, metricsProfiles)
// Disable l3 when the user chooses l2
if l2 {
l3 = false
}
if l3 {
if mode == "layer3" {
os.Setenv("ENABLE_LAYER_2", "false")
rc = wh.Run("udn-density-pods")
}
if l2 {
} else {
os.Setenv("ENABLE_LAYER_2", "true")
rc = wh.Run("udn-density-pods")
}
rc = wh.Run("udn-density-pods")
},
PostRun: func(cmd *cobra.Command, args []string) {
os.Exit(rc)
},
}
cmd.Flags().BoolVar(&l2, "layer2", false, "Layer2 UDN test")
cmd.Flags().BoolVar(&l3, "layer3", true, "Layer3 UDN test")
cmd.Flags().StringVar(&mode, "mode", "layer3", "Layer3 UDN test")
cmd.Flags().BoolVar(&churn, "churn", true, "Enable churning")
cmd.Flags().IntVar(&churnCycles, "churn-cycles", 0, "Churn cycles to execute")
cmd.Flags().DurationVar(&churnDuration, "churn-duration", 1*time.Hour, "Churn duration")
Expand All @@ -75,6 +70,5 @@ func NewUDNDensityPods(wh *workloads.WorkloadHelper) *cobra.Command {
cmd.Flags().IntVar(&iterations, "iterations", 0, "Iterations")
cmd.Flags().DurationVar(&podReadyThreshold, "pod-ready-threshold", 1*time.Minute, "Pod ready timeout threshold")
cmd.Flags().StringSliceVar(&metricsProfiles, "metrics-profile", []string{"metrics.yml"}, "Comma separated list of metrics profiles to use")
cmd.MarkFlagsMutuallyExclusive("layer2", "layer3")
return cmd
}

0 comments on commit cf74566

Please sign in to comment.