Merge lp:~nskaggs/juju-ci-tools/update-templates into lp:juju-ci-tools

Proposed by Nicholas Skaggs
Status: Rejected
Rejected by: Nicholas Skaggs
Proposed branch: lp:~nskaggs/juju-ci-tools/update-templates
Merge into: lp:juju-ci-tools
Diff against target: 179 lines (+74/-18)
4 files modified
jujupy.py (+15/-0)
template_assess.py.tmpl (+24/-11)
template_test.py.tmpl (+27/-7)
tests/test_jujupy.py (+8/-0)
To merge this branch: bzr merge lp:~nskaggs/juju-ci-tools/update-templates
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Disapprove
Review via email: mp+290664@code.launchpad.net

Description of the change

Update templates for new ci tests

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

See inline comments for design suggestions and changes.

1339. By Nicholas Skaggs

flake8 fixes

1340. By Nicholas Skaggs

kill current version, fix make_charm, move to jujupy

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Per Aaron, I'm tabling for now based on feedback. This takes the template away from the current decision to host a repository of charms, and changes how we view charms as needing 1.x and 2.x compatibility.

review: Disapprove

Unmerged revisions

1340. By Nicholas Skaggs

kill current version, fix make_charm, move to jujupy

1339. By Nicholas Skaggs

flake8 fixes

1338. By Nicholas Skaggs

only one more test hates me

1337. By Nicholas Skaggs

wip, fix unit tests

1336. By Nicholas Skaggs

add support for juju 1 and juju 2

1335. By Nicholas Skaggs

whitespace

1334. By Nicholas Skaggs

Update templates to be 2.0ish with xenial and dummy charm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'jujupy.py'
--- jujupy.py 2016-03-24 13:45:50 +0000
+++ jujupy.py 2016-04-01 21:59:37 +0000
@@ -1102,6 +1102,21 @@
1102 def add_subnet(self, subnet, space):1102 def add_subnet(self, subnet, space):
1103 self.juju('add-subnet', (subnet, space))1103 self.juju('add-subnet', (subnet, space))
11041104
1105 # nas make charm_dir sane default of temp dir
1106 # allow name to also be sane temporary default
1107 def make_charm(charm_dir, name, summary=None,
1108 description=None, series=[],
1109 min_juju_version=None):
1110 metadata = os.path.join(charm_dir, 'metadata.yaml')
1111 content = {}
1112 content['name'] = name
1113 content['summary'] = summary
1114 content['description'] = description
1115 content['min-juju-version'] = min_juju_version
1116 content['series'] = series
1117 with open(metadata, 'w') as f:
1118 yaml.safe_dump(content, f, default_flow_style=False)
1119
11051120
1106class EnvJujuClient2B2(EnvJujuClient):1121class EnvJujuClient2B2(EnvJujuClient):
11071122
11081123
=== modified file 'template_assess.py.tmpl'
--- template_assess.py.tmpl 2016-03-21 21:04:42 +0000
+++ template_assess.py.tmpl 2016-04-01 21:59:37 +0000
@@ -5,30 +5,44 @@
55
6import argparse6import argparse
7import logging7import logging
8import os
8import sys9import sys
910
11import yaml
12
10from deploy_stack import (13from deploy_stack import (
11 BootstrapManager,14 BootstrapManager,
12)15)
13from utility import (16from utility import (
14 add_basic_testing_arguments,17 add_basic_testing_arguments,
15 configure_logging,18 configure_logging,
19 temp_dir,
16)20)
1721
18
19__metaclass__ = type22__metaclass__ = type
2023
21
22log = logging.getLogger("assess_TEMPLATE")24log = logging.getLogger("assess_TEMPLATE")
2325
2426def assess_TEMPLATE(client, args):
25def assess_TEMPLATE(client):
26 # Deploy charms, there are several under ./repository27 # Deploy charms, there are several under ./repository
27 client.juju("deploy", ('local:trusty/my-charm',))28 if get_current_version(client, args.juju_bin).startswith('1.'):
28 # Wait for the deployment to finish.29 log.info("Testing TEMPLATE")
29 client.wait_for_started()30 charm_name = 'dummy'
30 log.info("TODO: Add log line about any test")31 make_charm(charm_dir, charm_name)
31 # TODO: Add specific functional testing actions here.32 client.deploy('local:' + charm_name)
33 # Wait for the deployment to finish.
34 client.wait_for_started()
35 log.info("TODO: Add log line about any test")
36 # TODO: Add specific functional testing actions here.
37 else:
38 with temp_dir() as charm_dir:
39 log.info("Testing TEMPLATE")
40 make_charm(charm_dir)
41 client.deploy(charm)
42 # Wait for the deployment to finish.
43 client.wait_for_started()
44 log.info("TODO: Add log line about any test")
45 # TODO: Add specific functional testing actions here.
3246
3347
34def parse_args(argv):48def parse_args(argv):
@@ -45,9 +59,8 @@
45 configure_logging(args.verbose)59 configure_logging(args.verbose)
46 bs_manager = BootstrapManager.from_args(args)60 bs_manager = BootstrapManager.from_args(args)
47 with bs_manager.booted_context(args.upload_tools):61 with bs_manager.booted_context(args.upload_tools):
48 assess_TEMPLATE(bs_manager.client)62 assess_TEMPLATE(bs_manager.client, args)
49 return 063 return 0
5064
51
52if __name__ == '__main__':65if __name__ == '__main__':
53 sys.exit(main())66 sys.exit(main())
5467
=== modified file 'template_test.py.tmpl'
--- template_test.py.tmpl 2015-12-16 03:59:38 +0000
+++ template_test.py.tmpl 2016-04-01 21:59:37 +0000
@@ -1,18 +1,28 @@
1"""Tests for assess_TEMPLATE module."""1"""Tests for assess_TEMPLATE module."""
22
3import logging3import logging
4from mock import Mock, patch4from mock import (
5 Mock,
6 patch,
7 call,
8)
9import os
5import StringIO10import StringIO
611
12import yaml
13
7from assess_TEMPLATE import (14from assess_TEMPLATE import (
8 assess_TEMPLATE,15 assess_TEMPLATE,
16 get_current_version,
17 make_charm,
18 main,
9 parse_args,19 parse_args,
10 main,
11)20)
12from tests import (21from tests import (
13 parse_error,22 parse_error,
14 TestCase,23 TestCase,
15)24)
25from utility import temp_dir
1626
1727
18class TestParseArgs(TestCase):28class TestParseArgs(TestCase):
@@ -55,15 +65,25 @@
55 mock_e.assert_called_once_with("an-env")65 mock_e.assert_called_once_with("an-env")
56 mock_c.assert_called_once_with(env, "/bin/juju", debug=False)66 mock_c.assert_called_once_with(env, "/bin/juju", debug=False)
57 self.assertEqual(mock_bc.call_count, 1)67 self.assertEqual(mock_bc.call_count, 1)
58 mock_assess.assert_called_once_with(client)68 mock_assess.assert_called_once_with(client, parse_args(argv))
5969
6070
61class TestAssess(TestCase):71class TestAssess(TestCase):
6272
63 def test_TEMPLATE(self):73 def test_assess_TEMPLATE(self):
74 argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
75 args = parse_args(argv)
64 mock_client = Mock(spec=["juju", "wait_for_started"])76 mock_client = Mock(spec=["juju", "wait_for_started"])
65 assess_TEMPLATE(mock_client)77 with patch("assess_TEMPLATE.get_current_version",
66 mock_client.juju.assert_called_once_with(78 autospec=True, return_value="2.0.0") as mock_gcv:
67 'deploy', ('local:trusty/my-charm',))79 with patch("assess_TEMPLATE.temp_dir",
80 autospec=True) as mock_td:
81 with patch("assess_TEMPLATE.make_charm",
82 autospec=True) as mock_mc:
83 assess_TEMPLATE(mock_client, args)
68 mock_client.wait_for_started.assert_called_once_with()84 mock_client.wait_for_started.assert_called_once_with()
85 mock_gcv.assert_called_once_with(mock_client, '/bin/juju')
86 temp_dir = mock_td.return_value.__enter__.return_value
87 call(mock_client, temp_dir)
88 self.assertEqual(mock_td.call_count, 1)
69 self.assertNotIn("TODO", self.log_stream.getvalue())89 self.assertNotIn("TODO", self.log_stream.getvalue())
7090
=== modified file 'tests/test_jujupy.py'
--- tests/test_jujupy.py 2016-03-24 13:45:50 +0000
+++ tests/test_jujupy.py 2016-04-01 21:59:37 +0000
@@ -2603,6 +2603,14 @@
2603 juju_mock.assert_called_once_with('add-subnet',2603 juju_mock.assert_called_once_with('add-subnet',
2604 ('bar-subnet', 'foo-space'))2604 ('bar-subnet', 'foo-space'))
26052605
2606 def test_make_charm(self):
2607 client = EnvJujuClient(JujuData(None, {'type': 'local'}),
2608 '1.23-series-arch', None)
2609 with patch.object(client, 'juju', autospec=True) as juju_mock:
2610 client.make_charm('/tmp/make-charm', 'foo')
2611 juju_mock.assert_called_once_with('make-charm',
2612 ('/tmp/make-charm', 'foo'))
2613
2606 def test__shell_environ_uses_pathsep(self):2614 def test__shell_environ_uses_pathsep(self):
2607 client = EnvJujuClient(JujuData('foo'), None, 'foo/bar/juju')2615 client = EnvJujuClient(JujuData('foo'), None, 'foo/bar/juju')
2608 with patch('os.pathsep', '!'):2616 with patch('os.pathsep', '!'):

Subscribers

People subscribed via source and target branches