~jseutter/charms/precise/haproxy/trunk

« back to all changes in this revision

Viewing changes to hooks/tests/test_nrpe_hooks.py

  • Committer: Marco Ceppi
  • Date: 2013-10-17 03:33:47 UTC
  • mfrom: (60.1.27 haproxy)
  • Revision ID: marco@ceppi.net-20131017033347-7ha6tdiivmpardtx
[sidnei] The 'all_services' config now supports a static list of servers to be used *in addition* to the ones provided via relation.
[sidnei] When more than one haproxy units exist, the configured service is upgraded in-place to a mode where traffic is routed to a single haproxy unit (the first one in unit-name order) and the remaining ones are configured as 'backup'. This is done to allow the enforcement of a 'maxconn' session in the configured services, which would not be possible to enforce otherwise.
[sidnei] Changes to the configured services are properly propagated to the upstream relation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from testtools import TestCase
 
2
from mock import call, patch, MagicMock
 
3
 
 
4
import hooks
 
5
 
 
6
 
 
7
class NRPEHooksTest(TestCase):
 
8
 
 
9
    @patch('hooks.install_nrpe_scripts')
 
10
    @patch('charmhelpers.contrib.charmsupport.nrpe.NRPE')
 
11
    def test_update_nrpe_config(self, nrpe, install_nrpe_scripts):
 
12
        nrpe_compat = MagicMock()
 
13
        nrpe_compat.checks = [MagicMock(shortname="haproxy"),
 
14
                              MagicMock(shortname="haproxy_queue")]
 
15
        nrpe.return_value = nrpe_compat
 
16
 
 
17
        hooks.update_nrpe_config()
 
18
 
 
19
        self.assertEqual(
 
20
            nrpe_compat.mock_calls,
 
21
            [call.add_check('haproxy', 'Check HAProxy', 'check_haproxy.sh'),
 
22
             call.add_check('haproxy_queue', 'Check HAProxy queue depth',
 
23
                            'check_haproxy_queue_depth.sh'),
 
24
             call.write()])