Skip to content

Commit

Permalink
add a graphite listener test
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshahid committed Mar 24, 2014
1 parent 5378787 commit ced0078
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/integration/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
. "launchpad.net/gocheck"
"net"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ced0078

Please sign in to comment.