Move string and bool data write to integration
parent
c3ffa45279
commit
8480a1829a
|
@ -250,6 +250,19 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
|
|||
query: `SELECT * FROM "%DB%"."%RP%".cpu`,
|
||||
expected: `{"results":[{"series":[{"name":"cpu","columns":["time","value"],"values":[["2015-02-28T01:03:36.703820946Z",100]]}]}]}`,
|
||||
},
|
||||
{
|
||||
name: "single string point with timestamp",
|
||||
write: `{"database" : "%DB%", "retentionPolicy" : "%RP%", "points": [{"name": "logs", "timestamp": "2015-02-28T01:03:36.703820946Z", "tags": {"host": "server01"}, "fields": {"value": "disk full"}}]}`,
|
||||
query: `SELECT * FROM "%DB%"."%RP%".logs`,
|
||||
expected: `{"results":[{"series":[{"name":"logs","columns":["time","value"],"values":[["2015-02-28T01:03:36.703820946Z","disk full"]]}]}]}`,
|
||||
},
|
||||
{
|
||||
name: "single bool point with timestamp",
|
||||
write: `{"database" : "%DB%", "retentionPolicy" : "%RP%", "points": [{"name": "status", "timestamp": "2015-02-28T01:03:36.703820946Z", "tags": {"host": "server01"}, "fields": {"value": "true"}}]}`,
|
||||
query: `SELECT * FROM "%DB%"."%RP%".status`,
|
||||
expected: `{"results":[{"series":[{"name":"status","columns":["time","value"],"values":[["2015-02-28T01:03:36.703820946Z","true"]]}]}]}`,
|
||||
},
|
||||
|
||||
{
|
||||
name: "single point, select with now()",
|
||||
query: `SELECT * FROM "%DB%"."%RP%".cpu WHERE time < now()`,
|
||||
|
|
|
@ -1198,92 +1198,6 @@ func TestHandler_serveWriteSeriesZeroTime(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_serveWriteSeriesStringValues(t *testing.T) {
|
||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||
srvr.CreateDatabase("foo")
|
||||
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
|
||||
srvr.SetDefaultRetentionPolicy("foo", "bar")
|
||||
|
||||
s := NewHTTPServer(srvr)
|
||||
defer s.Close()
|
||||
|
||||
status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "logs", "tags": {"host": "server01"},"fields": {"event": "disk full"}}]}`)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("unexpected status: %d", status)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
|
||||
|
||||
srvr.Restart() // Ensure data is queryable across restarts.
|
||||
|
||||
query := map[string]string{"db": "foo", "q": "select event from logs"}
|
||||
status, body := MustHTTP("GET", s.URL+`/query`, query, nil, "")
|
||||
if status != http.StatusOK {
|
||||
t.Logf("query %s\n", query)
|
||||
t.Log(body)
|
||||
t.Errorf("unexpected status: %d", status)
|
||||
}
|
||||
|
||||
r := &influxdb.Results{}
|
||||
if err := json.Unmarshal([]byte(body), r); err != nil {
|
||||
t.Logf("query : %s\n", query)
|
||||
t.Log(body)
|
||||
t.Error(err)
|
||||
}
|
||||
if len(r.Results) != 1 {
|
||||
t.Fatalf("unexpected results count")
|
||||
}
|
||||
result := r.Results[0]
|
||||
if len(result.Series) != 1 {
|
||||
t.Fatalf("unexpected row count, expected: %d, actual: %d", 1, len(result.Series))
|
||||
}
|
||||
if result.Series[0].Values[0][1] != "disk full" {
|
||||
t.Fatalf("unexpected string value, actual: %s", result.Series[0].Values[0][1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_serveWriteSeriesBoolValues(t *testing.T) {
|
||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||
srvr.CreateDatabase("foo")
|
||||
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
|
||||
srvr.SetDefaultRetentionPolicy("foo", "bar")
|
||||
|
||||
s := NewHTTPServer(srvr)
|
||||
defer s.Close()
|
||||
|
||||
status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "disk", "tags": {"host": "server01"},"fields": {"full": false}}]}`)
|
||||
if status != http.StatusOK {
|
||||
t.Fatalf("unexpected status: %d", status)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
|
||||
|
||||
srvr.Restart() // Ensure data is queryable across restarts.
|
||||
|
||||
query := map[string]string{"db": "foo", "q": "select full from disk"}
|
||||
status, body := MustHTTP("GET", s.URL+`/query`, query, nil, "")
|
||||
if status != http.StatusOK {
|
||||
t.Logf("query %s\n", query)
|
||||
t.Log(body)
|
||||
t.Errorf("unexpected status: %d", status)
|
||||
}
|
||||
|
||||
r := &influxdb.Results{}
|
||||
if err := json.Unmarshal([]byte(body), r); err != nil {
|
||||
t.Logf("query : %s\n", query)
|
||||
t.Log(body)
|
||||
t.Error(err)
|
||||
}
|
||||
if len(r.Results) != 1 {
|
||||
t.Fatalf("unexpected results count")
|
||||
}
|
||||
result := r.Results[0]
|
||||
if len(result.Series) != 1 {
|
||||
t.Fatalf("unexpected row count, expected: %d, actual: %d", 1, len(result.Series))
|
||||
}
|
||||
if result.Series[0].Values[0][1] != false {
|
||||
t.Fatalf("unexpected string value, actual: %s", result.Series[0].Values[0][1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_serveWriteSeriesBatch(t *testing.T) {
|
||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||
srvr.CreateDatabase("foo")
|
||||
|
|
Loading…
Reference in New Issue