Merge lp:~corey.bryant/charms/trusty/keystone/sync-charm-helpers into lp:~openstack-charmers-archive/charms/trusty/keystone/next

Proposed by Corey Bryant
Status: Merged
Merged at revision: 69
Proposed branch: lp:~corey.bryant/charms/trusty/keystone/sync-charm-helpers
Merge into: lp:~openstack-charmers-archive/charms/trusty/keystone/next
Diff against target: 309 lines (+86/-45)
10 files modified
hooks/charmhelpers/contrib/openstack/amulet/deployment.py (+24/-7)
hooks/charmhelpers/contrib/openstack/amulet/utils.py (+5/-5)
tests/11-basic-precise-folsom (+2/-1)
tests/12-basic-precise-grizzly (+2/-1)
tests/13-basic-precise-havana (+2/-1)
tests/14-basic-precise-icehouse (+2/-1)
tests/basic_deployment.py (+6/-7)
tests/charmhelpers/contrib/amulet/utils.py (+14/-10)
tests/charmhelpers/contrib/openstack/amulet/deployment.py (+24/-7)
tests/charmhelpers/contrib/openstack/amulet/utils.py (+5/-5)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/keystone/sync-charm-helpers
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+225167@code.launchpad.net

Description of the change

There are 3 commits to bring keystone amulet tests up to speed with the latest fixes in charm-helpers.

To post a comment you must log in.
69. By James Page

[coreycb,r=james-page] Resync helpers, specify source as well.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/deployment.py'
2--- hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-24 17:11:12 +0000
3+++ hooks/charmhelpers/contrib/openstack/amulet/deployment.py 2014-07-01 14:39:58 +0000
4@@ -7,19 +7,36 @@
5 """This class inherits from AmuletDeployment and has additional support
6 that is specifically for use by OpenStack charms."""
7
8- def __init__(self, series=None, openstack=None):
9+ def __init__(self, series=None, openstack=None, source=None):
10 """Initialize the deployment environment."""
11- self.openstack = None
12 super(OpenStackAmuletDeployment, self).__init__(series)
13-
14- if openstack:
15- self.openstack = openstack
16+ self.openstack = openstack
17+ self.source = source
18+
19+ def _add_services(self, this_service, other_services):
20+ """Add services to the deployment and set openstack-origin."""
21+ super(OpenStackAmuletDeployment, self)._add_services(this_service,
22+ other_services)
23+ name = 0
24+ services = other_services
25+ services.append(this_service)
26+ use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
27+
28+ if self.openstack:
29+ for svc in services:
30+ if svc[name] not in use_source:
31+ config = {'openstack-origin': self.openstack}
32+ self.d.configure(svc[name], config)
33+
34+ if self.source:
35+ for svc in services:
36+ if svc[name] in use_source:
37+ config = {'source': self.source}
38+ self.d.configure(svc[name], config)
39
40 def _configure_services(self, configs):
41 """Configure all of the services."""
42 for service, config in configs.iteritems():
43- if service == self.this_service:
44- config['openstack-origin'] = self.openstack
45 self.d.configure(service, config)
46
47 def _get_openstack_release(self):
48
49=== modified file 'hooks/charmhelpers/contrib/openstack/amulet/utils.py'
50--- hooks/charmhelpers/contrib/openstack/amulet/utils.py 2014-06-24 17:11:12 +0000
51+++ hooks/charmhelpers/contrib/openstack/amulet/utils.py 2014-07-01 14:39:58 +0000
52@@ -74,7 +74,7 @@
53 if ret:
54 return "unexpected tenant data - {}".format(ret)
55 if not found:
56- return "tenant {} does not exist".format(e.name)
57+ return "tenant {} does not exist".format(e['name'])
58 return ret
59
60 def validate_role_data(self, expected, actual):
61@@ -91,7 +91,7 @@
62 if ret:
63 return "unexpected role data - {}".format(ret)
64 if not found:
65- return "role {} does not exist".format(e.name)
66+ return "role {} does not exist".format(e['name'])
67 return ret
68
69 def validate_user_data(self, expected, actual):
70@@ -110,7 +110,7 @@
71 if ret:
72 return "unexpected user data - {}".format(ret)
73 if not found:
74- return "user {} does not exist".format(e.name)
75+ return "user {} does not exist".format(e['name'])
76 return ret
77
78 def validate_flavor_data(self, expected, actual):
79@@ -192,8 +192,8 @@
80
81 count = 1
82 status = instance.status
83- while status == 'BUILD' and count < 10:
84- time.sleep(5)
85+ while status != 'ACTIVE' and count < 60:
86+ time.sleep(3)
87 instance = nova.servers.get(instance.id)
88 status = instance.status
89 self.log.debug('instance status: {}'.format(status))
90
91=== modified file 'tests/11-basic-precise-folsom'
92--- tests/11-basic-precise-folsom 2014-06-24 17:11:36 +0000
93+++ tests/11-basic-precise-folsom 2014-07-01 14:39:58 +0000
94@@ -6,5 +6,6 @@
95
96 if __name__ == '__main__':
97 deployment = KeystoneBasicDeployment(series='precise',
98- openstack='cloud:precise-folsom')
99+ openstack='cloud:precise-folsom',
100+ source='cloud:precise-updates/folsom')
101 deployment.run_tests()
102
103=== modified file 'tests/12-basic-precise-grizzly'
104--- tests/12-basic-precise-grizzly 2014-06-24 17:11:36 +0000
105+++ tests/12-basic-precise-grizzly 2014-07-01 14:39:58 +0000
106@@ -6,5 +6,6 @@
107
108 if __name__ == '__main__':
109 deployment = KeystoneBasicDeployment(series='precise',
110- openstack='cloud:precise-grizzly')
111+ openstack='cloud:precise-grizzly',
112+ source='cloud:precise-updates/grizzly')
113 deployment.run_tests()
114
115=== modified file 'tests/13-basic-precise-havana'
116--- tests/13-basic-precise-havana 2014-06-24 17:11:36 +0000
117+++ tests/13-basic-precise-havana 2014-07-01 14:39:58 +0000
118@@ -6,5 +6,6 @@
119
120 if __name__ == '__main__':
121 deployment = KeystoneBasicDeployment(series='precise',
122- openstack='cloud:precise-havana')
123+ openstack='cloud:precise-havana',
124+ source='cloud:precise-updates/havana')
125 deployment.run_tests()
126
127=== modified file 'tests/14-basic-precise-icehouse'
128--- tests/14-basic-precise-icehouse 2014-06-24 17:11:36 +0000
129+++ tests/14-basic-precise-icehouse 2014-07-01 14:39:58 +0000
130@@ -6,5 +6,6 @@
131
132 if __name__ == '__main__':
133 deployment = KeystoneBasicDeployment(series='precise',
134- openstack='cloud:precise-icehouse')
135+ openstack='cloud:precise-icehouse',
136+ source='cloud:precise-updates/icehouse')
137 deployment.run_tests()
138
139=== modified file 'tests/basic_deployment.py'
140--- tests/basic_deployment.py 2014-06-24 17:11:36 +0000
141+++ tests/basic_deployment.py 2014-07-01 14:39:58 +0000
142@@ -19,9 +19,9 @@
143 class KeystoneBasicDeployment(OpenStackAmuletDeployment):
144 """Amulet tests on a basic keystone deployment."""
145
146- def __init__(self, series=None, openstack=None):
147+ def __init__(self, series=None, openstack=None, source=None):
148 """Deploy the entire test environment."""
149- super(KeystoneBasicDeployment, self).__init__(series, openstack)
150+ super(KeystoneBasicDeployment, self).__init__(series, openstack, source)
151 self._add_services()
152 self._add_relations()
153 self._configure_services()
154@@ -90,11 +90,10 @@
155 """Verify the expected services are running on the corresponding
156 service units."""
157 commands = {
158- self.mysql_sentry: 'status mysql',
159- self.keystone_sentry: 'status keystone',
160- self.cinder_sentry: 'status cinder-api',
161- self.cinder_sentry: 'status cinder-scheduler',
162- self.cinder_sentry: 'status cinder-volume'
163+ self.mysql_sentry: ['status mysql'],
164+ self.keystone_sentry: ['status keystone'],
165+ self.cinder_sentry: ['status cinder-api', 'status cinder-scheduler',
166+ 'status cinder-volume']
167 }
168 ret = u.validate_services(commands)
169 if ret:
170
171=== modified file 'tests/charmhelpers/contrib/amulet/utils.py'
172--- tests/charmhelpers/contrib/amulet/utils.py 2014-06-24 17:11:12 +0000
173+++ tests/charmhelpers/contrib/amulet/utils.py 2014-07-01 14:39:58 +0000
174@@ -53,9 +53,10 @@
175 """Verify the specified services are running on the corresponding
176 service units."""
177 for k, v in commands.iteritems():
178- output, code = k.run(v)
179- if code != 0:
180- return "command `{}` returned {}".format(v, str(code))
181+ for cmd in v:
182+ output, code = k.run(cmd)
183+ if code != 0:
184+ return "command `{}` returned {}".format(cmd, str(code))
185 return None
186
187 def _get_config(self, unit, filename):
188@@ -126,21 +127,24 @@
189 """Get last modification time of directory."""
190 return sentry_unit.directory_stat(directory)['mtime']
191
192- def _get_proc_start_time(self, sentry_unit, service):
193+ def _get_proc_start_time(self, sentry_unit, service, pgrep_full=False):
194 """Determine start time of the process based on the last modification
195- time of the /proc/pid directory. The servie string will be matched
196- against any substring in the full command line, choosing the oldest
197- process."""
198- cmd = 'pgrep -f -o {}'.format(service)
199+ time of the /proc/pid directory. If pgrep_full is True, the process
200+ name is matched against the full command line."""
201+ if pgrep_full:
202+ cmd = 'pgrep -o -f {}'.format(service)
203+ else:
204+ cmd = 'pgrep -o {}'.format(service)
205 proc_dir = '/proc/{}'.format(sentry_unit.run(cmd)[0].strip())
206 return self._get_dir_mtime(sentry_unit, proc_dir)
207
208- def service_restarted(self, sentry_unit, service, filename):
209+ def service_restarted(self, sentry_unit, service, filename,
210+ pgrep_full=False):
211 """Compare a service's start time vs a file's last modification time
212 (such as a config file for that service) to determine if the service
213 has been restarted."""
214 sleep(10)
215- if self._get_proc_start_time(sentry_unit, service) >= \
216+ if self._get_proc_start_time(sentry_unit, service, pgrep_full) >= \
217 self._get_file_mtime(sentry_unit, filename):
218 return True
219 else:
220
221=== modified file 'tests/charmhelpers/contrib/openstack/amulet/deployment.py'
222--- tests/charmhelpers/contrib/openstack/amulet/deployment.py 2014-06-24 17:11:12 +0000
223+++ tests/charmhelpers/contrib/openstack/amulet/deployment.py 2014-07-01 14:39:58 +0000
224@@ -7,19 +7,36 @@
225 """This class inherits from AmuletDeployment and has additional support
226 that is specifically for use by OpenStack charms."""
227
228- def __init__(self, series=None, openstack=None):
229+ def __init__(self, series=None, openstack=None, source=None):
230 """Initialize the deployment environment."""
231- self.openstack = None
232 super(OpenStackAmuletDeployment, self).__init__(series)
233-
234- if openstack:
235- self.openstack = openstack
236+ self.openstack = openstack
237+ self.source = source
238+
239+ def _add_services(self, this_service, other_services):
240+ """Add services to the deployment and set openstack-origin."""
241+ super(OpenStackAmuletDeployment, self)._add_services(this_service,
242+ other_services)
243+ name = 0
244+ services = other_services
245+ services.append(this_service)
246+ use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
247+
248+ if self.openstack:
249+ for svc in services:
250+ if svc[name] not in use_source:
251+ config = {'openstack-origin': self.openstack}
252+ self.d.configure(svc[name], config)
253+
254+ if self.source:
255+ for svc in services:
256+ if svc[name] in use_source:
257+ config = {'source': self.source}
258+ self.d.configure(svc[name], config)
259
260 def _configure_services(self, configs):
261 """Configure all of the services."""
262 for service, config in configs.iteritems():
263- if service == self.this_service:
264- config['openstack-origin'] = self.openstack
265 self.d.configure(service, config)
266
267 def _get_openstack_release(self):
268
269=== modified file 'tests/charmhelpers/contrib/openstack/amulet/utils.py'
270--- tests/charmhelpers/contrib/openstack/amulet/utils.py 2014-06-24 17:11:12 +0000
271+++ tests/charmhelpers/contrib/openstack/amulet/utils.py 2014-07-01 14:39:58 +0000
272@@ -74,7 +74,7 @@
273 if ret:
274 return "unexpected tenant data - {}".format(ret)
275 if not found:
276- return "tenant {} does not exist".format(e.name)
277+ return "tenant {} does not exist".format(e['name'])
278 return ret
279
280 def validate_role_data(self, expected, actual):
281@@ -91,7 +91,7 @@
282 if ret:
283 return "unexpected role data - {}".format(ret)
284 if not found:
285- return "role {} does not exist".format(e.name)
286+ return "role {} does not exist".format(e['name'])
287 return ret
288
289 def validate_user_data(self, expected, actual):
290@@ -110,7 +110,7 @@
291 if ret:
292 return "unexpected user data - {}".format(ret)
293 if not found:
294- return "user {} does not exist".format(e.name)
295+ return "user {} does not exist".format(e['name'])
296 return ret
297
298 def validate_flavor_data(self, expected, actual):
299@@ -192,8 +192,8 @@
300
301 count = 1
302 status = instance.status
303- while status == 'BUILD' and count < 10:
304- time.sleep(5)
305+ while status != 'ACTIVE' and count < 60:
306+ time.sleep(3)
307 instance = nova.servers.get(instance.id)
308 status = instance.status
309 self.log.debug('instance status: {}'.format(status))

Subscribers

People subscribed via source and target branches