예제 #1
0
 def test_config_changed_with_relationship(self):
     self.is_relation_made.return_value = True
     hooks.config_changed()
     self.apply_playbook.assert_called_with(hooks.playbook,
                                            tags=['config_changed'])
     self.status_set.assert_called_with(hooks.status_maintenance,
                                        hooks.msg_config_changed)
예제 #2
0
 def test_config_changed_with_relationship(self):
     self.relation_get.return_value = "9200"
     hooks.config_changed()
     self.apply_playbook.assert_called_with(hooks.playbook,
                                            tags=['config_changed'])
     self.status_set.assert_called_with(hooks.status_active,
                                        hooks.msg_service_uploaded)
예제 #3
0
 def test_config_changed(self, update_nrpe_config, mock_certs_joined):
     _install_packages = self.patch('install_packages')
     _relations = {'certificates': ['certificates:1']}
     self.relation_ids.side_effect = lambda name: _relations.get(name, [])
     ceph_hooks.config_changed()
     self.assertTrue(_install_packages.called)
     self.CONFIGS.write_all.assert_called_with()
     update_nrpe_config.assert_called_with()
     mock_certs_joined.assert_called_once_with('certificates:1')
예제 #4
0
    def test_config_changed_no_notify_website_not_changed(self):
        self.service_haproxy.return_value = True
        self.get_listen_stanzas.side_effect = ((('foo.internal', '1.2.3.4',
                                                 123), ), (('foo.internal',
                                                            '1.2.3.4', 123), ))

        hooks.config_changed()

        self.notify_website.assert_not_called()
        self.notify_peer.assert_not_called()
예제 #5
0
    def test_config_changed_no_notify_website_not_changed(self):
        self.service_haproxy.return_value = True
        self.get_listen_stanzas.side_effect = (
            (('foo.internal', '1.2.3.4', 123),),
            (('foo.internal', '1.2.3.4', 123),))

        hooks.config_changed()

        self.notify_website.assert_not_called()
        self.notify_peer.assert_not_called()
예제 #6
0
 def test_config_changed(self, update_nrpe_config, mock_certs_joined):
     _install_packages = self.patch('install_packages')
     _relations = {
         'certificates': ['certificates:1']
     }
     self.relation_ids.side_effect = lambda name: _relations.get(name, [])
     ceph_hooks.config_changed()
     self.assertTrue(_install_packages.called)
     self.CONFIGS.write_all.assert_called_with()
     update_nrpe_config.assert_called_with()
     mock_certs_joined.assert_called_once_with('certificates:1')
예제 #7
0
    def test_config_changed_notify_reverseproxy(self):
        """
        If the ssl_cert config value changes, the reverseproxy relations get
        updated.
        """
        config_data = self.config_get()
        config_data.changed.return_value = True
        _notify_reverseproxy = self.patch_hook("_notify_reverseproxy")
        service_restart = self.patch_hook('service_restart')

        hooks.config_changed()
        self.assertIn(call('ssl_cert'), config_data.changed.mock_calls)
        _notify_reverseproxy.assert_called_once_with()
        service_restart.assert_called_once_with('rsyslog')
예제 #8
0
    def test_config_changed_notify_reverseproxy(self):
        """
        If the ssl_cert config value changes, the reverseproxy relations get
        updated.
        """
        config_data = self.config_get()
        config_data.changed.return_value = True
        _notify_reverseproxy = self.patch_hook("_notify_reverseproxy")
        service_restart = self.patch_hook('service_restart')

        hooks.config_changed()
        self.assertIn(call('ssl_cert'), config_data.changed.mock_calls)
        _notify_reverseproxy.assert_called_once_with()
        service_restart.assert_called_once_with('rsyslog')
예제 #9
0
    def test_config_changed_no_notify_website_failed_check(self):
        self.service_haproxy.return_value = False
        self.get_listen_stanzas.side_effect = (
            (('foo.internal', '1.2.3.4', 123),),
            (('foo.internal', '1.2.3.4', 123),
             ('bar.internal', '1.2.3.5', 234),))

        hooks.config_changed()

        self.notify_website.assert_not_called()
        self.notify_peer.assert_not_called()
        self.log.assert_called_once_with(
            "HAProxy configuration check failed, exiting.")
        self.sys_exit.assert_called_once_with(1)
예제 #10
0
    def test_config_changed_no_notify_website_failed_check(self):
        self.service_haproxy.return_value = False
        self.get_listen_stanzas.side_effect = ((('foo.internal', '1.2.3.4',
                                                 123), ), (
                                                     ('foo.internal',
                                                      '1.2.3.4', 123),
                                                     ('bar.internal',
                                                      '1.2.3.5', 234),
                                                 ))

        hooks.config_changed()

        self.notify_website.assert_not_called()
        self.notify_peer.assert_not_called()
        self.log.assert_called_once_with(
            "HAProxy configuration check failed, exiting.")
        self.sys_exit.assert_called_once_with(1)
예제 #11
0
    def test_config_changed(self, mock_mkdir, mock_rsync, mock_config,
                            mock_os_mkdir, mock_configure_corosync,
                            mock_wait_for_pcmk, mock_pcmk_commit,
                            mock_update_nrpe_config, mock_is_leader,
                            mock_maintenance_mode,
                            mock_hanode_relation_joined,
                            mock_relation_ids):

        mock_config.side_effect = self.test_config.get
        mock_relation_ids.return_value = ['hanode:1']
        mock_wait_for_pcmk.return_value = True
        mock_is_leader.return_value = True
        hooks.config_changed()
        mock_maintenance_mode.assert_not_called()
        mock_relation_ids.assert_called_with('hanode')
        mock_hanode_relation_joined.assert_called_once_with('hanode:1')

        # enable maintenance
        self.test_config.set_previous('maintenance-mode', False)
        self.test_config.set('maintenance-mode', True)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(True)

        # disable maintenance
        self.test_config.set_previous('maintenance-mode', True)
        self.test_config.set('maintenance-mode', False)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(False)
    def test_config_changed(self, mock_mkdir, mock_rsync, mock_config,
                            mock_os_mkdir, mock_configure_corosync,
                            mock_wait_for_pcmk, mock_pcmk_commit,
                            mock_update_nrpe_config, mock_is_leader,
                            mock_maintenance_mode, mock_hanode_relation_joined,
                            mock_relation_ids, mock_configure_stonith):

        mock_config.side_effect = self.test_config.get
        mock_relation_ids.return_value = ['hanode:1']
        mock_wait_for_pcmk.return_value = True
        mock_is_leader.return_value = True
        hooks.config_changed()
        mock_maintenance_mode.assert_not_called()
        mock_relation_ids.assert_called_with('hanode')
        mock_hanode_relation_joined.assert_called_once_with('hanode:1')

        # enable maintenance
        self.test_config.set_previous('maintenance-mode', False)
        self.test_config.set('maintenance-mode', True)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(True)

        # disable maintenance
        self.test_config.set_previous('maintenance-mode', True)
        self.test_config.set('maintenance-mode', False)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(False)
        mock_configure_stonith.assert_called_with()
예제 #13
0
    def test_config_changed_restart_rsyslog(self):
        """
        If the gloabl_log or source config value changes, rsyslog is
        restarted
        """
        config_data = self.config_get()
        called = []

        def changed(a):
            if a in called or a == 'ssl_cert':
                return False
            called.append(a)
            return True

        config_data.changed.side_effect = changed
        service_restart = self.patch_hook('service_restart')

        hooks.config_changed()
        self.assertIn(call('global_log'), config_data.changed.mock_calls)
        service_restart.assert_called_once_with('rsyslog')
        hooks.config_changed()
        self.assertIn(call('source'), config_data.changed.mock_calls)
        service_restart.assert_called_with('rsyslog')
예제 #14
0
    def test_config_changed_restart_rsyslog(self):
        """
        If the gloabl_log or source config value changes, rsyslog is
        restarted
        """
        config_data = self.config_get()
        called = []

        def changed(a):
            if a in called or a == 'ssl_cert':
                return False
            called.append(a)
            return True

        config_data.changed.side_effect = changed
        service_restart = self.patch_hook('service_restart')

        hooks.config_changed()
        self.assertIn(call('global_log'), config_data.changed.mock_calls)
        service_restart.assert_called_once_with('rsyslog')
        hooks.config_changed()
        self.assertIn(call('source'), config_data.changed.mock_calls)
        service_restart.assert_called_with('rsyslog')
예제 #15
0
    def test_config_changed(self, mock_mkdir, mock_rsync, mock_config,
                            mock_os_mkdir, mock_configure_corosync,
                            mock_wait_for_pcmk, mock_pcmk_commit,
                            mock_assess_status_helper, mock_update_nrpe_config,
                            mock_is_leader, mock_maintenance_mode,
                            mock_hanode_relation_joined, mock_relation_ids,
                            mock_configure_stonith, mock_is_stonith_configured,
                            mock_set_property):

        mock_is_stonith_configured.return_value = False
        mock_config.side_effect = self.test_config.get
        mock_relation_ids.return_value = ['hanode:1']
        mock_is_leader.return_value = True
        mock_assess_status_helper.return_value = ('active', 'mockmessage')
        hooks.config_changed()
        mock_maintenance_mode.assert_not_called()
        mock_relation_ids.assert_called_with('hanode')
        mock_hanode_relation_joined.assert_called_once_with('hanode:1')
        mock_set_property.assert_called_with('no-quorum-policy', 'stop')

        # enable maintenance
        self.test_config.set_previous('maintenance-mode', False)
        self.test_config.set('maintenance-mode', True)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(True)

        # disable maintenance
        self.test_config.set_previous('maintenance-mode', True)
        self.test_config.set('maintenance-mode', False)
        hooks.config_changed()
        mock_maintenance_mode.assert_called_with(False)

        # set no-quorum-policy to ignore
        self.test_config.set('no_quorum_policy', 'ignore')
        hooks.config_changed()
        mock_set_property.assert_called_with('no-quorum-policy', 'ignore')
예제 #16
0
 def test_config_changed_without_relationship(self):
     self.is_relation_made.return_value = False
     hooks.config_changed()
     self.apply_playbook.assert_not_called()
     self.status_set.assert_called_with(hooks.status_blocked,
                                        hooks.msg_missing_es_rel)
 def test_config_changed(self):
     hooks.config_changed()
     self.apply_playbook.assert_called_with(hooks.playbook,
                                            tags=['config_changed'])
     self.status_set.assert_called_with(hooks.status_maintenance,
                                        hooks.msg_config_changed)
예제 #18
0
 def test_config_changed(self, update_nrpe_config):
     _install_packages = self.patch('install_packages')
     ceph_hooks.config_changed()
     self.assertTrue(_install_packages.called)
     self.CONFIGS.write_all.assert_called_with()
     update_nrpe_config.assert_called_with()
예제 #19
0
 def test_config_changed(self, update_nrpe_config):
     _install_packages = self.patch('install_packages')
     ceph_hooks.config_changed()
     self.assertTrue(_install_packages.called)
     self.CONFIGS.write_all.assert_called_with()
     update_nrpe_config.assert_called_with()