Debian Codegraph @

cmd/influx_stress/influx_stress.go

raw
1 // Command influx_stress is deprecated; use github.com/influxdata/influx-stress instead.
2 package main
3
4 import (
5 "flag"
6 "fmt"
7 "log"
8 "os"
9 "runtime/pprof"
10
11 "github.com/influxdata/influxdb/stress"
12 v2 "github.com/influxdata/influxdb/stress/v2"
13 )
14
15 var (
16 useV2 = flag.Bool("v2", false, "Use version 2 of stress tool")
17 config = flag.String("config", "", "The stress test file")
18 cpuprofile = flag.String("cpuprofile", "", "Write the cpu profile to `filename`")
19 db = flag.String("db", "", "target database within test system for write and query load")
20 )
21
22 func main() {
23 o := stress.NewOutputConfig()
24 flag.Parse()
25
26 if *cpuprofile != "" {
27 f, err := os.Create(*cpuprofile)
28 if err != nil {
29 fmt.Println(err)
30 return
31 }
32 pprof.StartCPUProfile(f)
33 defer pprof.StopCPUProfile()
34 }
35
36 if *useV2 {
37 if *config != "" {
38 v2.RunStress(*config)
39 } else {
40 v2.RunStress("stress/v2/iql/file.iql")
41 }
42 } else {
43
44 c, err := stress.NewConfig(*config)
45 if err != nil {
46 log.Fatal(err)
47 return
48 }
49
50 if *db != "" {
51 c.Provision.Basic.Database = *db
52 c.Write.InfluxClients.Basic.Database = *db
53 c.Read.QueryClients.Basic.Database = *db
54 }
55
56 w := stress.NewWriter(c.Write.PointGenerators.Basic, &c.Write.InfluxClients.Basic)
57 r := stress.NewQuerier(&c.Read.QueryGenerators.Basic, &c.Read.QueryClients.Basic)
58 s := stress.NewStressTest(&c.Provision.Basic, w, r)
59
60 bw := stress.NewBroadcastChannel()
61 bw.Register(c.Write.InfluxClients.Basic.BasicWriteHandler)
62 bw.Register(o.HTTPHandler("write"))
63
64 br := stress.NewBroadcastChannel()
65 br.Register(c.Read.QueryClients.Basic.BasicReadHandler)
66 br.Register(o.HTTPHandler("read"))
67
68 s.Start(bw.Handle, br.Handle)
69
70 }
71 }