This repository has been archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
main.go
50 lines (47 loc) · 1.74 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
"log"
"strings"
"time"
"github.com/ericchiang/k8s"
"github.com/mhausenblas/kubecuddler"
)
func main() {
var namespace string
var mode string
var load string
var image string
flag.StringVar(&namespace, "namespace", "kboom", "The namespace to run in, must exist. Create with 'kubectl create ns' if not done yet.")
flag.StringVar(&mode, "mode", "scale:20", "The mode to operate in: 'scale' for perf testing, 'soak' for long-term testing with timeout in seconds, defaults to scale:20.")
flag.StringVar(&load, "load", "pods:1", "The load, as in number of pods, defaults to pods:1.")
flag.StringVar(&image, "image", "busybox", "The container image used for the test pods. Must contain /bin/sh and sleep, defaults to busybox.")
flag.Parse()
res, _ := kubecuddler.Kubectl(false, false, "/kubectl", "version", "--short")
fmt.Println(strings.Split(res, "\n")[1])
client, err := k8s.NewInClusterClient()
if err != nil {
log.Fatal(err)
}
testmode, timeout, numpods := parseParams(mode, load)
timeoutinsec := time.Duration(timeout) * time.Second
fmt.Printf("Running a scale test, launching %v pod(s) with a %v timeout ...\n\n", numpods, timeoutinsec)
fmt.Println("-------- Results --------")
switch testmode {
case "scale":
if numpods > 0 {
r := launchPods(client, namespace, image, timeoutinsec, numpods)
fmt.Printf("Overall pods successful: %v out of %v\n", r.Totalsuccess, numpods)
fmt.Printf("Total runtime: %v\n", r.Totaltime)
fmt.Printf("Fastest pod: %v\n", r.Min)
fmt.Printf("Slowest pod: %v\n", r.Max)
fmt.Printf("p50 pods: %v\n", r.P50)
fmt.Printf("p95 pods: %v\n", r.P95)
}
case "soak":
log.Println("Not yet implemented, aborting.")
default:
log.Println("Unknown mode, aborting.")
}
}