summaryrefslogtreecommitdiffstats
path: root/gstatsd/service_test.py
diff options
context:
space:
mode:
authorPatrick Hensley <spaceboy@indirect.com>2011-06-30 14:22:50 (GMT)
committerPatrick Hensley <spaceboy@indirect.com>2011-06-30 21:20:53 (GMT)
commit2b8948ae0a92ab447ae78ded8e7e1eebe6c4d3fc (patch)
treedcdc419ab690c1399e612866dcdfa6c7e5a4d0b4 /gstatsd/service_test.py
parente83d53f948df502b14119e4faf6dac88806c21ba (diff)
downloadgstatsd-2b8948ae0a92ab447ae78ded8e7e1eebe6c4d3fc.zip
gstatsd-2b8948ae0a92ab447ae78ded8e7e1eebe6c4d3fc.tar.gz
gstatsd-2b8948ae0a92ab447ae78ded8e7e1eebe6c4d3fc.tar.bz2
Release 0.40.4
* Generalized the stats formatting and delivery into GraphiteSink class. Move the stats tables (timers/counts) into a Stats class. * Updated README files, added script to derive README.txt from README.md, changed '-d / --dest' option to '-s / --sink'.
Diffstat (limited to 'gstatsd/service_test.py')
-rw-r--r--gstatsd/service_test.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/gstatsd/service_test.py b/gstatsd/service_test.py
index 1b6bc2d..6f46ff8 100644
--- a/gstatsd/service_test.py
+++ b/gstatsd/service_test.py
@@ -9,54 +9,56 @@ from gstatsd import service
class StatsServiceTest(unittest.TestCase):
def setUp(self):
- args = (':8125', [':9100'], 5, 90, 0)
+ args = (':8125', [':2003'], 5, 90, 0)
self.svc = service.StatsDaemon(*args)
+ self.stats = self.svc._stats
def test_construct(self):
- svc = service.StatsDaemon('8125', ['9100'], 5, 90, 0)
+ svc = service.StatsDaemon('8125', ['2003'], 5, 90, 0)
+ stats = svc._stats
self.assertEquals(svc._bindaddr, ('', 8125))
self.assertEquals(svc._interval, 5.0)
- self.assertEquals(svc._percent, 90.0)
self.assertEquals(svc._debug, 0)
- self.assertEquals(svc._targets[0], (svc._send_graphite, ('', 9100)))
+ self.assertEquals(stats.percent, 90.0)
+ self.assertEquals(svc._sink._hosts, [('', 2003)])
- svc = service.StatsDaemon('bar:8125', ['foo:9100'], 5, 90, 1)
+ svc = service.StatsDaemon('bar:8125', ['foo:2003'], 5, 90, 1)
self.assertEquals(svc._bindaddr, ('bar', 8125))
- self.assertEquals(svc._targets[0], (svc._send_graphite, ('foo', 9100)))
+ self.assertEquals(svc._sink._hosts, [('foo', 2003)])
self.assertEquals(svc._debug, 1)
def test_backend(self):
service.StatsDaemon._send_foo = lambda self, x, y: None
- svc = service.StatsDaemon('8125', ['foo:bar:9100'], 5, 90, 0)
- self.assertEquals(svc._targets[0], (svc._send_foo, ('bar', 9100)))
+ svc = service.StatsDaemon('8125', ['bar:2003'], 5, 90, 0)
+ self.assertEquals(svc._sink._hosts, [('bar', 2003)])
def test_counters(self):
pkt = 'foo:1|c'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._counts, {'foo': 1})
+ self.assertEquals(self.stats.counts, {'foo': 1})
self.svc._process(pkt, None)
- self.assertEquals(self.svc._counts, {'foo': 2})
+ self.assertEquals(self.stats.counts, {'foo': 2})
pkt = 'foo:-1|c'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._counts, {'foo': 1})
+ self.assertEquals(self.stats.counts, {'foo': 1})
def test_counters_sampled(self):
pkt = 'foo:1|c|@.5'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._counts, {'foo': 2})
+ self.assertEquals(self.stats.counts, {'foo': 2})
def test_timers(self):
pkt = 'foo:20|ms'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._timers, {'foo': [20.0]})
+ self.assertEquals(self.stats.timers, {'foo': [20.0]})
pkt = 'foo:10|ms'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._timers, {'foo': [20.0, 10.0]})
+ self.assertEquals(self.stats.timers, {'foo': [20.0, 10.0]})
def test_key_sanitize(self):
pkt = '\t\n#! foo . bar \0 ^:1|c'
self.svc._process(pkt, None)
- self.assertEquals(self.svc._counts, {'foo.bar': 1})
+ self.assertEquals(self.stats.counts, {'foo.bar': 1})
def main():