add test that covers series not existing in all buckets for drop series
parent
1f38c0865e
commit
c662c628d3
|
@ -1086,12 +1086,54 @@ func TestServer_DropSeries(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %s", results.Error())
|
||||
}
|
||||
|
||||
results = s.ExecuteQuery(MustParseQuery(`SHOW SERIES`), "foo", nil)
|
||||
if res := results.Results[0]; res.Err != nil {
|
||||
t.Fatalf("unexpected error: %s", res.Err)
|
||||
} else if len(res.Series) != 0 {
|
||||
t.Fatalf("unexpected row count: %d", len(res.Series))
|
||||
} else if s := mustMarshalJSON(res); s != `{}` {
|
||||
t.Fatalf("unexpected row(0): %s", s)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the server can drop a series from measurement.
|
||||
func TestServer_DropSeriesFromMeasurement(t *testing.T) {
|
||||
c := NewMessagingClient()
|
||||
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.
|
||||
tags := map[string]string{"host": "serverA", "region": "uswest"}
|
||||
index, err := s.WriteSeries("foo", "raw", []influxdb.Point{{Name: "cpu", Tags: tags, Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": float64(23.2)}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err = s.Sync(index); err != nil {
|
||||
t.Fatalf("sync error: %s", err)
|
||||
}
|
||||
tags = map[string]string{"host": "serverb", "region": "useast"}
|
||||
index, err = s.WriteSeries("foo", "raw", []influxdb.Point{{Name: "memory", Tags: tags, Timestamp: mustParseTime("2000-01-02T00:00:00Z"), Fields: map[string]interface{}{"value": float64(23465432423)}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err = s.Sync(index); err != nil {
|
||||
t.Fatalf("sync error: %s", err)
|
||||
}
|
||||
|
||||
// Drop series
|
||||
results := s.ExecuteQuery(MustParseQuery(`DROP SERIES FROM memory`), "foo", nil)
|
||||
if results.Error() != nil {
|
||||
t.Fatalf("unexpected error: %s", results.Error())
|
||||
}
|
||||
|
||||
results = s.ExecuteQuery(MustParseQuery(`SHOW SERIES`), "foo", nil)
|
||||
if res := results.Results[0]; res.Err != nil {
|
||||
t.Fatalf("unexpected error: %s", res.Err)
|
||||
} else if len(res.Series) != 1 {
|
||||
t.Fatalf("unexpected row count: %d", len(res.Series))
|
||||
} else if s := mustMarshalJSON(res); s != `{"series":[{"name":"cpu","columns":[]}]}` {
|
||||
} else if s := mustMarshalJSON(res); s != `{"series":[{"name":"cpu","columns":["host","region"],"values":[["serverA","uswest"]]}]}` {
|
||||
t.Fatalf("unexpected row(0): %s", s)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue