def test_HorizonHAProxyContext_clustered(self): self.relation_ids.return_value = ['cluster:0'] self.related_units.return_value = [ 'openstack-dashboard/1', 'openstack-dashboard/2' ] self.relation_get.side_effect = ['10.5.0.2', '10.5.0.3'] self.local_unit.return_value = 'openstack-dashboard/0' self.get_relation_ip.return_value = "10.5.0.1" with patch_open() as (_open, _file): self.assertEqual( horizon_contexts.HorizonHAProxyContext()(), { 'units': { 'openstack-dashboard-0': '10.5.0.1', 'openstack-dashboard-1': '10.5.0.2', 'openstack-dashboard-2': '10.5.0.3' }, 'service_ports': { 'dash_insecure': [80, 70], 'dash_secure': [443, 433] }, 'prefer_ipv6': False, 'haproxy_expose_stats': False }) _open.assert_called_with('/etc/default/haproxy', 'w') self.assertTrue(_file.write.called) self.get_relation_ip.assert_called_with('cluster')
def test_HorizonHAProxyContext_expose_stats(self): self.test_config.set('haproxy-expose-stats', True) self.relation_ids.return_value = [] self.local_unit.return_value = 'openstack-dashboard/0' self.get_relation_ip.return_value = "10.5.0.1" with patch_open() as (_open, _file): self.assertEquals( horizon_contexts.HorizonHAProxyContext()(), { 'units': { 'openstack-dashboard-0': '10.5.0.1' }, 'service_ports': { 'dash_insecure': [80, 70], 'dash_secure': [443, 433] }, 'prefer_ipv6': False, 'haproxy_expose_stats': True }) _open.assert_called_with('/etc/default/haproxy', 'w') self.assertTrue(_file.write.called)
}), (APACHE_DEFAULT, { 'hook_contexts': [horizon_contexts.ApacheContext()], 'services': ['apache2', 'memcached'], }), (APACHE_24_DEFAULT, { 'hook_contexts': [horizon_contexts.ApacheContext()], 'services': ['apache2', 'memcached'], }), (PORTS_CONF, { 'hook_contexts': [horizon_contexts.ApacheContext()], 'services': ['apache2', 'memcached'], }), (HAPROXY_CONF, { 'hook_contexts': [ horizon_contexts.HorizonHAProxyContext(), context.HAProxyContext(singlenode_mode=True, address_types=[]), ], 'services': ['haproxy'], }), (ROUTER_SETTING, { 'hook_contexts': [horizon_contexts.RouterSettingContext()], 'services': ['apache2', 'memcached'], }), (KEYSTONEV3_POLICY, { 'hook_contexts': [horizon_contexts.IdentityServiceContext()], 'services': ['apache2', 'memcached'], }), (CONSISTENCY_GROUP_POLICY, { 'hook_contexts': [horizon_contexts.HorizonContext()], 'services': ['apache2', 'memcached'],