[Checkins] SVN: zc.zkzeo/trunk/src/zc/zkzeo/ Register the host name from the ZEO address setting with ZooKeeper.
Jim Fulton
jim at zope.com
Mon Dec 12 23:06:44 UTC 2011
Log message for revision 123788:
Register the host name from the ZEO address setting with ZooKeeper.
(This is often an empty string, which ``zc.zk`` turns into the
fully-quelified domain name.)
Changed:
U zc.zkzeo/trunk/src/zc/zkzeo/README.txt
U zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py
U zc.zkzeo/trunk/src/zc/zkzeo/tests.py
-=-
Modified: zc.zkzeo/trunk/src/zc/zkzeo/README.txt
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/README.txt 2011-12-12 22:14:12 UTC (rev 123787)
+++ zc.zkzeo/trunk/src/zc/zkzeo/README.txt 2011-12-12 23:06:43 UTC (rev 123788)
@@ -323,9 +323,13 @@
Change History
==============
-0.1.3 (2011-12-12)
+0.2.0 (2011-12-12)
------------------
+- Register the host name from the ZEO address setting with ZooKeeper.
+ (This is often an empty string, which ``zc.zk`` turns into the
+ fully-quelified domain name.)
+
- Fixed bug in handling the monitor-server. The actuall address
setting was ignored.
Modified: zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py 2011-12-12 22:14:12 UTC (rev 123787)
+++ zc.zkzeo/trunk/src/zc/zkzeo/runzeo.py 2011-12-12 23:06:43 UTC (rev 123788)
@@ -31,7 +31,8 @@
if not self.options.zkpath:
return
- addr = self.server.dispatcher.socket.getsockname()
+ addr = (self.server.addr[0],
+ self.server.dispatcher.socket.getsockname()[1])
def register():
props = {}
@@ -44,7 +45,7 @@
maddr = maddr[0], 0
props['monitor'] = "%s:%s" % zc.monitor.start(maddr)
- self.__zk.register_server(self.options.zkpath, addr, **props)
+ self.__zk.register_server(self.options.zkpath, addr[:2], **props)
if self.__testing is not None:
self.__testing()
Modified: zc.zkzeo/trunk/src/zc/zkzeo/tests.py
===================================================================
--- zc.zkzeo/trunk/src/zc/zkzeo/tests.py 2011-12-12 22:14:12 UTC (rev 123787)
+++ zc.zkzeo/trunk/src/zc/zkzeo/tests.py 2011-12-12 23:06:43 UTC (rev 123788)
@@ -237,6 +237,33 @@
>>> _ = stop()
"""
+def using_empty_hosts_uses_fqdn():
+ """
+ >>> stop = zc.zkzeo.runzeo.test('''
+ ... <zeo>
+ ... address :
+ ... </zeo>
+ ...
+ ... <zookeeper>
+ ... connection zookeeper.example.com:2181
+ ... path /databases/demo
+ ... </zookeeper>
+ ...
+ ... <filestorage>
+ ... path demo.fs
+ ... </filestorage>
+ ... ''')
+
+ >>> zk = zc.zk.ZooKeeper('zookeeper.example.com:2181')
+ >>> zk.print_tree('/databases/demo')
+ /demo
+ /server.example.com:57978
+ pid = 8315
+
+ >>> zk.close()
+ >>> _ = stop()
+ """
+
def setUp(test):
zc.zk.testing.setUp(test, tree='/databases\n /demo\n')
test.globs['_server_loop'] = _server_loop = ZEO.zrpc.connection.server_loop
@@ -252,6 +279,11 @@
ZEO.zrpc.connection.server_loop = server_loop
+ cm = mock.patch('socket.getfqdn')
+ m = cm.__enter__()
+ m.side_effect = lambda : 'server.example.com'
+ test.globs['zc.zk.testing'].append(cm.__exit__)
+
def tearDown(test):
zc.zk.testing.tearDown(test)
ZEO.zrpc.connection.server_loop = test.globs['_server_loop']
@@ -264,6 +296,7 @@
checker = zope.testing.renormalizing.RENormalizing([
(re.compile(r'pid = \d+'), 'pid = PID'),
(re.compile(r'127.0.0.1:\d+'), '127.0.0.1:PORT'),
+ (re.compile(r'server.example.com:\d+'), 'server.example.com:PORT'),
(re.compile(r'localhost:\d+'), 'localhost:PORT'),
])
suite = unittest.TestSuite((
More information about the checkins
mailing list