Queries for a measurement that doesn't exist should return a `200 OK`
parent
c53cd6b392
commit
56a712a8e3
|
@ -417,11 +417,17 @@ func isAuthorizationError(err error) bool {
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isMeasurementNotFoundError(err error) bool {
|
||||||
|
return (err.Error() == "measurement not found")
|
||||||
|
}
|
||||||
|
|
||||||
// httpResult writes a Results array to the client.
|
// httpResult writes a Results array to the client.
|
||||||
func httpResults(w http.ResponseWriter, results influxdb.Results, pretty bool) {
|
func httpResults(w http.ResponseWriter, results influxdb.Results, pretty bool) {
|
||||||
if results.Error() != nil {
|
if results.Error() != nil {
|
||||||
if isAuthorizationError(results.Error()) {
|
if isAuthorizationError(results.Error()) {
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
} else if isMeasurementNotFoundError(results.Error()) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,29 @@ func TestHandler_DropDatabase_NotFound(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHandler_SelectMeasurement_NotFound(t *testing.T) {
|
||||||
|
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||||
|
srvr.CreateDatabase("foo")
|
||||||
|
s := NewHTTPServer(srvr)
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
query := map[string]string{"q": "CREATE RETENTION POLICY bar ON foo DURATION 1h REPLICATION 1 DEFAULT"}
|
||||||
|
status, body := MustHTTP("GET", s.URL+`/query`, query, nil, "")
|
||||||
|
|
||||||
|
if status != http.StatusOK {
|
||||||
|
t.Fatalf("unexpected status: %d", status)
|
||||||
|
} else if body != `{"results":[{}]}` {
|
||||||
|
t.Fatalf("unexpected body: %s", body)
|
||||||
|
}
|
||||||
|
|
||||||
|
status, body = MustHTTP("GET", s.URL+`/query`, map[string]string{"q": "SELECT value FROM foobarbaz", "db": "foo"}, nil, "")
|
||||||
|
if status != http.StatusOK {
|
||||||
|
t.Fatalf("unexpected status: %d", status)
|
||||||
|
} else if body != `{"results":[{"error":"measurement not found"}]}` {
|
||||||
|
t.Fatalf("unexpected body: %s", body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestHandler_RetentionPolicies(t *testing.T) {
|
func TestHandler_RetentionPolicies(t *testing.T) {
|
||||||
srvr := OpenAuthlessServer(NewMessagingClient())
|
srvr := OpenAuthlessServer(NewMessagingClient())
|
||||||
srvr.CreateDatabase("foo")
|
srvr.CreateDatabase("foo")
|
||||||
|
|
Loading…
Reference in New Issue