Debian Codegraph @

stress/v2/statement/influxql.go

raw symbols SCIP
1 package statement
2
3 import (
4 "log"
5 "time"
6
7 "github.com/influxdata/influxdb/stress/v2/stress_client"
8 )
9
10 // InfluxqlStatement is a Statement Implementation that allows statements that parse in InfluxQL to be passed directly to the target instance
11 type InfluxqlStatement struct {
12 StatementID string
13 Query string
14 Tracer *stressClient.Tracer
15 }
16
17 func (i *InfluxqlStatement) tags() map[string]string {
18 tags := make(map[string]string)
19 return tags
20 }
21
22 // SetID statisfies the Statement Interface
23 func (i *InfluxqlStatement) SetID(s string) {
24 i.StatementID = s
25 }
26
27 // Run statisfies the Statement Interface
28 func (i *InfluxqlStatement) Run(s *stressClient.StressTest) {
29
30 // Set the tracer
31 i.Tracer = stressClient.NewTracer(i.tags())
32
33 // Make the Package
34 p := stressClient.NewPackage(stressClient.Query, []byte(i.Query), i.StatementID, i.Tracer)
35
36 // Increment the tracer
37 i.Tracer.Add(1)
38
39 // Send the Package
40 s.SendPackage(p)
41
42 // Wait for all operations to finish
43 i.Tracer.Wait()
44 }
45
46 // Report statisfies the Statement Interface
47 // No test coverage, fix
48 func (i *InfluxqlStatement) Report(s *stressClient.StressTest) (out string) {
49 allData := s.GetStatementResults(i.StatementID, "query")
50
51 iqlr := &influxQlReport{
52 statement: i.Query,
53 columns: allData[0].Series[0].Columns,
54 values: allData[0].Series[0].Values,
55 }
56
57 iqlr.responseTime = time.Duration(responseTimes(iqlr.columns, iqlr.values)[0].Value)
58
59 switch countSuccesses(iqlr.columns, iqlr.values) {
60 case 0:
61 iqlr.success = false
62 case 1:
63 iqlr.success = true
64 default:
65 log.Fatal("Error fetching response for InfluxQL statement")
66 }
67
68 return iqlr.String()
69 }