~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/test_sqlalchemy.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-02-22 09:27:29 UTC
  • mfrom: (1.1.68)
  • Revision ID: package-import@ubuntu.com-20130222092729-nn3gt8rf97uvts77
Tags: 2013.1.g3-0ubuntu1
[ Chuck Short ]
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.

[ Adam Gandelman ]
* debian/control: Fix typo (websocikfy -> websockify).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
# Copyright (c) 2012 Rackspace Hosting
3
 
# All Rights Reserved.
4
 
#
5
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
#    not use this file except in compliance with the License. You may obtain
7
 
#    a copy of the License at
8
 
#
9
 
#         http://www.apache.org/licenses/LICENSE-2.0
10
 
#
11
 
#    Unless required by applicable law or agreed to in writing, software
12
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
#    License for the specific language governing permissions and limitations
15
 
#    under the License.
16
 
 
17
 
"""Unit tests for SQLAlchemy specific code."""
18
 
 
19
 
from eventlet import db_pool
20
 
try:
21
 
    import MySQLdb
22
 
except ImportError:
23
 
    MySQLdb = None
24
 
 
25
 
from nova import context
26
 
from nova.db.sqlalchemy import session
27
 
from nova import test
28
 
 
29
 
 
30
 
class DbPoolTestCase(test.TestCase):
31
 
    def setUp(self):
32
 
        super(DbPoolTestCase, self).setUp()
33
 
        self.flags(sql_dbpool_enable=True)
34
 
        self.user_id = 'fake'
35
 
        self.project_id = 'fake'
36
 
        self.context = context.RequestContext(self.user_id, self.project_id)
37
 
        if not MySQLdb:
38
 
            self.skipTest("Unable to test due to lack of MySQLdb")
39
 
 
40
 
    def test_db_pool_option(self):
41
 
        self.flags(sql_idle_timeout=11, sql_min_pool_size=21,
42
 
                sql_max_pool_size=42)
43
 
 
44
 
        info = {}
45
 
 
46
 
        class FakeConnectionPool(db_pool.ConnectionPool):
47
 
            def __init__(self, mod_name, **kwargs):
48
 
                info['module'] = mod_name
49
 
                info['kwargs'] = kwargs
50
 
                super(FakeConnectionPool, self).__init__(mod_name,
51
 
                        **kwargs)
52
 
 
53
 
            def connect(self, *args, **kwargs):
54
 
                raise test.TestingException()
55
 
 
56
 
        self.stubs.Set(db_pool, 'ConnectionPool',
57
 
                FakeConnectionPool)
58
 
 
59
 
        sql_connection = 'mysql://user:pass@127.0.0.1/nova'
60
 
        self.assertRaises(test.TestingException, session.create_engine,
61
 
                sql_connection)
62
 
 
63
 
        self.assertEqual(info['module'], MySQLdb)
64
 
        self.assertEqual(info['kwargs']['max_idle'], 11)
65
 
        self.assertEqual(info['kwargs']['min_size'], 21)
66
 
        self.assertEqual(info['kwargs']['max_size'], 42)