Commit c4297758 authored by Jim Fulton's avatar Jim Fulton

Made dynamic_server_ports.test more robust

parent 0e06dc44
...@@ -14,67 +14,46 @@ ZODB.notify. ...@@ -14,67 +14,46 @@ ZODB.notify.
Now, let's start a server and verify that we get a serving event: Now, let's start a server and verify that we get a serving event:
>>> import ZEO.StorageServer, ZODB.MappingStorage >>> import ZEO
>>> server = ZEO.StorageServer.StorageServer( >>> addr, stop = ZEO.server()
... ('127.0.0.1', 0), {'1': ZODB.MappingStorage.MappingStorage()})
>>> isinstance(last_event, ZEO.StorageServer.Serving) >>> isinstance(last_event, ZEO.StorageServer.Serving)
True True
>>> last_event.server is server
True
>>> last_event.address[0], last_event.address[1] > 0
('127.0.0.1', True)
If the host part pf the address passed to the constructor is not an >>> last_event.address == addr
empty string. then the server addr attribute is the same as the
address attribute of the event:
>>> server.addr == last_event.address
True True
Let's run the server in a thread, to make sure we can connect. >>> server = last_event.server
>>> server.addr == addr
True
>>> server.start_thread() Let's make sure we can connect.
>>> client = ZEO.client(last_event.address) >>> client = ZEO.client(last_event.address).close()
>>> client.is_connected()
True
If we close the server, we'll get a closed event: If we close the server, we'll get a closed event:
>>> server.close() >>> stop()
>>> isinstance(last_event, ZEO.StorageServer.Closed) >>> isinstance(last_event, ZEO.StorageServer.Closed)
True True
>>> last_event.server is server >>> last_event.server is server
True True
>>> wait_until(lambda : not client.is_connected(test=True))
>>> client.close()
If we pass an empty string as the host part of the server address, we If we pass an empty string as the host part of the server address, we
can't really assign a single address, so the server addr attribute is can't really assign a single address, so the server addr attribute is
left alone: left alone:
>>> server = ZEO.StorageServer.StorageServer( >>> addr, stop = ZEO.server(port=('', 0))
... ('', 0), {'1': ZODB.MappingStorage.MappingStorage()})
>>> isinstance(last_event, ZEO.StorageServer.Serving) >>> isinstance(last_event, ZEO.StorageServer.Serving)
True True
>>> last_event.server is server
True
>>> last_event.address[1] > 0 >>> last_event.address[1] > 0
True True
If the host part pf the address passed to the constructor is not an >>> last_event.server.addr
empty string. then the server addr attribute is the same as the
address attribute of the event:
>>> server.addr
('', 0) ('', 0)
>>> server.close() >>> stop()
The runzeo module provides some process support, including getting the The runzeo module provides some process support, including getting the
server configuration via a ZConfig configuration file. To spell a server configuration via a ZConfig configuration file. To spell a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment