forked from Daniel.Sy/loic-go
29 lines
1.1 KiB
Go
29 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pkg/loic"
|
|
"github.com/spf13/cobra"
|
|
"time"
|
|
)
|
|
|
|
var startCmd = &cobra.Command{
|
|
Use: "start",
|
|
Short: "Startet einen Lasttest",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
targetURL, _ := cmd.Flags().GetString("target")
|
|
concurrency, _ := cmd.Flags().GetInt("concurrency")
|
|
duration, _ := cmd.Flags().GetDuration("duration")
|
|
rampUp, _ := cmd.Flags().GetDuration("ramp-up")
|
|
fmt.Printf("Starting test with target %s, concurrency %d, duration %v, ramp-up %v\n", targetURL, concurrency, duration, rampUp)
|
|
loic.StartTest(targetURL, concurrency, duration, rampUp)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
startCmd.Flags().StringP("target", "t", "", "Ziel-URL für den Test (z. B. http://service.cluster.local oder http://example.com)")
|
|
startCmd.Flags().IntP("concurrency", "c", 10, "Maximale Anzahl paralleler Anfragen")
|
|
startCmd.Flags().DurationP("duration", "d", time.Minute, "Dauer des Tests")
|
|
startCmd.Flags().DurationP("ramp-up", "r", 30*time.Second, "Zeit für schrittweise Erhöhung der Last")
|
|
rootCmd.AddCommand(startCmd)
|
|
}
|