-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
52 lines (41 loc) · 1.21 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
package main
import (
"github.com/ferdoran/sro-load-tester/flows"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
var AvailableFlows = make(map[string]flows.Flow)
func main() {
// 1. Load config
initConfig()
//logrus.SetLevel(logrus.DebugLevel)
logrus.SetFormatter(&logrus.TextFormatter{
ForceColors: true,
EnvironmentOverrideColors: true,
FullTimestamp: true,
TimestampFormat: "2006-01-01 15:04:05.000",
})
// 2. Initialize flows
AvailableFlows["login"] = flows.NewLoginFlow()
// 3. Play flows
flows := viper.GetStringSlice("flows.active")
logrus.Infof("found flows: %v", flows)
runner := NewRunner(flows)
runner.Start()
}
func initConfig() {
viper.SetConfigName("config")
viper.SetConfigType("json")
viper.AddConfigPath(".")
viper.SetDefault("gateway.host", "127.0.0.1")
viper.SetDefault("gateway.port", 15779)
viper.SetDefault("agent.host", "127.0.0.1")
viper.SetDefault("agent.port", 15882)
viper.SetDefault("config.duration", "60s")
viper.SetDefault("config.reschedule-timeout", "50ms")
viper.SetDefault("config.concurrent-clients", 10)
err := viper.ReadInConfig()
if err != nil {
logrus.Panicf("failed to read in config file: %s", err)
}
}