~hopem/charms/trusty/cinder/lp1499643

« back to all changes in this revision

Viewing changes to unit_tests/test_cinder_hooks.py

  • Committer: billy.olsen at canonical
  • Date: 2015-08-31 20:26:18 UTC
  • mfrom: (109.1.4 next)
  • Revision ID: billy.olsen@canonical.com-20150831202618-fat3jvgssr4w587y
[xtrusia,r=billy-olsen] Restart cinder services if overwrite config
value changed to ensure that the change is properly reflected within the
service.

Closes-Bug: 1383801

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
 
148
148
    @patch.object(hooks, 'configure_https')
149
149
    @patch.object(hooks, 'git_install_requested')
150
 
    def test_config_changed(self, git_requested, conf_https):
 
150
    @patch.object(hooks, 'config_value_changed')
 
151
    def test_config_changed(self, config_val_changed,
 
152
                            git_requested, conf_https):
151
153
        'It writes out all config'
152
154
        git_requested.return_value = False
153
155
        self.openstack_upgrade_available.return_value = False
160
162
 
161
163
    @patch.object(hooks, 'configure_https')
162
164
    @patch.object(hooks, 'git_install_requested')
163
 
    def test_config_changed_block_devices(self, git_requested, conf_https):
 
165
    @patch.object(hooks, 'config_value_changed')
 
166
    def test_config_changed_block_devices(self, config_val_changed,
 
167
                                          git_requested, conf_https):
164
168
        'It writes out all config'
165
169
        git_requested.return_value = False
166
170
        self.openstack_upgrade_available.return_value = False
178
182
 
179
183
    @patch.object(hooks, 'configure_https')
180
184
    @patch.object(hooks, 'git_install_requested')
181
 
    def test_config_changed_uses_remove_missing_force(self, git_requested,
 
185
    @patch.object(hooks, 'config_value_changed')
 
186
    def test_config_changed_uses_remove_missing_force(self,
 
187
                                                      config_val_changed,
 
188
                                                      git_requested,
182
189
                                                      conf_https):
183
190
        'It uses the remove-missing-force config option'
184
191
        git_requested.return_value = False
193
200
 
194
201
    @patch.object(hooks, 'configure_https')
195
202
    @patch.object(hooks, 'git_install_requested')
196
 
    def test_config_changed_upgrade_available(self, git_requested, conf_https):
 
203
    @patch.object(hooks, 'config_value_changed')
 
204
    def test_config_changed_upgrade_available(self, config_val_changed,
 
205
                                              git_requested, conf_https):
197
206
        'It writes out all config with an available OS upgrade'
198
207
        git_requested.return_value = False
199
208
        self.openstack_upgrade_available.return_value = True
226
235
        self.assertFalse(self.do_openstack_upgrade.called)
227
236
        self.assertTrue(conf_https.called)
228
237
 
 
238
    @patch('charmhelpers.core.host.service')
 
239
    @patch.object(hooks, 'configure_https')
 
240
    @patch.object(hooks, 'git_install_requested')
 
241
    @patch.object(hooks, 'config_value_changed')
 
242
    def test_config_changed_overwrite_changed(self, config_val_changed,
 
243
                                              git_requested, conf_https,
 
244
                                              _services):
 
245
        'It uses the overwrite config option'
 
246
        git_requested.return_value = False
 
247
        self.openstack_upgrade_available.return_value = False
 
248
        config_val_changed.return_value = True
 
249
        hooks.hooks.execute(['hooks/config-changed'])
 
250
        self.assertTrue(self.CONFIGS.write_all.called)
 
251
        self.assertTrue(conf_https.called)
 
252
        self.configure_lvm_storage.assert_called_with(['sdb'],
 
253
                                                      'cinder-volumes',
 
254
                                                      False, False, False)
 
255
        self.service_restart.assert_called_with('cinder-volume')
 
256
 
229
257
    def test_db_changed(self):
230
258
        'It writes out cinder.conf on db changed'
231
259
        self.relation_get.return_value = 'cinder/0 cinder/1'