Clean up stress package
parent
648040393c
commit
b1b2b8d43d
|
|
@ -389,7 +389,7 @@ type BasicQuery struct {
|
|||
|
||||
// QueryGenerate returns a Query channel
|
||||
func (q *BasicQuery) QueryGenerate(now func() time.Time) (<-chan Query, error) {
|
||||
c := make(chan Query, 0)
|
||||
c := make(chan Query)
|
||||
|
||||
go func(chan Query) {
|
||||
defer close(c)
|
||||
|
|
@ -406,7 +406,6 @@ func (q *BasicQuery) QueryGenerate(now func() time.Time) (<-chan Query, error) {
|
|||
// SetTime sets the internal state of time
|
||||
func (q *BasicQuery) SetTime(t time.Time) {
|
||||
q.time = t
|
||||
return
|
||||
}
|
||||
|
||||
// BasicQueryClient implements the QueryClient interface
|
||||
|
|
@ -513,11 +512,7 @@ func resetDB(c client.Client, database string) error {
|
|||
_, err = c.Query(client.Query{
|
||||
Command: fmt.Sprintf("CREATE DATABASE %s", database),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// BasicProvisioner implements the Provisioner
|
||||
|
|
@ -562,7 +557,7 @@ func NewBroadcastChannel() *BroadcastChannel {
|
|||
}
|
||||
|
||||
func (b *BroadcastChannel) Register(fn responseHandler) {
|
||||
ch := make(chan response, 0)
|
||||
ch := make(chan response)
|
||||
|
||||
b.chs = append(b.chs, ch)
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ func (s *StressTest) Start(wHandle responseHandler, rHandle responseHandler) {
|
|||
wg.Add(1)
|
||||
// Starts Writing
|
||||
go func() {
|
||||
r := make(chan response, 0)
|
||||
r := make(chan response)
|
||||
wt := NewTimer()
|
||||
|
||||
go func() {
|
||||
|
|
|
|||
|
|
@ -322,8 +322,8 @@ func TestBasicClient_send(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBasicClient_Batch(t *testing.T) {
|
||||
c := make(chan Point, 0)
|
||||
r := make(chan response, 0)
|
||||
c := make(chan Point)
|
||||
r := make(chan response)
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
content, _ := ioutil.ReadAll(r.Body)
|
||||
|
|
@ -348,11 +348,6 @@ func TestBasicClient_Batch(t *testing.T) {
|
|||
|
||||
}(c)
|
||||
|
||||
go func(r chan response) {
|
||||
for _ = range r {
|
||||
}
|
||||
}(r)
|
||||
|
||||
err := basicIC.Batch(c, r)
|
||||
close(r)
|
||||
if err != nil {
|
||||
|
|
@ -395,8 +390,6 @@ func TestBasicQueryClient_Query(t *testing.T) {
|
|||
var data client.Response
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = json.NewEncoder(w).Encode(data)
|
||||
|
||||
return
|
||||
}))
|
||||
defer ts.Close()
|
||||
|
||||
|
|
@ -438,7 +431,7 @@ func Test_NewConfigWithFile(t *testing.T) {
|
|||
if p.Basic.Database != "stress" {
|
||||
t.Errorf("Expected `stress` got %s", p.Basic.Database)
|
||||
}
|
||||
if p.Basic.ResetDatabase != true {
|
||||
if !p.Basic.ResetDatabase {
|
||||
t.Errorf("Expected true got %v", p.Basic.ResetDatabase)
|
||||
}
|
||||
|
||||
|
|
@ -480,8 +473,8 @@ func Test_NewConfigWithFile(t *testing.T) {
|
|||
if wc.Concurrency != 10 {
|
||||
t.Errorf("Expected 10 got %v", wc.Concurrency)
|
||||
}
|
||||
if wc.SSL != false {
|
||||
t.Errorf("Expected 10 got %v", wc.SSL)
|
||||
if wc.SSL {
|
||||
t.Errorf("Expected true got %v", wc.SSL)
|
||||
}
|
||||
if wc.Format != "line_http" {
|
||||
t.Errorf("Expected `line_http` got %s", wc.Format)
|
||||
|
|
@ -525,7 +518,7 @@ func Test_NewConfigWithoutFile(t *testing.T) {
|
|||
if p.Basic.Database != "stress" {
|
||||
t.Errorf("Expected `stress` got %s", p.Basic.Database)
|
||||
}
|
||||
if p.Basic.ResetDatabase != true {
|
||||
if !p.Basic.ResetDatabase {
|
||||
t.Errorf("Expected true got %v", p.Basic.ResetDatabase)
|
||||
}
|
||||
|
||||
|
|
@ -567,8 +560,8 @@ func Test_NewConfigWithoutFile(t *testing.T) {
|
|||
if wc.Concurrency != 10 {
|
||||
t.Errorf("Expected 10 got %v", wc.Concurrency)
|
||||
}
|
||||
if wc.SSL != false {
|
||||
t.Errorf("Expected 10 got %v", wc.SSL)
|
||||
if wc.SSL {
|
||||
t.Errorf("Expected true got %v", wc.SSL)
|
||||
}
|
||||
if wc.Format != "line_http" {
|
||||
t.Errorf("Expected `line_http` got %s", wc.Format)
|
||||
|
|
|
|||
|
|
@ -87,10 +87,6 @@ func TestStringersEval(t *testing.T) {
|
|||
if parseFloat(values[4].(string)) > floatRandFunction.Argument {
|
||||
t.Errorf("Expected value below: %v\nGot value: %v\n", floatRandFunction.Argument, values[4])
|
||||
}
|
||||
// Check the spoofTime func
|
||||
if values[5] != 8 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func spoofTime() int64 {
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import (
|
|||
// NewStressTest creates the backend for the stress test
|
||||
func NewStressTest() *StressTest {
|
||||
|
||||
packageCh := make(chan Package, 0)
|
||||
directiveCh := make(chan Directive, 0)
|
||||
responseCh := make(chan Response, 0)
|
||||
packageCh := make(chan Package)
|
||||
directiveCh := make(chan Directive)
|
||||
responseCh := make(chan Response)
|
||||
|
||||
clnt, _ := influx.NewHTTPClient(influx.HTTPConfig{
|
||||
Addr: fmt.Sprintf("http://%v/", "localhost:8086"),
|
||||
|
|
@ -46,8 +46,8 @@ func NewStressTest() *StressTest {
|
|||
// NewTestStressTest returns a StressTest to be used for testing Statements
|
||||
func NewTestStressTest() (*StressTest, chan Package, chan Directive) {
|
||||
|
||||
packageCh := make(chan Package, 0)
|
||||
directiveCh := make(chan Directive, 0)
|
||||
packageCh := make(chan Package)
|
||||
directiveCh := make(chan Directive)
|
||||
|
||||
s := &StressTest{
|
||||
TestDB: "_stressTest",
|
||||
|
|
|
|||
|
|
@ -67,8 +67,3 @@ func (sc *stressClient) makeGet(addr, statementID string, tr *Tracer) {
|
|||
// Send the response
|
||||
sc.responseChan <- NewResponse(sc.queryPoint(statementID, body, resp.StatusCode, elapsed, tr.Tags), tr)
|
||||
}
|
||||
|
||||
func success(r *http.Response) bool {
|
||||
// ADD success for tcp, udp, etc
|
||||
return r != nil && (r.StatusCode == 204 || r.StatusCode == 200)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ const (
|
|||
keywordEnd
|
||||
)
|
||||
|
||||
// These assignments prevent static analysis tools highlighting lack of use of
|
||||
// boundary constants.
|
||||
var _, _ = literalBeg, literalEnd
|
||||
var _, _ = keywordBeg, keywordEnd
|
||||
|
||||
var eof = rune(1)
|
||||
|
||||
func isWhitespace(ch rune) bool { return ch == ' ' || ch == '\t' || ch == '\n' }
|
||||
|
|
|
|||
Loading…
Reference in New Issue