diff --git a/httpd/handler_test.go b/httpd/handler_test.go index 46944c4ca5..45484ecb26 100644 --- a/httpd/handler_test.go +++ b/httpd/handler_test.go @@ -1501,6 +1501,46 @@ func TestHandler_serveWriteSeriesWhereIntField(t *testing.T) { } } +func TestHandler_serveWriteSeriesWhereStringField(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 where event = 'nonsense'"} + 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) + } + if string(body) != `{"results":[{}]}` { + t.Fatalf("unexpected results, got %s", string(body)) + } + + query = map[string]string{"db": "foo", "q": "select event from logs where event = 'disk full'"} + 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) + } + if string(body) != `{"results":[{}]}` { + t.Fatalf("unexpected results, got %s", string(body)) + } +} + func TestHandler_serveWriteSeriesBatch(t *testing.T) { srvr := OpenAuthlessServer(NewMessagingClient()) srvr.CreateDatabase("foo")