8ec8987c31
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
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
# Copyright (c) 2012 OpenStack, LLC.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import unittest
|
|
|
|
from quantum.openstack.common import cfg
|
|
#NOTE this import loads tests required options
|
|
from quantum.plugins.openvswitch.common import config
|
|
|
|
|
|
class ConfigurationTest(unittest.TestCase):
|
|
|
|
def test_defaults(self):
|
|
self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)
|
|
self.assertFalse(cfg.CONF.OVS.enable_tunneling)
|
|
self.assertEqual('br-tun', cfg.CONF.OVS.tunnel_bridge)
|
|
self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries)
|
|
self.assertEqual(2, cfg.CONF.DATABASE.reconnect_interval)
|
|
self.assertEqual(2, cfg.CONF.AGENT.polling_interval)
|
|
self.assertEqual('sudo', cfg.CONF.AGENT.root_helper)
|
|
self.assertEqual('local', cfg.CONF.OVS.tenant_network_type)
|
|
self.assertEqual(0, len(cfg.CONF.OVS.bridge_mappings))
|
|
self.assertEqual(0, len(cfg.CONF.OVS.network_vlan_ranges))
|
|
self.assertEqual(0, len(cfg.CONF.OVS.tunnel_id_ranges))
|