forked from Daniel.Sy/loic-go
✨ Initial commit
This commit is contained in:
commit
600e641560
11 changed files with 394 additions and 0 deletions
20
cmd/root.go
Normal file
20
cmd/root.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "loic",
|
||||
Short: "LOIC-Anwendung für Lasttests",
|
||||
Long: `Eine Anwendung für skalierbare Lasttests im Kubernetes-Cluster.`,
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
29
cmd/start.go
Normal file
29
cmd/start.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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)
|
||||
}
|
||||
25
cmd/status.go
Normal file
25
cmd/status.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pkg/loic"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "Displays test status",
|
||||
Long: "Display test status of the application",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if loic.IsTestRunning() {
|
||||
fmt.Println("Status: running")
|
||||
return
|
||||
} else {
|
||||
fmt.Println("Status: stopped")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(statusCmd)
|
||||
}
|
||||
18
cmd/stop.go
Normal file
18
cmd/stop.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pkg/loic"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var stopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Stoppt den aktuellen Lasttest",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
loic.StopTest()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(stopCmd)
|
||||
}
|
||||
19
cmd/web.go
Normal file
19
cmd/web.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/Daniel.Sy/loic-go/pkg/web"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var webCmd = &cobra.Command{
|
||||
Use: "web",
|
||||
Short: "Startet den Web-Server",
|
||||
Long: "Startet den Web-Server für myapp",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
web.Start()
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(webCmd)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue