Merge lp:~bloodearnest/juju-deployer/annotate-branches into lp:juju-deployer

Proposed by Simon Davy on 2014-10-22
Status: Approved
Approved by: Kapil Thangavelu on 2015-07-02
Approved revision: 130
Proposed branch: lp:~bloodearnest/juju-deployer/annotate-branches
Merge into: lp:juju-deployer
Diff against target: 100 lines (+38/-2) (has conflicts)
5 files modified
deployer/action/importer.py (+12/-0)
deployer/tests/test_data/wiki-branch.yaml (+5/-0)
deployer/tests/test_data/wiki.yaml (+1/-1)
deployer/tests/test_guiserver.py (+1/-1)
deployer/tests/test_importer.py (+19/-0)
Text conflict in deployer/action/importer.py
To merge this branch: bzr merge lp:~bloodearnest/juju-deployer/annotate-branches
Reviewer Review Type Date Requested Status
Kapil Thangavelu 2014-10-22 Approve on 2015-07-02
Review via email: mp+239270@code.launchpad.net

Commit Message

Annotate a service with the branch information on deploy.

Description of the Change

Annotate a service with the branch information on deploy.

This lays the ground work for being able to produce upgrade charms in diff.

To post a comment you must log in.
Kapil Thangavelu (hazmat) wrote :

so a minor on this would be to actually record the vcs revision in the annotation with charm.get_vcs().get_cur_rev() added to the annotation.

Kapil Thangavelu (hazmat) wrote :

this branch also setups a test with a nonsensical config by specifying a branch for a store charm.

Simon Davy (bloodearnest) wrote :

On Tue, Feb 3, 2015 at 12:09 PM, Kapil Thangavelu
<email address hidden> wrote:
> so a minor on this would be to actually record the vcs revision in the annotation with charm.get_vcs().get_cur_rev() added to the annotation.

good idea, will do.

Simon Davy (bloodearnest) wrote :

On Tue, Feb 3, 2015 at 12:57 PM, Kapil Thangavelu
<email address hidden> wrote:
> this branch also setups a test with a nonsensical config by specifying a branch for a store charm.

Right, I will copy the test-wiki fixture and change to non-cs charm.

Simon Davy (bloodearnest) wrote :

Hi Kapil

Have addressed review comments, let me know if there's anything else.

The only thing I would like to be able to do is annotate branch/revision when deploying directly from the store, perhaps we can use the store api to get the bzr revision that a particular store revision matches up to, i dunno.

Kapil Thangavelu (hazmat) wrote :

lgtm

review: Approve
Kapil Thangavelu (hazmat) wrote :

The branch seems to be referencing a test data file that is not in the branch

131. By Simon Davy on 2015-07-16

add missing test data file

132. By Simon Davy on 2015-07-16

fix local repo clean up

Simon Davy (bloodearnest) wrote :

I've added the file that was missing, and fixed test clean up issue, should be good to go

Unmerged revisions

132. By Simon Davy on 2015-07-16

fix local repo clean up

131. By Simon Davy on 2015-07-16

add missing test data file

130. By Simon Davy on 2015-03-30

merge upstream and fix review comments

129. By Simon Davy on 2014-10-22

whitespace clean up

128. By Simon Davy on 2014-10-22

whitespace clean up

127. By Simon Davy on 2014-10-22

add branch annotations on deploy

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/action/importer.py'
2--- deployer/action/importer.py 2015-05-28 13:04:30 +0000
3+++ deployer/action/importer.py 2015-07-16 15:16:39 +0000
4@@ -109,6 +109,7 @@
5 if machines:
6 self.log.info("Creating machines...")
7 for machine_name, spec in machines.items():
8+<<<<<<< TREE
9 if self.machine_exists(machine_name):
10 self.log.info(
11 """Machine %s already exists on environment, """
12@@ -119,6 +120,10 @@
13 self.log.info("Machine %s will be created" % machine_name)
14 self.machines[machine_name] = self.env.add_machine(
15 series=spec.get('series',
16+=======
17+ self.machines[machine_name] = self.env.add_machine(
18+ series=spec.get('series',
19+>>>>>>> MERGE-SOURCE
20 self.deployment.data['series']),
21 constraints=spec.get('constraints'))
22
23@@ -227,6 +232,13 @@
24 self.log.debug(" Setting annotations")
25 self.env.set_annotation(svc.name, svc.annotations)
26
27+ if charm.branch:
28+ self.log.debug(" Setting branch annotation to " + charm.branch)
29+ self.env.set_annotation(svc.name, {
30+ 'branch': charm.branch.split('@', 1)[0],
31+ 'revision': charm.get_vcs().get_cur_rev(),
32+ })
33+
34 if self.options.deploy_delay:
35 self.log.debug(" Waiting for deploy delay")
36 time.sleep(self.options.deploy_delay)
37
38=== added file 'deployer/tests/test_data/wiki-branch.yaml'
39--- deployer/tests/test_data/wiki-branch.yaml 1970-01-01 00:00:00 +0000
40+++ deployer/tests/test_data/wiki-branch.yaml 2015-07-16 15:16:39 +0000
41@@ -0,0 +1,5 @@
42+wiki-branch:
43+ series: precise
44+ services:
45+ wiki:
46+ branch: lp:charms/precise/mediawiki@80
47
48=== modified file 'deployer/tests/test_data/wiki.yaml'
49--- deployer/tests/test_data/wiki.yaml 2014-02-22 23:11:02 +0000
50+++ deployer/tests/test_data/wiki.yaml 2015-07-16 15:16:39 +0000
51@@ -8,4 +8,4 @@
52 db:
53 charm: cs:precise/mysql
54 relations:
55- - [wiki, db]
56\ No newline at end of file
57+ - [wiki, db]
58
59=== modified file 'deployer/tests/test_guiserver.py'
60--- deployer/tests/test_guiserver.py 2015-03-17 10:40:34 +0000
61+++ deployer/tests/test_guiserver.py 2015-07-16 15:16:39 +0000
62@@ -219,7 +219,7 @@
63 def cleanup_series_path(self):
64 """Remove the series path created by the Deployment object."""
65 if os.path.isdir('precise'):
66- os.rmdir('precise')
67+ shutil.rmtree('precise', ignore_errors=True)
68
69 @mock.patch('deployer.guiserver.Importer')
70 def test_importing_bundle(self, mock_importer, mock_environment):
71
72=== modified file 'deployer/tests/test_importer.py'
73--- deployer/tests/test_importer.py 2015-05-13 14:06:34 +0000
74+++ deployer/tests/test_importer.py 2015-07-16 15:16:39 +0000
75@@ -66,6 +66,25 @@
76
77 @skip_if_offline
78 @mock.patch('deployer.action.importer.time')
79+ def test_importer_annotations(self, mock_time):
80+ stack = ConfigStack(
81+ [os.path.join(self.test_data_dir, 'wiki-branch.yaml')]
82+ )
83+ deploy = stack.get('wiki-branch')
84+ env = mock.MagicMock()
85+ importer = Importer(env, deploy, self.options)
86+ importer.run()
87+
88+ env.set_annotation.assert_called_once_with(
89+ 'wiki',
90+ {
91+ 'branch': 'lp:charms/precise/mediawiki',
92+ 'revision': '80',
93+ }
94+ )
95+
96+ @skip_if_offline
97+ @mock.patch('deployer.action.importer.time')
98 def test_importer_no_relations(self, mock_time):
99 self.options.no_relations = True
100 stack = ConfigStack(self.options.configs)

Subscribers

People subscribed via source and target branches