~landscape/charms/trusty/glance/trunk

« back to all changes in this revision

Viewing changes to unit_tests/test_glance_utils.py

  • Committer: James Page
  • Date: 2014-03-13 16:38:06 UTC
  • mfrom: (43.4.5 glance)
  • Revision ID: james.page@canonical.com-20140313163806-xnh1nmtzw393s0wm
[yolanda.robla,r=james-page] Managed ceph.conf using alternatives to support co-install with glance, nova and ceph

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from mock import patch, call, MagicMock
2
2
 
3
3
from collections import OrderedDict
 
4
import os
4
5
 
 
6
os.environ['JUJU_UNIT_NAME'] = 'glance'
5
7
import glance_utils as utils
6
8
 
7
9
from test_utils import (
21
23
    'templating',
22
24
    'apt_update',
23
25
    'apt_install',
24
 
    'mkdir'
 
26
    'mkdir',
 
27
    'service_name',
 
28
    'install_alternative'
25
29
]
26
30
 
27
31
 
33
37
 
34
38
    @patch('subprocess.check_call')
35
39
    def test_migrate_database(self, check_call):
36
 
        '''It migrates database with cinder-manage'''
 
40
        "It migrates database with cinder-manage"
37
41
        utils.migrate_database()
38
42
        check_call.assert_called_with(['glance-manage', 'db_sync'])
39
43
 
89
93
 
90
94
    @patch('os.path.exists')
91
95
    def test_register_configs_ceph(self, exists):
92
 
        exists.return_value = False
 
96
        exists.return_value = True
93
97
        self.get_os_codename_package.return_value = 'grizzly'
94
98
        self.relation_ids.return_value = ['ceph:0']
 
99
        self.service_name.return_value = 'glance'
95
100
        configs = utils.register_configs()
96
101
        calls = []
97
102
        for conf in [utils.GLANCE_REGISTRY_CONF,
99
104
                     utils.GLANCE_API_PASTE_INI,
100
105
                     utils.GLANCE_REGISTRY_PASTE_INI,
101
106
                     utils.HAPROXY_CONF,
102
 
                     utils.HTTPS_APACHE_CONF,
103
 
                     utils.CEPH_CONF]:
 
107
                     utils.ceph_config_file()]:
104
108
            calls.append(
105
109
                call(conf,
106
110
                     utils.CONFIG_FILES[conf]['hook_contexts'])
109
113
        self.mkdir.assert_called_with('/etc/ceph')
110
114
 
111
115
    def test_restart_map(self):
 
116
        self.service_name.return_value = 'glance'
 
117
 
112
118
        ex_map = OrderedDict([
113
119
            (utils.GLANCE_REGISTRY_CONF, ['glance-registry']),
114
120
            (utils.GLANCE_API_CONF, ['glance-api']),
115
121
            (utils.GLANCE_API_PASTE_INI, ['glance-api']),
116
122
            (utils.GLANCE_REGISTRY_PASTE_INI, ['glance-registry']),
117
 
            (utils.CEPH_CONF, ['glance-api', 'glance-registry']),
 
123
            (utils.ceph_config_file(), ['glance-api', 'glance-registry']),
118
124
            (utils.HAPROXY_CONF, ['haproxy']),
119
125
            (utils.HTTPS_APACHE_CONF, ['apache2']),
120
126
            (utils.HTTPS_APACHE_24_CONF, ['apache2'])