Merge lp:~james-agentultra/charms/precise/mongodb/join-replicaset-test into lp:charms/trusty/mongodb

Proposed by j_king
Status: Merged
Merged at revision: 87
Proposed branch: lp:~james-agentultra/charms/precise/mongodb/join-replicaset-test
Merge into: lp:charms/trusty/mongodb
Diff against target: 126 lines (+58/-38)
1 file modified
tests/03_deploy_replicaset.py (+58/-38)
To merge this branch: bzr merge lp:~james-agentultra/charms/precise/mongodb/join-replicaset-test
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Needs Fixing
James Page Approve
Review via email: mp+296497@code.launchpad.net

Description of the change

This patch adds an amulet test to verify joining multiple units to a replica set after setup.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #2790 mongodb for james-agentultra mp296497
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/2790/

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

charm_unit_test #2134 mongodb for james-agentultra mp296497
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/2134/

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

charm_amulet_test #768 mongodb for james-agentultra mp296497
    AMULET OK: passed

Build: http://10.245.162.36:8080/job/charm_amulet_test/768/

Revision history for this message
James Page (james-page) :
review: Approve
Revision history for this message
James Page (james-page) wrote :

Hi James

Thanks for your contribution - looks good and passes amulet tests from the OpenStack CI testing bot so merged and landed!

Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/4605/

review: Needs Fixing (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/4585/

review: Needs Fixing (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/03_deploy_replicaset.py'
2--- tests/03_deploy_replicaset.py 2015-12-02 22:50:09 +0000
3+++ tests/03_deploy_replicaset.py 2016-06-05 00:56:08 +0000
4@@ -46,39 +46,12 @@
5
6
7 #############################################################
8-# Check presence of MongoDB GUI HEALTH Status
9-#############################################################
10-def validate_status_interface():
11- pubaddy = d.sentry['mongodb'][0].info['public-address']
12- fmt = "http://{}:28017"
13- if ":" in pubaddy:
14- fmt = "http://[{}]:28017"
15- r = requests.get(fmt.format(pubaddy), verify=False)
16- r.raise_for_status
17-
18-
19-#############################################################
20-# Validate that each unit has an active mongo service
21-#############################################################
22-def validate_running_services():
23- for service in sentry_dict:
24- output = sentry_dict[service].run('service mongodb status')
25- service_active = str(output).find('mongodb start/running')
26- if service_active == -1:
27- message = "Failed to find running MongoDB on host {}".format(
28- service)
29- amulet.raise_status(amulet.SKIP, msg=message)
30-
31-
32-#############################################################
33-# Validate proper replicaset setup
34-#############################################################
35-def validate_replicaset_setup():
36-
37- d.sentry.wait(seconds)
38-
39+# Test Utilities
40+#############################################################
41+def _expect_replicaset_counts(primaries_count,
42+ secondaries_count,
43+ time_between=10):
44 unit_status = []
45- time_between = 10
46 tries = wait_for_replicaset / time_between
47
48 for service in sentry_dict:
49@@ -107,19 +80,65 @@
50 client.close()
51
52 primaries = Counter(unit_status)[1]
53- if primaries != 1:
54- message = "Only one PRIMARY unit allowed! Found: %s %s" % (primaries,
55- unit_status)
56+ if primaries != primaries_count:
57+ message = "Expected %d PRIMARY unit(s)! Found: %s %s" % (
58+ primaries_count,
59+ primaries,
60+ unit_status)
61 amulet.raise_status(amulet.FAIL, message)
62
63 secondrs = Counter(unit_status)[2]
64- if secondrs != 2:
65- message = ("Only two SECONDARY units allowed! (Found %s) %s" %
66- (secondrs, unit_status))
67+ if secondrs != secondaries_count:
68+ message = ("Expected %d secondary units! (Found %s) %s" %
69+ (secondaries_count, secondrs, unit_status))
70 amulet.raise_status(amulet.FAIL, message)
71
72
73 #############################################################
74+# Check presence of MongoDB GUI HEALTH Status
75+#############################################################
76+def validate_status_interface():
77+ pubaddy = d.sentry['mongodb'][0].info['public-address']
78+ fmt = "http://{}:28017"
79+ if ":" in pubaddy:
80+ fmt = "http://[{}]:28017"
81+ r = requests.get(fmt.format(pubaddy), verify=False)
82+ r.raise_for_status
83+
84+
85+#############################################################
86+# Validate that each unit has an active mongo service
87+#############################################################
88+def validate_running_services():
89+ for service in sentry_dict:
90+ output = sentry_dict[service].run('service mongodb status')
91+ service_active = str(output).find('mongodb start/running')
92+ if service_active == -1:
93+ message = "Failed to find running MongoDB on host {}".format(
94+ service)
95+ amulet.raise_status(amulet.SKIP, msg=message)
96+
97+
98+#############################################################
99+# Validate proper replicaset setup
100+#############################################################
101+def validate_replicaset_setup():
102+ d.sentry.wait(seconds)
103+ _expect_replicaset_counts(1, 2)
104+
105+
106+#############################################################
107+# Validate replicaset joined
108+#############################################################
109+def validate_replicaset_relation_joined():
110+ d.add_unit('mongodb', units=2)
111+ d.sentry.wait(wait_for_replicaset)
112+ sentry_dict.update({'mongodb3-sentry': d.sentry['mongodb'][3],
113+ 'mongodb4-sentry': d.sentry['mongodb'][4]})
114+ _expect_replicaset_counts(1, 4)
115+
116+
117+#############################################################
118 # Validate connectivity from $WORLD
119 #############################################################
120 def validate_world_connectivity():
121@@ -165,4 +184,5 @@
122 validate_status_interface()
123 validate_running_services()
124 validate_replicaset_setup()
125+validate_replicaset_relation_joined()
126 validate_world_connectivity()

Subscribers

People subscribed via source and target branches

to all changes: