Allow BaseTestCase use a different conf object

The new messaging work will register options like rpc_backend and, since
the existing RPC API registers those options with CONF, we need to run
the messaging tests with a different ConfigOpts object.

It's actually probably pretty sane for all unit tests to use a per-test
ConfigOpts object rather than cfg.CONF anyway.

The kombu and zmq tests have an issue with this where they rely on being
able to call self.config() before the base class setUp() is called.
Fixing this properly is a little tricky, so for now, initialize
self.conf early to cfg.CONF just for these tests.

Change-Id: I7b2e3db7c21c511f3ab16ac866e0cc80846cbd80
Add lockutils.check_for_lock()

Add a function that can be passed to messaging.RPCClient as a lock
check callback so that oslo.messaging doesn't depend on eventlet's
corolocal.

A debug_check_for_lock() variant is available which only applies this
check when debugging is enabled.

Change-Id: Id9013ac2d05e8dd29ebe61b60cbb313deeb05f16
Initial framework

Change-Id: I183a6fd41a1971158f237bc94666818fcb136765
Co-authored-by: Doug Hellmann <doug.hellmann@dreamhost.com>
Co-authored-by: Flaper Fesp <flaper87@gmail.com>
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.

Change-Id: Ib4b9e33e870c7706f6cc6233296a3503ffa16241
Support capping message versions in the client.

When doing a rolling upgrade, we need to be able to tell all rpc clients
to hold off on sending newer versions of messages until all nodes
understand the new message version.  This patch adds the oslo component
of this.

It's quite simple.  The rpc proxy just stores the version cap and will
raise an exception if code ever tries to send a message that exceeds
this cap.

Allowing the cap to be configured and generating different types of
messages based on the configured value is the hard part here, but that
is left up to the project using the rpc library.

Implements blueprint rpc-version-control.
Add generic serialization support

Copy across Dan Smith's work in commit 93ee6e3.

Change-Id: Id3e500d40e34abb386db878a6a6d457f13521676
Implement a fake driver

A bunch of FIXMEs in here, but it seems like a good start.

Note that this differs from the original fake driver. Rather than the
driver consuming each message in a greenthread, we leave it up to the
choice of executor to determine how the consumer is run in parallel to
the client and we use thread-safe queues to pass the messages and
replies back and forth. The main reason for this is that we don't want
the driver explicitly depending on eventlet.

Change-Id: Id52e12be93c95b779695f62411f02f43d8480e4e
Add parse_url to _utils.

The patch adds parse_url to _utils as an attempt to find a common url
format that satisfies most drivers needs. The code isn't definitive but
instead the beginning for further discussions. Current code parses
transport urls like this:

qpid://test/test
{'exchange': 'test',
 'hosts': [{'host': 'test', 'password': '', 'username': ''}],
 'parameters': {},
 'transport': 'qpid'}

qpid://test:port/test
{'exchange': 'test',
 'hosts': [{'host': 'test:port', 'password': '', 'username': ''}],
 'parameters': {},
 'transport': 'qpid'}

qpid://username:password@test:port/test
{'exchange': 'test',
 'hosts': [{'host': 'test:port',
            'password': 'password',
            'username': 'username'}],
 'parameters': {},
 'transport': 'qpid'}

qpid://username:password@test:port
{'exchange': None,
 'hosts': [{'host': 'test:port',
            'password': 'password',
            'username': 'username'}],
 'parameters': {},
 'transport': 'qpid'}

qpid://username:password@test:port,test2:port2/test
{'exchange': 'test',
 'hosts': [{'host': 'test:port',
            'password': 'password',
            'username': 'username'},
           {'host': 'test2:port2',
            'password': 'password',
            'username': 'username'}],
 'parameters': {},
 'transport': 'qpid'}

qpid://username:password@test:port,:@test2:port2/test
{'exchange': 'test',
 'hosts': [{'host': 'test:port',
            'password': 'password',
            'username': 'username'},
           {'host': 'test2:port2', 'password': '', 'username': ''}],
 'parameters': {},
 'transport': 'qpid'}

qpid://username:password@test:port,:@test2:port2/test?option=value
{'exchange': 'test',
 'hosts': [{'host': 'test:port',
            'password': 'password',
            'username': 'username'},
           {'host': 'test2:port2', 'password': '', 'username': ''}],
 'parameters': {'option': ['value']},
 'transport': 'qpid'}

Change-Id: I890a83add44082f0945a01b2c2313f91ce8cea59
First cut at the notifier API

See:

  https://wiki.openstack.org/wiki/Oslo/Messaging#Emitting_Notifications

Change-Id: Icbc16c8b089158e398acebaac3c599fe529981b7
Co-authored-by: Doug Hellmann <doug.hellmann@dreamhost.com>
Unit tests

Change-Id: I6cbec6fe126b9f49c55dafb35c5ae78591a3608b
Add some notes and test code

Change-Id: I927d3131ff0d0edb7d126399cb028e4c69142836