~james-page/charms/trusty/cinder/https-multi-network

« back to all changes in this revision

Viewing changes to unit_tests/test_cluster_hooks.py

  • Committer: james.page at ubuntu
  • Date: 2014-10-01 22:07:44 UTC
  • mfrom: (45.1.1 cinder)
  • Revision ID: james.page@ubuntu.com-20141001220744-v35hu9iblt15phc7
Rebase and resync

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
utils.service_enabled = MagicMock()
13
13
 
14
14
import cinder_hooks as hooks
 
15
hooks.hooks._config_save = False
15
16
 
16
17
# Unpatch it now that its loaded.
17
18
utils.register_configs = _register_configs
62
63
 
63
64
    def setUp(self):
64
65
        super(TestClusterHooks, self).setUp(hooks, TO_PATCH)
65
 
        self.config.side_effect = self.test_config.get_all
 
66
        self.config.side_effect = self.test_config.get
66
67
 
67
68
    @patch('charmhelpers.core.host.service')
68
69
    @patch('charmhelpers.core.host.file_hash')
121
122
            'vip_iface': 'eth101',
122
123
            'vip_cidr': '19',
123
124
        }
 
125
 
 
126
        self.test_config.set('prefer-ipv6', 'False')
124
127
        self.get_hacluster_config.return_value = conf
125
128
        self.get_iface_for_address.return_value = 'eth101'
126
129
        self.get_netmask_for_address.return_value = '255.255.224.0'
146
149
            call(**ex_args)
147
150
        ])
148
151
 
 
152
    def test_ha_joined_complete_config_with_ipv6(self):
 
153
        'Ensure hacluster subordinate receives all relevant config'
 
154
        conf = {
 
155
            'ha-bindiface': 'eth100',
 
156
            'ha-mcastport': '37373',
 
157
            'vip': '2001:db8:1::1',
 
158
            'vip_iface': 'eth101',
 
159
            'vip_cidr': '64',
 
160
        }
 
161
 
 
162
        self.test_config.set('prefer-ipv6', 'True')
 
163
        self.get_hacluster_config.return_value = conf
 
164
        self.get_iface_for_address.return_value = 'eth101'
 
165
        self.get_netmask_for_address.return_value = 'ffff.ffff.ffff.ffff'
 
166
        hooks.hooks.execute(['hooks/ha-relation-joined'])
 
167
        ex_args = {
 
168
            'corosync_mcastport': '37373',
 
169
            'init_services': {'res_cinder_haproxy': 'haproxy'},
 
170
            'resource_params': {
 
171
                'res_cinder_eth101_vip':
 
172
                'params ipv6addr="2001:db8:1::1" '
 
173
                'cidr_netmask="ffff.ffff.ffff.ffff" '
 
174
                'nic="eth101"',
 
175
                'res_cinder_haproxy': 'op monitor interval="5s"'
 
176
            },
 
177
            'corosync_bindiface': 'eth100',
 
178
            'clones': {'cl_cinder_haproxy': 'res_cinder_haproxy'},
 
179
            'resources': {
 
180
                'res_cinder_eth101_vip': 'ocf:heartbeat:IPv6addr',
 
181
                'res_cinder_haproxy': 'lsb:haproxy'
 
182
            }
 
183
        }
 
184
        self.relation_set.assert_called_with(**ex_args)
 
185
 
149
186
    @patch.object(hooks, 'identity_joined')
150
187
    def test_ha_changed_clustered(self, joined):
151
188
        self.relation_get.return_value = True