add a graphite listener test

pull/336/head
John Shahid 2014-03-24 12:18:51 -04:00
parent 5378787c6d
commit ced0078d6c
1 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
. "launchpad.net/gocheck"
"net"
"net/http"
"net/url"
"os"
@ -517,6 +518,26 @@ func (self *ServerSuite) TestGroupByDay(c *C) {
c.Assert(series.GetValueForPointAndColumn(1, "count", c).(float64), Equals, float64(1))
}
func (self *ServerSuite) TestGraphiteInterface(c *C) {
conn, err := net.Dial("tcp", "localhost:60513")
c.Assert(err, IsNil)
now := time.Now().UTC().Truncate(time.Minute)
data := fmt.Sprintf("some_metric 100 %d\nsome_metric 200.5 %d\n", now.Add(-time.Minute).Unix(), now.Unix())
_, err = conn.Write([]byte(data))
c.Assert(err, IsNil)
time.Sleep(time.Second)
collection := self.serverProcesses[0].QueryWithUsername("graphite_db", "select * from some_metric", false, c, "root", "root")
c.Assert(collection.Members, HasLen, 1)
series := collection.GetSeries("some_metric", c)
c.Assert(series.Points, HasLen, 2)
c.Assert(series.GetValueForPointAndColumn(0, "value", c).(float64), Equals, float64(200.5))
c.Assert(series.GetValueForPointAndColumn(1, "value", c).(float64), Equals, float64(100))
}
func (self *ServerSuite) TestLimitQueryOnSingleShard(c *C) {
data := `[{"points": [[4], [10], [5]], "name": "test_limit_query_single_shard", "columns": ["value"]}]`
self.serverProcesses[0].Post("/db/test_rep/series?u=paul&p=pass", data, c)