influxdb/stress/config.go

146 lines
3.6 KiB
Go
Raw Normal View History

Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
package stress
2015-09-12 00:23:14 +00:00
import (
2015-12-08 22:19:07 +00:00
"flag"
"fmt"
"strings"
2016-03-12 00:34:34 +00:00
"github.com/BurntSushi/toml"
2015-09-12 00:23:14 +00:00
)
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// Config is a struct for the Stress test configuration
type Config struct {
Provision Provision `toml:"provision"`
Write Write `toml:"write"`
Read Read `toml:"read"`
2015-09-12 00:23:14 +00:00
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// Provision is a struct that contains the configuration
// parameters for all implemented Provisioner's.
type Provision struct {
Basic BasicProvisioner `toml:"basic"`
}
2015-09-12 00:23:14 +00:00
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// Write is a struct that contains the configuration
// parameters for the stress test Writer.
type Write struct {
PointGenerators PointGenerators `toml:"point_generator"`
InfluxClients InfluxClients `toml:"influx_client"`
2015-09-12 00:23:14 +00:00
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// PointGenerators is a struct that contains the configuration
// parameters for all implemented PointGenerator's.
type PointGenerators struct {
Basic *BasicPointGenerator `toml:"basic"`
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// InfluxClients is a struct that contains the configuration
// parameters for all implemented InfluxClient's.
type InfluxClients struct {
Basic BasicClient `toml:"basic"`
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// Read is a struct that contains the configuration
// parameters for the stress test Reader.
type Read struct {
QueryGenerators QueryGenerators `toml:"query_generator"`
QueryClients QueryClients `toml:"query_client"`
2015-09-12 00:23:14 +00:00
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// QueryGenerators is a struct that contains the configuration
// parameters for all implemented QueryGenerator's.
type QueryGenerators struct {
Basic BasicQuery `toml:"basic"`
2015-09-12 00:23:14 +00:00
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// QueryClients is a struct that contains the configuration
// parameters for all implemented QueryClient's.
type QueryClients struct {
Basic BasicQueryClient `toml:"basic"`
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// NewConfig returns a pointer to a Config
func NewConfig(s string) (*Config, error) {
var c *Config
var err error
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
if s == "" {
c, err = BasicStress()
} else {
c, err = DecodeFile(s)
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
return c, err
}
2015-09-18 21:46:21 +00:00
// DecodeFile takes a file path for a toml config file
// and returns a pointer to a Config Struct.
func DecodeFile(s string) (*Config, error) {
t := &Config{}
2015-09-12 00:23:14 +00:00
// Decode the toml file
if _, err := toml.DecodeFile(s, t); err != nil {
return nil, err
}
2015-09-12 00:23:14 +00:00
return t, nil
2015-09-12 00:23:14 +00:00
}
2015-09-18 21:46:21 +00:00
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// DecodeConfig takes a file path for a toml config file
// and returns a pointer to a Config Struct.
func DecodeConfig(s string) (*Config, error) {
t := &Config{}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
// Decode the toml file
if _, err := toml.Decode(s, t); err != nil {
return nil, err
}
Refactor stress tool Add StressTest type and auxillary interfaces Add config structs Move generator to config Add utility methods used in stress Add basic components for a stress test Add touches Add configuration options Add unified results handlers Add final print out of results Add Success function to response type Add query support Send query results Add comments to run.go Change Basic to BasicWriter Add basic query Add incomplete README Abstract out response handling Change plugin to basic Add responseHandler type Add additional parameter to Query function Add todo comments and cleanup main Lower hard coded value Add flag for profiling Fix race condition Wait at the right place Chane point from struct to interface Improve generic write throughput Reorganize Fastest State Add toml config Add test server Add basic working version of config file Move config file logic into its own file Fix broken config file Add query count to stress config Add support for concurrency and batch interval Reorder config option Remove unneeded init Remove old stress package Move new stress code into stress directory Rework influx_stress tool Do something reasonable if no config is given Remove unneeded comments Add tests for stress package Add comments and reorganize code Add more comments Count lines posted correctly Add NewConfig method Fix style issues Add backticks to flag description Fix grammar Remove `StartTimer` calls where appropriate Fix comment language Change Reader to Querier Reorder defer Fix issues bought up by golint Add more comments Add more detailed Readme Increase counter appropriately Add return errors where appropriate Add test coverage Move `now()` from QueryClient to QueryGenerator
2015-11-02 19:50:39 +00:00
return t, nil
2015-09-18 21:46:21 +00:00
}
2015-12-08 22:19:07 +00:00
type outputConfig struct {
2016-03-12 00:34:34 +00:00
tags map[string]string
addr string
database string
retentionPolicy string
2015-12-08 22:19:07 +00:00
}
2016-03-12 00:34:34 +00:00
func (t *outputConfig) SetParams(addr, db, rp string) {
2015-12-08 22:19:07 +00:00
t.addr = addr
t.database = db
2016-03-12 00:34:34 +00:00
t.retentionPolicy = rp
2015-12-08 22:19:07 +00:00
}
func NewOutputConfig() *outputConfig {
var o outputConfig
tags := make(map[string]string)
o.tags = tags
database := flag.String("database", "stress", "name of database where the response times will persist")
2016-03-12 00:34:34 +00:00
retentionPolicy := flag.String("retention-policy", "", "name of the retention policy where the response times will persist")
2015-12-08 22:19:07 +00:00
address := flag.String("addr", "http://localhost:8086", "IP address and port of database where response times will persist (e.g., localhost:8086)")
flag.Var(&o, "tags", "A comma seperated list of tags")
flag.Parse()
2016-03-12 00:34:34 +00:00
o.SetParams(*address, *database, *retentionPolicy)
2015-12-08 22:19:07 +00:00
return &o
}
func (t *outputConfig) String() string {
var s string
for k, v := range t.tags {
s += fmt.Sprintf("%v=%v ", k, v)
}
2016-03-12 00:34:34 +00:00
return fmt.Sprintf("%v %v %v %v", s, t.database, t.retentionPolicy, t.addr)
2015-12-08 22:19:07 +00:00
}
func (t *outputConfig) Set(value string) error {
for _, s := range strings.Split(value, ",") {
tags := strings.Split(s, "=")
t.tags[tags[0]] = tags[1]
}
return nil
}