neutron/quantum/tests/unit/nicira
Paul Michali 60c7607a91 Remove cfg option default value and check if missing
Currently, several plugins already check config options at __init__()
for validity and will exit, if the settings are incorrect. However,
most (all?) config option definitions have default values, so if the
option is missing, a valid, but maybe unexpected value will be used.
This is what occurred in the bug.

The proposed fix is to take a config option, sql_connection, which is
used by many plugins, and remove the default value. Then, at init
time, when the config option is used in configure_db(), a check is
made for the value. If the value is not set, a warning is logged and
the value is set to the default, for db/api.py. It is expected that
this will be the only module to consume this config option.

Added UT to check that log warning is issued. Also, changed the timing
so that the test takes 0.25 secs vs 12 secs. Removed UTs in two plugin
tests that checked the default value for sql_connection.

Other alternatives explored in previous patches, were to either
raise an exception, or mark this config option as "required". This
resulted in a large number of changes to tests, and required config
overrides in plugins that imported quantum.db.api, but did not use
sql_connection.

In order to keep this solution (of this log-hanging fruit) fix, the
proposed, simpler change is being made.

Some cleanup to the Cisco plugin test case was also made, so that
the mock was more in line with what production code does.

bug 1059923

Change-Id: I8c2a4e05231ac4e172d0dccece067e6fdb354341
2013-02-12 09:24:22 -05:00
..
etc L3 API support for nicira plugin 2013-02-11 05:19:04 -08:00
__init__.py Allow tox to run plugin specific unit tests 2012-08-24 14:40:29 -07:00
fake_nvpapiclient.py L3 API support for nicira plugin 2013-02-11 05:19:04 -08:00
test_defaults.py Remove cfg option default value and check if missing 2013-02-12 09:24:22 -05:00
test_nicira_plugin.py L3 API support for nicira plugin 2013-02-11 05:19:04 -08:00
test_nvp_api_common.py Allow tox to run plugin specific unit tests 2012-08-24 14:40:29 -07:00
test_nvp_api_request.py Allow tox to run plugin specific unit tests 2012-08-24 14:40:29 -07:00
test_nvp_api_request_eventlet.py Allow nvp_api to load balance requests 2013-01-08 00:39:32 -05:00