~matsubara/charms/trusty/keystone/bug-1417211

« back to all changes in this revision

Viewing changes to unit_tests/test_keystone_hooks.py

  • Committer: Liam Young
  • Date: 2015-01-23 09:20:29 UTC
  • mfrom: (109.1.1 keystone.fix-db-race)
  • Revision ID: liam.young@canonical.com-20150123092029-9catqct0ouxmaxcg
[hopem, r=gnuoy] Wait until DB ready before performing Keystone api ops.

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
        configs.write = MagicMock()
204
204
        hooks.pgsql_db_changed()
205
205
 
 
206
    @patch.object(hooks, 'is_db_ready')
206
207
    @patch('keystone_utils.log')
207
208
    @patch('keystone_utils.ensure_ssl_cert_master')
208
209
    @patch.object(hooks, 'CONFIGS')
209
210
    @patch.object(hooks, 'identity_changed')
210
211
    def test_db_changed_allowed(self, identity_changed, configs,
211
212
                                mock_ensure_ssl_cert_master,
212
 
                                mock_log):
 
213
                                mock_log, mock_is_db_ready):
 
214
        mock_is_db_ready.return_value = True
213
215
        mock_ensure_ssl_cert_master.return_value = False
214
216
        self.relation_ids.return_value = ['identity-service:0']
215
217
        self.related_units.return_value = ['unit/0']
223
225
            relation_id='identity-service:0',
224
226
            remote_unit='unit/0')
225
227
 
 
228
    @patch.object(hooks, 'is_db_ready')
226
229
    @patch('keystone_utils.log')
227
230
    @patch('keystone_utils.ensure_ssl_cert_master')
228
231
    @patch.object(hooks, 'CONFIGS')
229
232
    @patch.object(hooks, 'identity_changed')
230
233
    def test_db_changed_not_allowed(self, identity_changed, configs,
231
 
                                    mock_ensure_ssl_cert_master, mock_log):
 
234
                                    mock_ensure_ssl_cert_master, mock_log,
 
235
                                    mock_is_db_ready):
 
236
        mock_is_db_ready.return_value = False
232
237
        mock_ensure_ssl_cert_master.return_value = False
233
238
        self.relation_ids.return_value = ['identity-service:0']
234
239
        self.related_units.return_value = ['unit/0']
374
379
            remote_unit='unit/0')
375
380
        admin_relation_changed.assert_called_with('identity-service:0')
376
381
 
 
382
    @patch.object(hooks, 'is_db_ready')
377
383
    @patch('keystone_utils.log')
378
384
    @patch('keystone_utils.ensure_ssl_cert_master')
379
385
    @patch.object(hooks, 'hashlib')
380
386
    @patch.object(hooks, 'send_notifications')
381
387
    def test_identity_changed_leader(self, mock_send_notifications,
382
388
                                     mock_hashlib, mock_ensure_ssl_cert_master,
383
 
                                     mock_log):
 
389
                                     mock_log, mock_is_db_ready):
 
390
        mock_is_db_ready.return_value = True
384
391
        mock_ensure_ssl_cert_master.return_value = False
385
392
        hooks.identity_changed(
386
393
            relation_id='identity-service:0',