summaryrefslogtreecommitdiffstats
path: root/gstatsd/service_test.py
diff options
context:
space:
mode:
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():