forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
87 lines (71 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"flag"
"log"
"net/http"
_ "net/http/pprof"
"time"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/paths"
"github.com/elastic/beats/libbeat/publisher/pipeline/stress"
"github.com/elastic/beats/libbeat/service"
// import queue types
_ "github.com/elastic/beats/libbeat/publisher/queue/memqueue"
// import outputs
_ "github.com/elastic/beats/libbeat/outputs/console"
_ "github.com/elastic/beats/libbeat/outputs/elasticsearch"
_ "github.com/elastic/beats/libbeat/outputs/fileout"
_ "github.com/elastic/beats/libbeat/outputs/logstash"
)
var (
duration time.Duration // -duration <duration>
overwrites = common.SettingFlag(nil, "E", "Configuration overwrite")
)
type config struct {
Path paths.Path
Logging logp.Logging
}
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
info := beat.Info{
Beat: "stresser",
Version: "0",
Name: "stresser.test",
Hostname: "stresser.test",
}
flag.DurationVar(&duration, "duration", 0, "Test duration (default 0)")
flag.Parse()
files := flag.Args()
cfg, err := common.LoadFiles(files...)
if err != nil {
return err
}
service.BeforeRun()
defer service.Cleanup()
if err := cfg.Merge(overwrites); err != nil {
return err
}
config := config{}
if err := cfg.Unpack(&config); err != nil {
return err
}
if err := paths.InitPaths(&config.Path); err != nil {
return err
}
if err = logp.Init("test", time.Now(), &config.Logging); err != nil {
return err
}
logp.SetStderr()
return stress.RunTests(info, duration, cfg, nil)
}
func startHTTP(bind string) {
go func() {
http.ListenAndServe(bind, nil)
}()
}