Merge lp:~corey.bryant/charm-helpers/enable-next-branches into lp:charm-helpers

Proposed by Corey Bryant
Status: Merged
Merged at revision: 220
Proposed branch: lp:~corey.bryant/charm-helpers/enable-next-branches
Merge into: lp:charm-helpers
Diff against target: 125 lines (+50/-15)
3 files modified
charmhelpers/contrib/amulet/deployment.py (+10/-9)
charmhelpers/contrib/openstack/amulet/deployment.py (+35/-2)
charmhelpers/contrib/openstack/amulet/utils.py (+5/-4)
To merge this branch: bzr merge lp:~corey.bryant/charm-helpers/enable-next-branches
Reviewer Review Type Date Requested Status
Liam Young (community) Needs Fixing
Review via email: mp+235664@code.launchpad.net

Description of the change

OpenStack amulet tests are currently broken for the dev branches. This is because we are mixing next branch (the current branch that is being tested) with stable branches (all other charms are branched from the charm store). This patch fixes that.

To post a comment you must log in.
215. By Corey Bryant

Allow branch locations to be specified for amulet tests. Also enable testing of
openstack dev branches.

216. By Corey Bryant

Extend timeout limit for amulet deployment.

Revision history for this message
Liam Young (gnuoy) wrote :

A few comments inline

review: Needs Fixing
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Hey Liam, thanks for reviewing. A few responses below.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

1 more response inline.

Revision history for this message
Liam Young (gnuoy) wrote :

approve.

217. By Corey Bryant

Revert hard-coded setup() timeout limit for amulet deployment.
It can be specified via the juju test command line.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/amulet/deployment.py'
--- charmhelpers/contrib/amulet/deployment.py 2014-07-29 17:58:27 +0000
+++ charmhelpers/contrib/amulet/deployment.py 2014-09-24 16:17:11 +0000
@@ -24,10 +24,10 @@
24 """Add services.24 """Add services.
2525
26 Add services to the deployment where this_service is the local charm26 Add services to the deployment where this_service is the local charm
27 that we're focused on testing and other_services are the other27 that we're testing and other_services are the other services that
28 charms that come from the charm store.28 are being used in the amulet tests.
29 """29 """
30 name, units = range(2)30 name, units, location = range(3)
3131
32 if this_service[name] != os.path.basename(os.getcwd()):32 if this_service[name] != os.path.basename(os.getcwd()):
33 s = this_service[name]33 s = this_service[name]
@@ -37,12 +37,13 @@
37 self.d.add(this_service[name], units=this_service[units])37 self.d.add(this_service[name], units=this_service[units])
3838
39 for svc in other_services:39 for svc in other_services:
40 if self.series:40 if len(svc) > 2:
41 self.d.add(svc[name],41 branch_location = svc[location]
42 charm='cs:{}/{}'.format(self.series, svc[name]),42 elif self.series:
43 units=svc[units])43 branch_location = 'cs:{}/{}'.format(self.series, svc[name]),
44 else:44 else:
45 self.d.add(svc[name], units=svc[units])45 branch_location = None
46 self.d.add(svc[name], charm=branch_location, units=svc[units])
4647
47 def _add_relations(self, relations):48 def _add_relations(self, relations):
48 """Add all of the relations for the services."""49 """Add all of the relations for the services."""
@@ -57,7 +58,7 @@
57 def _deploy(self):58 def _deploy(self):
58 """Deploy environment and wait for all hooks to finish executing."""59 """Deploy environment and wait for all hooks to finish executing."""
59 try:60 try:
60 self.d.setup()61 self.d.setup(timeout=900)
61 self.d.sentry.wait(timeout=900)62 self.d.sentry.wait(timeout=900)
62 except amulet.helpers.TimeoutError:63 except amulet.helpers.TimeoutError:
63 amulet.raise_status(amulet.FAIL, msg="Deployment timed out")64 amulet.raise_status(amulet.FAIL, msg="Deployment timed out")
6465
=== modified file 'charmhelpers/contrib/openstack/amulet/deployment.py'
--- charmhelpers/contrib/openstack/amulet/deployment.py 2014-07-29 17:58:27 +0000
+++ charmhelpers/contrib/openstack/amulet/deployment.py 2014-09-24 16:17:11 +0000
@@ -1,3 +1,6 @@
1from bzrlib.branch import Branch
2import os
3import re
1from charmhelpers.contrib.amulet.deployment import (4from charmhelpers.contrib.amulet.deployment import (
2 AmuletDeployment5 AmuletDeployment
3)6)
@@ -16,11 +19,41 @@
16 self.openstack = openstack19 self.openstack = openstack
17 self.source = source20 self.source = source
1821
22 def _is_dev_branch(self):
23 """Determine if branch being tested is a dev (i.e. next) branch."""
24 branch = Branch.open(os.getcwd())
25 parent = branch.get_parent()
26 pattern = re.compile("^.*/next/$")
27 if (pattern.match(parent)):
28 return True
29 else:
30 return False
31
32 def _determine_branch_locations(self, other_services):
33 """Determine the branch locations for the other services.
34
35 If the branch being tested is a dev branch, then determine the
36 development branch locations for the other services. Otherwise,
37 the default charm store branches will be used."""
38 name = 0
39 if self._is_dev_branch():
40 updated_services = []
41 for svc in other_services:
42 if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']:
43 location = 'lp:charms/{}'.format(svc[name])
44 else:
45 temp = 'lp:~openstack-charmers/charms/trusty/{}/next'
46 location = temp.format(svc[name])
47 updated_services.append(svc + (location,))
48 other_services = updated_services
49 return other_services
50
19 def _add_services(self, this_service, other_services):51 def _add_services(self, this_service, other_services):
20 """Add services to the deployment and set openstack-origin."""52 """Add services to the deployment and set openstack-origin/source."""
53 name = 0
54 other_services = self._determine_branch_locations(other_services)
21 super(OpenStackAmuletDeployment, self)._add_services(this_service,55 super(OpenStackAmuletDeployment, self)._add_services(this_service,
22 other_services)56 other_services)
23 name = 0
24 services = other_services57 services = other_services
25 services.append(this_service)58 services.append(this_service)
26 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']59 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
2760
=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
--- charmhelpers/contrib/openstack/amulet/utils.py 2014-07-29 17:58:27 +0000
+++ charmhelpers/contrib/openstack/amulet/utils.py 2014-09-24 16:17:11 +0000
@@ -187,15 +187,16 @@
187187
188 f = opener.open("http://download.cirros-cloud.net/version/released")188 f = opener.open("http://download.cirros-cloud.net/version/released")
189 version = f.read().strip()189 version = f.read().strip()
190 cirros_img = "tests/cirros-{}-x86_64-disk.img".format(version)190 cirros_img = "cirros-{}-x86_64-disk.img".format(version)
191 local_path = os.path.join('tests', cirros_img)
191192
192 if not os.path.exists(cirros_img):193 if not os.path.exists(local_path):
193 cirros_url = "http://{}/{}/{}".format("download.cirros-cloud.net",194 cirros_url = "http://{}/{}/{}".format("download.cirros-cloud.net",
194 version, cirros_img)195 version, cirros_img)
195 opener.retrieve(cirros_url, cirros_img)196 opener.retrieve(cirros_url, local_path)
196 f.close()197 f.close()
197198
198 with open(cirros_img) as f:199 with open(local_path) as f:
199 image = glance.images.create(name=image_name, is_public=True,200 image = glance.images.create(name=image_name, is_public=True,
200 disk_format='qcow2',201 disk_format='qcow2',
201 container_format='bare', data=f)202 container_format='bare', data=f)

Subscribers

People subscribed via source and target branches