def test_update_all_identity_relation_units(self, configs,
                                             is_db_initialized,
                                             identity_changed,
                                             identity_credentials_changed,
                                             admin_relation_changed,
                                             configure_https,
                                             is_expected_scale):
     """ Verify all identity relations are updated """
     is_db_initialized.return_value = True
     is_expected_scale.return_value = True
     self.relation_ids.return_value = ['identity-relation:0']
     self.related_units.return_value = ['unit/0']
     log_calls = [call('Firing identity_changed hook for all related '
                       'services.'),
                  call('Firing admin_relation_changed hook for all related '
                       'services.'),
                  call('Firing identity_credentials_changed hook for all '
                       'related services.')]
     hooks.update_all_identity_relation_units(check_db_ready=False)
     identity_changed.assert_called_with(
         relation_id='identity-relation:0',
         remote_unit='unit/0')
     identity_credentials_changed.assert_called_with(
         relation_id='identity-relation:0',
         remote_unit='unit/0')
     admin_relation_changed.assert_called_with('identity-relation:0')
     self.log.assert_has_calls(log_calls, any_order=True)
 def test_update_all_identity_relation_units(self, configs,
                                             is_db_initialized,
                                             identity_changed,
                                             identity_credentials_changed,
                                             admin_relation_changed):
     """ Verify all identity relations are updated """
     is_db_initialized.return_value = True
     self.relation_ids.return_value = ['identity-relation:0']
     self.related_units.return_value = ['unit/0']
     log_calls = [call('Firing identity_changed hook for all related '
                       'services.'),
                  call('Firing admin_relation_changed hook for all related '
                       'services.'),
                  call('Firing identity_credentials_changed hook for all '
                       'related services.')]
     hooks.update_all_identity_relation_units(check_db_ready=False)
     self.assertTrue(configs.write_all.called)
     identity_changed.assert_called_with(
         relation_id='identity-relation:0',
         remote_unit='unit/0')
     identity_credentials_changed.assert_called_with(
         relation_id='identity-relation:0',
         remote_unit='unit/0')
     admin_relation_changed.assert_called_with('identity-relation:0')
     self.log.assert_has_calls(log_calls, any_order=True)
 def test_update_all_db_not_ready(self, configs, configure_https):
     """ Verify update identity relations when DB is not ready """
     self.is_db_ready.return_value = False
     hooks.update_all_identity_relation_units(check_db_ready=True)
     self.assertTrue(self.is_db_ready.called)
     self.log.assert_called_with('Allowed_units list provided and this '
                                 'unit not present', level='INFO')
     self.assertFalse(self.relation_ids.called)
Beispiel #4
0
 def test_update_all_not_leader(self, configs, configure_https):
     """ Verify update identity relations when not the leader"""
     self.check_api_application_ready.return_value = (True, 'msg')
     self.is_elected_leader.return_value = False
     hooks.update_all_identity_relation_units()
     self.assertFalse(self.ensure_initial_admin.called)
     # Still updates relations
     self.assertTrue(self.relation_ids.called)
 def test_update_all_db_not_ready(self, configs, configure_https):
     """ Verify update identity relations when DB is not ready """
     self.is_db_ready.return_value = False
     hooks.update_all_identity_relation_units(check_db_ready=True)
     self.assertTrue(self.is_db_ready.called)
     self.log.assert_called_with('Allowed_units list provided and this '
                                 'unit not present', level='INFO')
     self.assertFalse(self.relation_ids.called)
 def test_update_all_leader(self, configs, is_db_initialized,
                            configure_https):
     """ Verify update identity relations when the leader"""
     self.is_elected_leader.return_value = True
     is_db_initialized.return_value = True
     hooks.update_all_identity_relation_units(check_db_ready=False)
     # Still updates relations
     self.assertTrue(self.relation_ids.called)
Beispiel #7
0
 def test_update_all_db_not_ready(self, configs, configure_https):
     """ Verify update identity relations when DB is not ready """
     self.check_api_application_ready.return_value = (False, 'msg')
     hooks.update_all_identity_relation_units()
     self.log.assert_called_with(
         ("Keystone charm unit not ready - deferring identity-relation "
          "updates"),
         level='INFO')
     self.assertFalse(self.relation_ids.called)
 def test_update_all_not_leader(self, configs, is_db_initialized):
     """ Verify update identity relations when not the leader"""
     self.is_elected_leader.return_value = False
     is_db_initialized.return_value = True
     hooks.update_all_identity_relation_units(check_db_ready=False)
     self.assertTrue(configs.write_all.called)
     self.assertFalse(self.ensure_initial_admin.called)
     # Still updates relations
     self.assertTrue(self.relation_ids.called)
 def test_update_all_leader(self, configs, is_db_initialized,
                            configure_https, is_expected_scale):
     """ Verify update identity relations when the leader"""
     self.is_elected_leader.return_value = True
     is_db_initialized.return_value = True
     is_expected_scale.return_value = True
     hooks.update_all_identity_relation_units(check_db_ready=False)
     # Still updates relations
     self.assertTrue(self.relation_ids.called)
 def test_update_all_db_not_initializd(self, configs, is_db_initialized,
                                       configure_https):
     """ Verify update identity relations when DB is not initialized """
     is_db_initialized.return_value = False
     hooks.update_all_identity_relation_units(check_db_ready=False)
     self.assertFalse(self.is_db_ready.called)
     self.log.assert_called_with('Database not yet initialised - '
                                 'deferring identity-relation updates',
                                 level='INFO')
     self.assertFalse(self.relation_ids.called)
 def test_update_all_db_not_initializd(self, configs, is_db_initialized):
     """ Verify update identity relations when DB is not initialized """
     is_db_initialized.return_value = False
     hooks.update_all_identity_relation_units(check_db_ready=False)
     self.assertTrue(configs.write_all.called)
     self.assertFalse(self.is_db_ready.called)
     self.log.assert_called_with('Database not yet initialised - '
                                 'deferring identity-relation updates',
                                 level='INFO')
     self.assertFalse(self.relation_ids.called)
Beispiel #12
0
 def test_update_all_leader(self, configs, configure_https):
     """ Verify update identity relations when the leader"""
     self.check_api_application_ready.return_value = (True, 'msg')
     hooks.update_all_identity_relation_units()
     # Still updates relations
     self.assertTrue(self.relation_ids.called)