libra/tests/test_lbstats.py
David Shrewsbury 3ec02bcdb1 Start of obtaining worker stats.
The worker now gets the bytes-in/bytes-out for the specified
protocol (http or tcp). For now, these values are only logged,
and then only in debug mode. Added a test for setting these
values in the new LBStatistics class.

Updated README for the 'socat' requirement and to mention that
the PID file directory must be writable by the user.

Change-Id: I79f218747255cba84b25c4a69d0b210c9d1dfee5
2012-11-12 16:51:57 -05:00

27 lines
736 B
Python

import unittest
from libra.common.lbstats import LBStatistics
class TestLBStatistics(unittest.TestCase):
def setUp(self):
self.stats = LBStatistics()
def tearDown(self):
pass
def testInitValues(self):
self.assertEquals(self.stats.bytes_out, 0)
self.assertEquals(self.stats.bytes_in, 0)
def testSetBytesIn(self):
self.stats.bytes_in = 99
self.assertEquals(self.stats.bytes_in, 99)
with self.assertRaises(TypeError):
self.stats.bytes_in = "NaN"
def testSetBytesOut(self):
self.stats.bytes_out = 100
self.assertEquals(self.stats.bytes_out, 100)
with self.assertRaises(TypeError):
self.stats.bytes_out = "NaN"