94 Commits

Author SHA1 Message Date
Mark McLoughlin
dd4b8bd672 Call wait() in server tests
Just for the sake of the coverage report.
2013-06-15 21:22:10 +01:00
Mark McLoughlin
0fc785267f Add docstrings for base executor class
Avoiding spurious missed lines in coverage report.
2013-06-15 21:20:26 +01:00
Mark McLoughlin
de88d62998 Remove a fixed fixme 2013-06-15 21:19:05 +01:00
Mark McLoughlin
54f01ade9e Add a client call timeout test 2013-06-15 21:18:01 +01:00
Mark McLoughlin
1ab3b83f43 Don't raise a driver-specific error on send
Similar to doing listen() on the server side, if the driver throws an
exception when we do a cast() or call() we should translate it into
a transport-agnostic exception.
2013-06-15 19:24:32 +01:00
Mark McLoughlin
2be7df70b0 Add some docstrings to driver base
Eliminates spurious missed lines from coverage report.
2013-06-15 19:13:45 +01:00
Mark McLoughlin
2eda85e3ba Test a bunch more RPC server scenarios 2013-06-15 19:05:44 +01:00
Mark McLoughlin
8a8685b62f Make it possible to call prepare() on call context
Found it's quite easy to get into doing e.g.

  client = RPCClient(...)
  client = client.prepare(topic='foo')
  client = client.prepare(server='bar')
2013-06-15 18:56:15 +01:00
Mark McLoughlin
978d19c256 Rework how queues get created in fake driver
Currently, if there are no servers listening on a topic then a message
to that topic just gets dropped by the fake driver.

This makes the tests intermittently fail if the server takes longer to
start.

Turn things on their head so that the client always creates the queues
on the exchange so that messages can get queued up even if there is no
server listening.

Now we also need to delete the "duplicate server on topic" test - it's
actually fine to have multiple servers listening on the one topic.
2013-06-15 18:56:11 +01:00
Mark McLoughlin
8bf3c862b3 Use testscenarios
Now that we're using testr rather than nose, we can actually use
testscenarios.

Nice diffstat ... 474 lines removed :)
2013-06-15 11:12:47 +01:00
Mark McLoughlin
cbfb1452a4 Move files to new locations for oslo.messaging 2013-06-15 08:43:54 +01:00
Mark McLoughlin
be649d1d74 Import stuff from oslo-incubator 2013-06-15 08:43:54 +01:00
Mark McLoughlin
b5c41bba00 Add oslo.messaging project infrastructure 2013-06-15 08:43:50 +01:00
Mark McLoughlin
50f5f3b925 Add some RPC server tests
These actually test the blocking executor and fake driver too.
2013-06-15 08:26:34 +01:00
Mark McLoughlin
a32e0b42a5 More gracefully handle "no listeners" in fake driver 2013-06-14 15:18:56 +01:00
Mark McLoughlin
badb0fa4e6 Better error handling in server.start()
Transport drivers can raise transport driver specific exceptions
in listen(). Catch such exceptions and wrap them in a ServerListenError
which callers to start() can explicitly handle.
2013-06-14 14:45:40 +01:00
Mark McLoughlin
f0f3d4b5f2 Re-work server API to eliminate server subclasses
This is something I think Doug has been trying to tell me to do from the
start :-)

The main idea is to remove all the MessageHandlingServer subclasses and,
instead, if you want a server which is hooked up with the RPC dispatcher
you just use this convenience function:

  server = rpc_server.get_rpc_server(transport, target, endpoints)

This means the dispatcher interface is now part of the public API, but
that should be fine since it's very simple - it's a callable that takes
a request context and message.

However, we also need to be able to construct a MessageHandlingServer
with a specific executor. By having an executor_cls parameter to the
constructor as part of the public API, we'd be exposing the executor
interface which is quite likely to change. Instead - and this seems
obvious in retrospect - just use stevedore to load executors and allow
them to be requested by name:

  server = rpc_server.get_rpc_server(transport, target, endpoints,
                                     executor='eventlet')

This also means we can get rid of openstack.common.messaging.eventlet.
2013-06-14 11:41:49 +01:00
Mark McLoughlin
7a1c2730a0 Add license header to _executors/__init__.py
Bleh.
2013-06-14 09:44:13 +01:00
Mark McLoughlin
7ca7fed9ea Add RPCDispatcher tests 2013-06-12 07:42:35 +01:00
Mark McLoughlin
3e07f5b5bf Check for return value in client serializer test 2013-06-12 07:40:03 +01:00
Mark McLoughlin
f8648b36cf Add note about can_send_version() 2013-06-12 16:46:56 +01:00
Mark McLoughlin
8f3ab4fa09 More client unit tests 2013-06-11 14:38:39 +01:00
Mark McLoughlin
fbb20dda28 Make RPCClient.check_for_lock a callable
We really don't want to depend on openstack.common.local since it
implies a dependency on eventlet.corolocal.

Instead, make the check_for_lock parameter a callable which is given the
ConfigOpts object and returns a list of held locks. To hook it up to
lockutils, just do:

  client = messaging.RPCClient(transport, target,
                               check_for_lock=lockutils.check_for_lock)

Although you probably want to use lockutils.debug_check_for_lock() which
only does the check if debugging is enabled.
2013-06-11 21:39:26 +01:00
Mark McLoughlin
d80b8fe683 Apply version cap check when casting
We were only applying it when calling.
2013-06-11 16:44:16 +01:00
Mark McLoughlin
5972e8c16f Make RPCVersionCapError extend base exception 2013-06-11 12:22:21 +01:00
Mark McLoughlin
08744d849a Remove a bogus param from client.prepare() docs 2013-06-11 07:26:19 +01:00
Mark McLoughlin
0da344d8fc pep8 fixes for serializer code 2013-06-10 15:19:20 +01:00
Mark McLoughlin
2f1ef1ffe3 Simple RPCClient test 2013-06-10 12:07:15 +01:00
Mark McLoughlin
62dcede6b6 Unit tests 2013-06-09 14:46:40 +01:00
Mark McLoughlin
95119398e2 Move some stuff into doc/
This won't end up in the final patch set, just leave here for now. Also
makes nose ignore the test code.
2013-06-09 14:45:50 +01:00
Mark McLoughlin
6929a72987 Implement Target.__eq__()
Needed for unit tests, but probably useful for other cases too.
2013-06-10 12:04:13 +01:00
Mark McLoughlin
79a10f26ee Fix bug in exchange_from_url()
Needs testing obviously :)
2013-06-10 14:30:52 +01:00
Mark McLoughlin
a0feafa9a7 pep8 fixes for fake driver 2013-06-10 14:31:31 +01:00
Mark McLoughlin
1e61c02742 Make utils.parse_url() docstring pep8 compliant 2013-06-10 14:28:50 +01:00
Mark McLoughlin
2ba5a6a1be Don't translate exceptions
All our exceptions so far don't seem to be messages we ever
intentionally want shown to a user.
2013-06-10 14:30:05 +01:00
Mark McLoughlin
23c566e3e2 Misc pep8 fixes 2013-06-10 14:46:09 +01:00
Mark McLoughlin
81e8dc9033 pep8 fixes for toplevel package
Otherwise we get e.g.

  F401 'RPCClient' imported but unused
2013-06-10 14:44:13 +01:00
Mark McLoughlin
ee0e546150 Some error handling improvements 2013-06-10 10:34:52 +01:00
Mark McLoughlin
20f19d1c70 Recommend wrapping the client class rather than subclassing
Based on Doug's comments in:

  https://github.com/markmc/oslo-incubator/pull/6
2013-06-07 14:36:16 +01:00
Mark McLoughlin
b2d6dcd2ef Document how to use RPCClient directly 2013-06-07 14:29:51 +01:00
Mark McLoughlin
f67c090277 Document the public RPC API
I think I've covered everything that's public, which actually turns out
not to be a whole lot.

Still need to document the notifications API.
2013-06-07 11:10:24 +01:00
Mark McLoughlin
e6a237d766 Fix defaults for client.prepare() args
None is a legitimate value to pass in for any of these args, so use a
marker object to distinguish between None and "no value supplied".
2013-06-07 14:18:01 +01:00
Mark McLoughlin
5d34b37109 Fix client.cast() typo 2013-06-07 14:17:06 +01:00
Mark McLoughlin
b928fb64e0 Fix version_cap typo 2013-06-07 14:15:35 +01:00
Mark McLoughlin
69233f8b65 Allow all target attributes in client.prepare()
There's really no reason not to - you could have a single client object
invoking methods on a variety of different targets so long as they're
all available via the same transport.
2013-06-07 12:38:41 +01:00
Mark McLoughlin
c2c2e17f25 Expose Serializer from top-level namespace
I guess the idea is that users of the API shouldn't have to import
specific modules other than I/O framework specific modules.
2013-06-07 11:29:34 +01:00
Mark McLoughlin
7cf7b386c8 Allow specifying a serializer when creating a server
Since the dispatcher class isn't public, we need to allow this to be passed via
the server constructor.
2013-06-07 11:05:22 +01:00
Mark McLoughlin
65d985053c Make endpoint.target optional
If an endpoint has no target set, or if it is set to None, just act
like the target is Target(namespace=None, version='1.0')

Also, refactor the dispatcher's inspection of endpoints a little.
2013-06-07 10:49:37 +01:00
Mark McLoughlin
5b654345c8 Dispatch methods in their own greenthreads
This mimics what we do with amqp.ProxyCallback.

It might be nice to have errors like "no such method" and "unspupported
version" raised before spawning a greenthread, but that would mean
either turning the dispatcher into a two step lookup/invoke interface or
having I/O framework specific dispatchers.
2013-06-07 07:59:30 +01:00
Mark McLoughlin
b44541e617 Make rpc.dispatcher private
This is just an implementation detail of the public EventletRPCServer
and BlockingRPCServer classes.

This is important because I'm not sure we've got the right separation
of concerns between executors and dispatchers yet:

  http://lists.openstack.org/pipermail/openstack-dev/2013-June/009934.html

  That implies that you need to pair a tulip-aware executor with a
  tulip-aware dispatcher. We'll probably need to do something similar for
  eventlet too.

I think we need the RPC dispatcher to just know about RPC specific stuff
and there's a single abstraction for I/O framework integration.
2013-06-07 07:09:49 +01:00