Move TestServer_ExecuteWildcardQuery
parent
b5d5ce070f
commit
c95af24e43
|
@ -436,6 +436,20 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
|
|||
expected: `{"results":[{"series":[{"name":"cpu_n_precision","columns":["time","count"],"values":[["1970-01-01T00:00:00Z",1]]}]}]}`,
|
||||
},
|
||||
|
||||
// Wildcard queries
|
||||
{
|
||||
reset: true,
|
||||
name: "wildcard queries",
|
||||
write: `{"database" : "%DB%", "retentionPolicy" : "%RP%", "points": [
|
||||
{"name": "cpu", "timestamp": "2000-01-01T00:00:00Z", "tags": {"region": "us-east"}, "fields": {"value": 10}},
|
||||
{"name": "cpu", "timestamp": "2000-01-01T00:00:10Z", "tags": {"region": "us-east"}, "fields": {"val-x": 20}},
|
||||
{"name": "cpu", "timestamp": "2000-01-01T00:00:20Z", "tags": {"region": "us-east"}, "fields": {"value": 30, "val-x": 40}}
|
||||
]}`,
|
||||
query: `SELECT * FROM cpu`,
|
||||
queryDb: "%DB%",
|
||||
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","val-x","value"],"values":[["2000-01-01T00:00:00Z",null,10],["2000-01-01T00:00:10Z",20,null],["2000-01-01T00:00:20Z",40,30]]}]}]}`,
|
||||
},
|
||||
|
||||
// WHERE fields queries
|
||||
{
|
||||
reset: true,
|
||||
|
|
|
@ -1506,33 +1506,6 @@ func TestServer_LimitAndOffset(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure the server can execute a wildcard query and return the data correctly.
|
||||
func TestServer_ExecuteWildcardQuery(t *testing.T) {
|
||||
c := test.NewMessagingClient()
|
||||
defer c.Close()
|
||||
s := OpenServer(c)
|
||||
defer s.Close()
|
||||
s.CreateDatabase("foo")
|
||||
s.CreateRetentionPolicy("foo", &influxdb.RetentionPolicy{Name: "raw", Duration: 1 * time.Hour})
|
||||
s.SetDefaultRetentionPolicy("foo", "raw")
|
||||
s.CreateUser("susy", "pass", false)
|
||||
|
||||
// Write series with one point to the database.
|
||||
// We deliberatly write one value per insert as we need to create each field in a predicatable order for testing.
|
||||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "cpu", Tags: map[string]string{"region": "us-east"}, Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": float64(10)}}})
|
||||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "cpu", Tags: map[string]string{"region": "us-east"}, Timestamp: mustParseTime("2000-01-01T00:00:10Z"), Fields: map[string]interface{}{"val-x": 20}}})
|
||||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "cpu", Tags: map[string]string{"region": "us-east"}, Timestamp: mustParseTime("2000-01-01T00:00:20Z"), Fields: map[string]interface{}{"value": 30, "val-x": 40}}})
|
||||
|
||||
// Select * (wildcard).
|
||||
results := s.ExecuteQuery(MustParseQuery(`SELECT * FROM cpu`), "foo", nil)
|
||||
if res := results.Results[0]; res.Err != nil {
|
||||
t.Fatalf("unexpected error during SELECT *: %s", res.Err)
|
||||
} else if s, e := mustMarshalJSON(res), `{"series":[{"name":"cpu","columns":["time","val-x","value"],"values":[["2000-01-01T00:00:00Z",null,10],["2000-01-01T00:00:10Z",20,null],["2000-01-01T00:00:20Z",40,30]]}]}`; s != e {
|
||||
t.Logf("expected %s\n", e)
|
||||
t.Fatalf("unexpected results during SELECT *: %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the server can execute a wildcard GROUP BY
|
||||
func TestServer_ExecuteWildcardGroupBy(t *testing.T) {
|
||||
c := test.NewMessagingClient()
|
||||
|
|
Loading…
Reference in New Issue