| 1 |
package statement |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"strings" |
| 6 |
|
| 7 |
"github.com/influxdata/influxdb/stress/v2/stress_client" |
| 8 |
) |
| 9 |
|
| 10 |
|
| 11 |
type SetStatement struct { |
| 12 |
Var string |
| 13 |
Value string |
| 14 |
|
| 15 |
StatementID string |
| 16 |
|
| 17 |
Tracer *stressClient.Tracer |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
func (i *SetStatement) SetID(s string) { |
| 22 |
i.StatementID = s |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
func (i *SetStatement) Run(s *stressClient.StressTest) { |
| 27 |
i.Tracer = stressClient.NewTracer(make(map[string]string)) |
| 28 |
d := stressClient.NewDirective(strings.ToLower(i.Var), strings.ToLower(i.Value), i.Tracer) |
| 29 |
switch d.Property { |
| 30 |
|
| 31 |
|
| 32 |
case "precision": |
| 33 |
s.Precision = d.Value |
| 34 |
i.Tracer.Add(1) |
| 35 |
s.SendDirective(d) |
| 36 |
|
| 37 |
|
| 38 |
case "startdate": |
| 39 |
s.Lock() |
| 40 |
s.StartDate = d.Value |
| 41 |
s.Unlock() |
| 42 |
|
| 43 |
|
| 44 |
case "batchsize": |
| 45 |
s.Lock() |
| 46 |
s.BatchSize = parseInt(d.Value) |
| 47 |
s.Unlock() |
| 48 |
|
| 49 |
default: |
| 50 |
i.Tracer.Add(1) |
| 51 |
s.SendDirective(d) |
| 52 |
} |
| 53 |
i.Tracer.Wait() |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
func (i *SetStatement) Report(s *stressClient.StressTest) string { |
| 58 |
return fmt.Sprintf("SET %v = '%v'", i.Var, i.Value) |
| 59 |
} |