Merge lp:~freyes/charms/trusty/hacluster/add-location into lp:~openstack-charmers/charms/trusty/hacluster/next

Proposed by Felipe Reyes
Status: Superseded
Proposed branch: lp:~freyes/charms/trusty/hacluster/add-location
Merge into: lp:~openstack-charmers/charms/trusty/hacluster/next
Diff against target: 137 lines (+101/-0)
4 files modified
.bzrignore (+1/-0)
hooks/hooks.py (+10/-0)
setup.cfg (+6/-0)
unit_tests/test_hacluster_hooks.py (+84/-0)
To merge this branch: bzr merge lp:~freyes/charms/trusty/hacluster/add-location
Reviewer Review Type Date Requested Status
Jorge Niedbalski (community) Needs Fixing
Review via email: mp+252022@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-06.

Description of the change

To post a comment you must log in.
Revision history for this message
Jorge Niedbalski (niedbalski) wrote :

Felipe,

Thanks for this patch. Mind to add a test for covering your change?

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #2488 hacluster-next for freyes mp252022
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2488/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #2278 hacluster-next for freyes mp252022
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2278/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #2360 hacluster-next for freyes mp252022
    AMULET FAIL: amulet-test missing

AMULET Results (max last 2 lines):
INFO:root:Search string not found in makefile target commands.
ERROR:root:No make target was executed.

Full amulet test output: http://paste.ubuntu.com/10543782/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2360/

43. By Felipe Reyes

Add unit test for configure_principle_cluster_resources()

This is the handler for ha-relation-joined, ha-relation-changed,
hanode-relation-joined and hanode-relation-changed

44. By Felipe Reyes

Drop str() when logging parameters

log() already takes care of calling repr() when needed

Unmerged revisions

44. By Felipe Reyes

Drop str() when logging parameters

log() already takes care of calling repr() when needed

43. By Felipe Reyes

Add unit test for configure_principle_cluster_resources()

This is the handler for ha-relation-joined, ha-relation-changed,
hanode-relation-joined and hanode-relation-changed

42. By Felipe Reyes

Add support to define location rules in pcmkr

Fixes bug #1428850

41. By Liam Young

Fix charm-helpers.yaml and charmhelper sync

40. By Edward Hope-Morley

[hopem,r=niedbalski,tinoco,wolsen]

Don't upgrade pacemaker packages. This restriction
can be removed once 1382842 is fixed but for the
moment we can't allow upgrades due to issues with
pacemaker dependencies.

Closes-Bug: 1382842

39. By Edward Hope-Morley

[freyes,r=hopem]

Add debug option to config.yaml and optionally enable
debug logging in corosync.conf

38. By James Page

Merge in bundle tests from master charm

37. By Edward Hope-Morley

[wolsen,r=hopem]

Specify the vote count for multicast quorum to be the number of nodes
which are configured. Additionally, specify the two_node value in the
quorum section when there are 2 nodes configured.

Closes-Bug: 1394008

36. By Edward Hope-Morley

[gnuoy,r=jamespage,hopem]

Adds unicast support

corosync_transport can now be uysed to specify udp or udpu.

Closes-Bug: 1348521

35. By Edward Hope-Morley

[hopem] synced lp:charm-helpers

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-10-12 08:12:10 +0000
3+++ .bzrignore 2015-03-06 15:00:00 +0000
4@@ -1,1 +1,2 @@
5 bin
6+.coverage
7
8=== modified file 'hooks/hooks.py'
9--- hooks/hooks.py 2014-12-17 17:17:29 +0000
10+++ hooks/hooks.py 2015-03-06 15:00:00 +0000
11@@ -350,6 +350,7 @@
12 orders = parse_data(relid, unit, 'orders')
13 colocations = parse_data(relid, unit, 'colocations')
14 clones = parse_data(relid, unit, 'clones')
15+ locations = parse_data(relid, unit, 'locations')
16 init_services = parse_data(relid, unit, 'init_services')
17 else:
18 log('Related to {} ha services'.format(len(relids)))
19@@ -458,6 +459,15 @@
20 pcmk.commit(cmd)
21 log('%s' % cmd)
22
23+ log('Configuring Locations')
24+ log(str(locations))
25+ for loc_name, loc_params in locations.iteritems():
26+ if not pcmk.crm_opt_exists(loc_name):
27+ cmd = 'crm -w -F configure location %s %s' % (loc_name,
28+ loc_params)
29+ pcmk.commit(cmd)
30+ log('%s' % cmd)
31+
32 for res_name, res_type in resources.iteritems():
33 if len(init_services) != 0 and res_name in init_services:
34 # Checks that the resources are running and started.
35
36=== added file 'setup.cfg'
37--- setup.cfg 1970-01-01 00:00:00 +0000
38+++ setup.cfg 2015-03-06 15:00:00 +0000
39@@ -0,0 +1,6 @@
40+[nosetests]
41+verbosity=2
42+with-coverage=1
43+cover-erase=1
44+cover-package=hooks
45+
46
47=== modified file 'unit_tests/test_hacluster_hooks.py'
48--- unit_tests/test_hacluster_hooks.py 2014-12-15 12:55:12 +0000
49+++ unit_tests/test_hacluster_hooks.py 2015-03-06 15:00:00 +0000
50@@ -89,3 +89,87 @@
51
52 matches = re.findall(pattern, content, re.M)
53 self.assertEqual(len(matches), 2, str(matches))
54+
55+ @mock.patch('pcmk.wait_for_pcmk')
56+ @mock.patch('hooks.peer_units')
57+ @mock.patch('pcmk.crm_opt_exists')
58+ @mock.patch('hooks.oldest_peer')
59+ @mock.patch('hooks.configure_corosync')
60+ @mock.patch('hooks.configure_cluster_global')
61+ @mock.patch('hooks.configure_monitor_host')
62+ @mock.patch('hooks.configure_stonith')
63+ @mock.patch('hooks.related_units')
64+ @mock.patch('hooks.get_cluster_nodes')
65+ @mock.patch('hooks.relation_set')
66+ @mock.patch('hooks.relation_ids')
67+ @mock.patch('hooks.get_corosync_conf')
68+ @mock.patch('pcmk.commit')
69+ @mock.patch('hooks.config')
70+ @mock.patch('hooks.parse_data')
71+ def test_configure_principle_cluster_resources(self, parse_data, config,
72+ commit,
73+ get_corosync_conf,
74+ relation_ids, relation_set,
75+ get_cluster_nodes,
76+ related_units,
77+ configure_stonith,
78+ configure_monitor_host,
79+ configure_cluster_global,
80+ configure_corosync,
81+ oldest_peer, crm_opt_exists,
82+ peer_units, wait_for_pcmk):
83+ crm_opt_exists.return_value = False
84+ oldest_peer.return_value = True
85+ related_units.return_value = ['ha/0', 'ha/1', 'ha/2']
86+ get_cluster_nodes.return_value = ['10.0.3.2', '10.0.3.3', '10.0.3.4']
87+ relation_ids.return_value = ['hanode:1']
88+ get_corosync_conf.return_value = True
89+ cfg = {'debug': False,
90+ 'prefer-ipv6': False,
91+ 'corosync_transport': 'udpu',
92+ 'corosync_mcastaddr': 'corosync_mcastaddr',
93+ 'cluster_count': 3}
94+
95+ def c(k):
96+ return cfg.get(k)
97+
98+ config.side_effect = c
99+
100+ rel_get_data = {'locations': {'loc_foo': 'bar rule inf: meh eq 1'},
101+ 'clones': {'cl_foo': 'res_foo meta interleave=true'},
102+ 'groups': {'grp_foo': 'res_foo'},
103+ 'colocations': {'co_foo': 'inf: grp_foo cl_foo'},
104+ 'resources': {'res_foo': 'ocf:heartbeat:IPaddr2',
105+ 'res_bar': 'ocf:heartbear:IPv6addr'},
106+ 'resource_params': {'res_foo': 'params bar'},
107+ 'ms': {'ms_foo': 'res_foo meta notify=true'},
108+ 'orders': {'foo_after': 'inf: res_foo ms_foo'}}
109+
110+ def fake_parse_data(relid, unit, key):
111+ return rel_get_data.get(key, {})
112+
113+ parse_data.side_effect = fake_parse_data
114+
115+ hacluster_hooks.configure_principle_cluster_resources()
116+ relation_set.assert_any_call(relation_id='hanode:1', ready=True)
117+ configure_stonith.assert_called_with()
118+ configure_monitor_host.assert_called_with()
119+ configure_cluster_global.assert_called_with()
120+ configure_corosync.assert_called_with()
121+
122+ for kw, key in [('location', 'locations'),
123+ ('clone', 'clones'),
124+ ('group', 'groups'),
125+ ('colocation', 'colocations'),
126+ ('primitive', 'resources'),
127+ ('ms', 'ms'),
128+ ('order', 'orders')]:
129+ for name, params in rel_get_data[key].items():
130+ if name in rel_get_data['resource_params']:
131+ res_params = rel_get_data['resource_params'][name]
132+ commit.assert_any_call(
133+ 'crm -w -F configure %s %s %s %s' % (kw, name, params,
134+ res_params))
135+ else:
136+ commit.assert_any_call(
137+ 'crm -w -F configure %s %s %s' % (kw, name, params))

Subscribers

People subscribed via source and target branches