-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
57 lines (46 loc) · 1.38 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
51
52
53
54
55
56
57
package main
import (
"flag"
"fmt"
"os"
"time"
)
var (
vapeFile = flag.String("config", "Vapefile", "The full path to the Vape configuration file")
insecureSSL = flag.Bool("skip-ssl-verification", false, "Ignore bad SSL certs")
concurrency = flag.Int("concurrency", 3, "The maximum number of requests to make at a time")
authorization = flag.String("authorization", "", "Authorization header containing authentication credentials")
start = time.Now()
)
func main() {
flag.Parse()
args := flag.Args()
if len(args) < 1 {
fmt.Println("vape: usage: no base URL specified")
os.Exit(0)
}
baseURL, err := parseBaseURL(args[0])
if err != nil {
fmt.Printf("vape: invalid base URL: %v\n", err)
os.Exit(0)
}
smokeTests, err := parseVapefile(*vapeFile)
if err != nil {
fmt.Printf("Error reading config: %s", err.Error())
os.Exit(1)
}
httpClient := NewHTTPClient(*insecureSSL)
vape := NewVape(httpClient, baseURL, *concurrency, *authorization)
results, errors := vape.Process(smokeTests)
for _, result := range results {
fmt.Println(formatResult(result))
}
for _, err := range errors {
fmt.Println(err)
}
fmt.Printf("\n✨ [%d/%d] tests passed in %s\n", results.PassedCount(), len(smokeTests), time.Since(start))
if results.PassedCount() < len(smokeTests) {
fmt.Println("🔥 Some tests failed. You may have a bad deployment")
os.Exit(2)
}
}