jenkins-bot has submitted this change and it was merged.
Change subject: Add stub LVSService object and two tests for
IdleConnectionMonitoringProtocol
......................................................................
Add stub LVSService object and two tests for IdleConnectionMonitoringProtocol
* Add a stub class for pybal.ipvs.LVSService to test.fixtures
* Add tests for IdleConnectionMonitoringProtocol.clientConnectionMade()
and .buildProtocol()
Change-Id: Ie5299f4df9708caec362cd71a8912183111dbf88
---
M pybal/test/fixtures.py
M pybal/test/test_monitors.py
2 files changed, 43 insertions(+), 2 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pybal/test/fixtures.py b/pybal/test/fixtures.py
index ededde4..1fe18e2 100644
--- a/pybal/test/fixtures.py
+++ b/pybal/test/fixtures.py
@@ -15,15 +15,19 @@
class ServerStub(object):
"""Test stub for `pybal.Server`."""
- def __init__(self, host, ip=None, weight=None, port=None):
+ def __init__(self, host, ip=None, port=None, weight=None, lvsservice=None):
self.host = host
self.ip = ip
self.weight = weight
self.port = port
+ self.lvsservice = lvsservice
self.ip4_addresses = set()
self.ip6_addresses = set()
if ip is not None:
(self.ip6_addresses if ':' in ip else self.ip4_addresses).add(ip)
+
+ def textStatus(self):
+ return '...'
def __hash__(self):
return hash((self.host, self.ip, self.weight, self.port))
@@ -44,6 +48,19 @@
self.reason = reason
+class StubLVSService(object):
+ """Test stub for `pybal.ipvs.LVSService`."""
+
+ def __init__(self, name, (protocol, ip, port, scheduler), configuration):
+ self.name = name
+ self.servers = set()
+ self.protocol = protocol
+ self.ip = ip
+ self.port = port
+ self.scheduler = scheduler
+ self.configuration = configuration
+
+
class PyBalTestCase(twisted.trial.unittest.TestCase):
"""Base class for PyBal test cases."""
@@ -51,8 +68,18 @@
# rather than the one provided by twisted.trial.unittest.
assertRaises = unittest.TestCase.assertRaises
+ name = 'test'
+ host = 'localhost'
+ ip = '127.0.0.1'
+ port = 80
+ scheduler = 'rr'
+ protocol = 'tcp'
+
def setUp(self):
self.coordinator = StubCoordinator()
self.config = pybal.util.ConfigDict()
- self.server = ServerStub(host='localhost', ip='127.0.0.1', port=80)
+ service_def = (self.protocol, self.ip, self.port, self.scheduler)
+ self.lvsservice = StubLVSService(self.name, service_def, self.config)
+ self.server = ServerStub(self.host, self.ip, self.port,
+ lvsservice=self.lvsservice)
self.reactor = twisted.test.proto_helpers.MemoryReactor()
diff --git a/pybal/test/test_monitors.py b/pybal/test/test_monitors.py
index 753d215..7d4b4c8 100644
--- a/pybal/test/test_monitors.py
+++ b/pybal/test/test_monitors.py
@@ -46,3 +46,17 @@
destination = connector.getDestination()
self.assertEquals((destination.host, destination.port),
(self.server.host, self.server.port))
+
+ def testClientConnectionMade(self):
+ """Test `IdleConnectionMonitoringProtocol.clientConnectionMade`."""
+ self.monitor.run()
+ self.monitor.up = False
+ self.monitor.clientConnectionMade()
+ self.assertTrue(self.monitor.up)
+
+ def testBuildProtocol(self):
+ """Test `IdleConnectionMonitoringProtocol.buildProtocol`."""
+ self.monitor.run()
+ self.monitor.up = False
+ self.monitor.buildProtocol(None)
+ self.assertTrue(self.monitor.up)
--
To view, visit https://gerrit.wikimedia.org/r/195318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5299f4df9708caec362cd71a8912183111dbf88
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits