RabbitMQ: advance thru the list of brokers on reconnect

In RabbitMQ implementation, when using multiple rabbit_hosts, we don't want to
immediately retry failed connection for the same failed broker. This was not
the case in existing implementation though, where we've always attempted to
reconnect starting from the first broker in the list of candidates. So if the
first broker failed, we initiated reconnect to the same failed broker.

This change makes reconnect() implementation to select the next broker in the
list. This also means that non-failure reconnect attempts will also switch the
current broker. All in all, users should not rely on any particular order to
use brokers from the list, so this should not constitute an issue.

This is a backport of 71c6866471d628b207d7c5b84bfd37cc9fed0898 from
oslo.messaging.

Change-Id: I67923cb024bbd143edc8edccf35b9b400df31eb3
Partial-Bug: 1261631
Make table utf-8 charset checking be optional for DB migration

Add an option to the migration db_sync call to allow a project to
disable the check for utf8 encoding on all tables.  This allows the
project to fix problems automatically via a migration, which
otherwise would not be possible because the utf8 check would stop
them from running migrations.

Change-Id: I7f271d846141ac72dde3fb0d12159b125018eb2c
Closes-bug: #1279000
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
Revert setting oslo-incubator logs to INFO

Originally oslo-incubator logs were set to INFO because we wanted to
treat oslo-incubator like a library, and we don't want debug logs on for
every single library that we use. In particular the lockutils module has
verbose logs. But this had the side effect of disabling the
processutils debug logs, which are very useful at letting you know when
a something is being shelled out to.

In the short term don't default oslo-incubator logs to INFO. And in the
long run we need to revisit how we set log levels, but that will have to
wait until Juno.

This is a partial revert of: Ia12c003dae196e2220a5f6ea768758a75f2ede23

Change-Id: Icc61964c6a2b002ac1c8566f174e6a5230674c75
Merge "Make table utf-8 charset checking be optional for DB migration"
Don't store the request ID value in middleware as class variable

The original version of the request_id middleware generates a request ID during
process_request() and stores the value in a variable, so it can be attached as
header in process_request(). This is pretty dangerous, since subsequent
requests will overwrite this value, and the wrong request ID may be attached to
some responses. This is particularly apparent when requests arrive in parallel.

This change replaces process_request() and process_response() with an override
of __call__(). This allows the generated req_id to be used in the response
header without needing to save it as a class-level variable.

Change-Id: I498859140ba113412c9d95d09f0c4c6b8650749c
Closes-bug: #1289696
Merge "Revert setting oslo-incubator logs to INFO"
Adds test condition in test_periodic

There was no test case that covers a periodic_task not being called
without "run_immediately" set. This patch also mocks time.time() due
to the time gap between when the sciprts are loaded and when the tests
are actually executed.

Merged test_is_called and test_called_twice since the two cases overlap.

Change-Id: I3385c8d313d58cbaad5c21347b2b7ce4a8aae6a7
Related-Bug: #1275151
Related-Bug: #1275152
Qpid: advance thru the list of brokers on reconnect

In Qpid implementation, when using multiple qpid_hosts, we don't want to
immediately retry failed connection for the same failed broker. This was not
the case in existing implementation though, where we've always attempted to
reconnect starting from the first broker in the list of candidates. So if the
first broker failed, we initiated reconnect to the same failed broker.

This change makes reconnect() implementation to select the next broker in the
list. This also means that non-failure reconnect attempts will also switch the
current broker. All in all, users should not rely on any particular order to
use brokers from the list, so this should not constitute an issue.

This is a backport of the following changes from oslo.messaging:
* I257c2ad6d7ebead356c0239134340975da6dbc07 (code change)
* I32e20c0e747e6489dab4b0358d422b8a9c6b982e (unit test).

Change-Id: Ia148baa6e1ec632789ac3621c85173c2c16f3918
Partial-Bug: 1261631
Merge "Don't store the request ID value in middleware as class variable"
Merge "RabbitMQ: advance thru the list of brokers on reconnect"
Merge "Qpid: advance thru the list of brokers on reconnect"
Merge "Adds test condition in test_periodic"