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
1=== modified file 'charmhelpers/contrib/amulet/deployment.py'
2--- charmhelpers/contrib/amulet/deployment.py 2014-07-29 17:58:27 +0000
3+++ charmhelpers/contrib/amulet/deployment.py 2014-09-24 16:17:11 +0000
4@@ -24,10 +24,10 @@
5 """Add services.
6
7 Add services to the deployment where this_service is the local charm
8- that we're focused on testing and other_services are the other
9- charms that come from the charm store.
10+ that we're testing and other_services are the other services that
11+ are being used in the amulet tests.
12 """
13- name, units = range(2)
14+ name, units, location = range(3)
15
16 if this_service[name] != os.path.basename(os.getcwd()):
17 s = this_service[name]
18@@ -37,12 +37,13 @@
19 self.d.add(this_service[name], units=this_service[units])
20
21 for svc in other_services:
22- if self.series:
23- self.d.add(svc[name],
24- charm='cs:{}/{}'.format(self.series, svc[name]),
25- units=svc[units])
26+ if len(svc) > 2:
27+ branch_location = svc[location]
28+ elif self.series:
29+ branch_location = 'cs:{}/{}'.format(self.series, svc[name]),
30 else:
31- self.d.add(svc[name], units=svc[units])
32+ branch_location = None
33+ self.d.add(svc[name], charm=branch_location, units=svc[units])
34
35 def _add_relations(self, relations):
36 """Add all of the relations for the services."""
37@@ -57,7 +58,7 @@
38 def _deploy(self):
39 """Deploy environment and wait for all hooks to finish executing."""
40 try:
41- self.d.setup()
42+ self.d.setup(timeout=900)
43 self.d.sentry.wait(timeout=900)
44 except amulet.helpers.TimeoutError:
45 amulet.raise_status(amulet.FAIL, msg="Deployment timed out")
46
47=== modified file 'charmhelpers/contrib/openstack/amulet/deployment.py'
48--- charmhelpers/contrib/openstack/amulet/deployment.py 2014-07-29 17:58:27 +0000
49+++ charmhelpers/contrib/openstack/amulet/deployment.py 2014-09-24 16:17:11 +0000
50@@ -1,3 +1,6 @@
51+from bzrlib.branch import Branch
52+import os
53+import re
54 from charmhelpers.contrib.amulet.deployment import (
55 AmuletDeployment
56 )
57@@ -16,11 +19,41 @@
58 self.openstack = openstack
59 self.source = source
60
61+ def _is_dev_branch(self):
62+ """Determine if branch being tested is a dev (i.e. next) branch."""
63+ branch = Branch.open(os.getcwd())
64+ parent = branch.get_parent()
65+ pattern = re.compile("^.*/next/$")
66+ if (pattern.match(parent)):
67+ return True
68+ else:
69+ return False
70+
71+ def _determine_branch_locations(self, other_services):
72+ """Determine the branch locations for the other services.
73+
74+ If the branch being tested is a dev branch, then determine the
75+ development branch locations for the other services. Otherwise,
76+ the default charm store branches will be used."""
77+ name = 0
78+ if self._is_dev_branch():
79+ updated_services = []
80+ for svc in other_services:
81+ if svc[name] in ['mysql', 'mongodb', 'rabbitmq-server']:
82+ location = 'lp:charms/{}'.format(svc[name])
83+ else:
84+ temp = 'lp:~openstack-charmers/charms/trusty/{}/next'
85+ location = temp.format(svc[name])
86+ updated_services.append(svc + (location,))
87+ other_services = updated_services
88+ return other_services
89+
90 def _add_services(self, this_service, other_services):
91- """Add services to the deployment and set openstack-origin."""
92+ """Add services to the deployment and set openstack-origin/source."""
93+ name = 0
94+ other_services = self._determine_branch_locations(other_services)
95 super(OpenStackAmuletDeployment, self)._add_services(this_service,
96 other_services)
97- name = 0
98 services = other_services
99 services.append(this_service)
100 use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph']
101
102=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
103--- charmhelpers/contrib/openstack/amulet/utils.py 2014-07-29 17:58:27 +0000
104+++ charmhelpers/contrib/openstack/amulet/utils.py 2014-09-24 16:17:11 +0000
105@@ -187,15 +187,16 @@
106
107 f = opener.open("http://download.cirros-cloud.net/version/released")
108 version = f.read().strip()
109- cirros_img = "tests/cirros-{}-x86_64-disk.img".format(version)
110+ cirros_img = "cirros-{}-x86_64-disk.img".format(version)
111+ local_path = os.path.join('tests', cirros_img)
112
113- if not os.path.exists(cirros_img):
114+ if not os.path.exists(local_path):
115 cirros_url = "http://{}/{}/{}".format("download.cirros-cloud.net",
116 version, cirros_img)
117- opener.retrieve(cirros_url, cirros_img)
118+ opener.retrieve(cirros_url, local_path)
119 f.close()
120
121- with open(cirros_img) as f:
122+ with open(local_path) as f:
123 image = glance.images.create(name=image_name, is_public=True,
124 disk_format='qcow2',
125 container_format='bare', data=f)

Subscribers

People subscribed via source and target branches