Merge lp:~frankban/charms/trusty/juju-gui/config-version into lp:~juju-gui/charms/trusty/juju-gui/trunk

Proposed by Francesco Banconi
Status: Merged
Merged at revision: 223
Proposed branch: lp:~frankban/charms/trusty/juju-gui/config-version
Merge into: lp:~juju-gui/charms/trusty/juju-gui/trunk
Diff against target: 144 lines (+48/-2)
6 files modified
config.yaml (+6/-0)
config/config.js.template (+2/-1)
hooks/backend.py (+1/-0)
hooks/utils.py (+5/-1)
tests/test_backends.py (+2/-0)
tests/test_utils.py (+32/-0)
To merge this branch: bzr merge lp:~frankban/charms/trusty/juju-gui/config-version
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+244273@code.launchpad.net

Description of the change

Add the Juju version to the GUI config file.

The version can be specified using a charm option.
If not specified, the Juju version is retrieved
dynamically by calling jujud --version.

Initial implementation by Huw.

Tests: `make unittest`.

QA:
- bootstrap an environment;
- run `make deploy`;
- wait for the unit to be ready;
- run `juju ssh juju-gui/0 cat /var/lib/juju-gui/juju-gui/build-prod/juju-ui/assets/config.js`
  and check the Juju version is included in the config file;
- run `juju set juju-gui juju-core-version=42.47`;
- check the version is changed to the one specified;
- run `juju unset juju-gui juju-core-version`;
- check the correct version is back in the config file;
- destroy the environment.

Done, thank you!

https://codereview.appspot.com/188890043/

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :
Download full text (7.4 KiB)

Reviewers: mp+244273_code.launchpad.net,

Message:
Please take a look.

Description:
Add the Juju version to the GUI config file.

The version can be specified using a charm option.
If not specified, the Juju version is retrieved
dynamically by calling jujud --version.

Initial implementation by Huw.

Tests: `make unittest`.

QA:
- bootstrap an environment;
- run `make deploy`;
- wait for the unit to be ready;
- run `juju ssh juju-gui/0 cat
/var/lib/juju-gui/juju-gui/build-prod/juju-ui/assets/config.js`
   and check the Juju version is included in the config file;
- run `juju set juju-gui juju-core-version=42.47`;
- check the version is changed to the one specified;
- run `juju unset juju-gui juju-core-version`;
- check the correct version is back in the config file;
- destroy the environment.

Done, thank you!

https://code.launchpad.net/~frankban/charms/trusty/juju-gui/config-version/+merge/244273

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/188890043/

Affected files (+50, -2 lines):
   A [revision details]
   M config.yaml
   M config/config.js.template
   M hooks/backend.py
   M hooks/utils.py
   M tests/test_backends.py
   M tests/test_utils.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision:
<email address hidden>

Index: config.yaml
=== modified file 'config.yaml'
--- config.yaml 2014-11-14 11:35:36 +0000
+++ config.yaml 2014-12-10 10:19:42 +0000
@@ -193,3 +193,9 @@
        fonts will let the GUI load much faster and render properly.
      type: boolean
      default: false
+ juju-core-version:
+ description: |
+ The version of Juju tools used for the charm deployment. If left
empty,
+ the Juju version is dynamically retrieved.
+ type: string
+ default:

Index: config/config.js.template
=== modified file 'config/config.js.template'
--- config/config.js.template 2014-02-04 20:07:31 +0000
+++ config/config.js.template 2014-12-10 03:16:32 +0000
@@ -25,5 +25,6 @@
    sandbox: {{sandbox}},
    GA_key: {{ga_key}},
    login_help: {{login_help}},
- showGetJujuButton: {{show_get_juju_button}}
+ showGetJujuButton: {{show_get_juju_button}},
+ jujuCoreVersion: {{juju_core_version}}
  };

Index: hooks/backend.py
=== modified file 'hooks/backend.py'
--- hooks/backend.py 2014-11-14 09:14:54 +0000
+++ hooks/backend.py 2014-12-10 10:47:53 +0000
@@ -131,6 +131,7 @@
              build_dir, secure=config['secure'], sandbox=config['sandbox'],
              cached_fonts=config['cached-fonts'], ga_key=config['ga-key'],
              show_get_juju_button=config['show-get-juju-button'],
+ juju_core_version=config.get('juju-core-version'),
              password=config.get('password'))
          # Set up TCP ports.
          previous_port = backend.prev_config.get('port')

Index: hooks/utils.py
=== modified file 'hooks/utils.py'
--- hooks/utils.py 2014-11-14 13:14:33 +0000
+++ hooks/utils.py 2014-12-10 10:4...

Read more...

Revision history for this message
Richard Harding (rharding) wrote :
Revision history for this message
Richard Harding (rharding) wrote :

On 2014/12/10 13:10:40, rharding wrote:
> :+1: will QA

QA OK thank you! LGTM

https://codereview.appspot.com/188890043/

Revision history for this message
Francesco Banconi (frankban) wrote :

Thanks Rick for the review and QA!

https://codereview.appspot.com/188890043/

Revision history for this message
Francesco Banconi (frankban) wrote :

*** Submitted:

Add the Juju version to the GUI config file.

The version can be specified using a charm option.
If not specified, the Juju version is retrieved
dynamically by calling jujud --version.

Initial implementation by Huw.

Tests: `make unittest`.

QA:
- bootstrap an environment;
- run `make deploy`;
- wait for the unit to be ready;
- run `juju ssh juju-gui/0 cat
/var/lib/juju-gui/juju-gui/build-prod/juju-ui/assets/config.js`
   and check the Juju version is included in the config file;
- run `juju set juju-gui juju-core-version=42.47`;
- check the version is changed to the one specified;
- run `juju unset juju-gui juju-core-version`;
- check the correct version is back in the config file;
- destroy the environment.

Done, thank you!

R=rharding
CC=
https://codereview.appspot.com/188890043

https://codereview.appspot.com/188890043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-11-14 11:35:36 +0000
3+++ config.yaml 2014-12-10 11:46:31 +0000
4@@ -193,3 +193,9 @@
5 fonts will let the GUI load much faster and render properly.
6 type: boolean
7 default: false
8+ juju-core-version:
9+ description: |
10+ The version of Juju tools used for the charm deployment. If left empty,
11+ the Juju version is dynamically retrieved.
12+ type: string
13+ default:
14
15=== modified file 'config/config.js.template'
16--- config/config.js.template 2014-02-04 20:07:31 +0000
17+++ config/config.js.template 2014-12-10 11:46:31 +0000
18@@ -25,5 +25,6 @@
19 sandbox: {{sandbox}},
20 GA_key: {{ga_key}},
21 login_help: {{login_help}},
22- showGetJujuButton: {{show_get_juju_button}}
23+ showGetJujuButton: {{show_get_juju_button}},
24+ jujuCoreVersion: {{juju_core_version}}
25 };
26
27=== modified file 'hooks/backend.py'
28--- hooks/backend.py 2014-11-14 09:14:54 +0000
29+++ hooks/backend.py 2014-12-10 11:46:31 +0000
30@@ -131,6 +131,7 @@
31 build_dir, secure=config['secure'], sandbox=config['sandbox'],
32 cached_fonts=config['cached-fonts'], ga_key=config['ga-key'],
33 show_get_juju_button=config['show-get-juju-button'],
34+ juju_core_version=config.get('juju-core-version'),
35 password=config.get('password'))
36 # Set up TCP ports.
37 previous_port = backend.prev_config.get('port')
38
39=== modified file 'hooks/utils.py'
40--- hooks/utils.py 2014-11-14 13:14:33 +0000
41+++ hooks/utils.py 2014-12-10 11:46:31 +0000
42@@ -348,7 +348,7 @@
43 console_enabled, login_help, readonly, charmworld_url,
44 build_dir, secure=True, sandbox=False, cached_fonts=False,
45 show_get_juju_button=False, config_js_path=None, ga_key='',
46- password=None):
47+ juju_core_version=None, password=None):
48 """Generate the GUI configuration file."""
49 log('Generating the Juju GUI configuration file.')
50 user = 'user-admin'
51@@ -393,6 +393,9 @@
52 'using juju-quickstart '
53 '(https://launchpad.net/juju-quickstart) can automate logging '
54 'in, as well as other parts of installing and starting Juju.')
55+ if not juju_core_version:
56+ log('Retrieving Juju version.')
57+ juju_core_version = run('jujud', '--version').strip()
58
59 context = {
60 'cached_fonts': json.dumps(cached_fonts),
61@@ -409,6 +412,7 @@
62 'charmworld_url': json.dumps(charmworld_url),
63 'ga_key': json.dumps(ga_key),
64 'show_get_juju_button': json.dumps(show_get_juju_button),
65+ 'juju_core_version': json.dumps(juju_core_version),
66 }
67 if config_js_path is None:
68 config_js_path = os.path.join(
69
70=== modified file 'tests/test_backends.py'
71--- tests/test_backends.py 2014-11-14 11:26:41 +0000
72+++ tests/test_backends.py 2014-12-10 11:46:31 +0000
73@@ -147,6 +147,7 @@
74 'secure': True,
75 'serve-tests': False,
76 'show-get-juju-button': False,
77+ 'juju-core-version': '1.21',
78 'ssl-cert-path': self.ssl_cert_path,
79 }
80 if options is not None:
81@@ -200,6 +201,7 @@
82 mocks.compute_build_dir(), secure=config['secure'],
83 sandbox=config['sandbox'], cached_fonts=config['cached-fonts'],
84 ga_key=config['ga-key'],
85+ juju_core_version=config['juju-core-version'],
86 show_get_juju_button=config['show-get-juju-button'], password=None)
87
88 def test_base_dir_created(self):
89
90=== modified file 'tests/test_utils.py'
91--- tests/test_utils.py 2014-11-14 13:14:33 +0000
92+++ tests/test_utils.py 2014-12-10 11:46:31 +0000
93@@ -778,6 +778,9 @@
94
95
96 class TestStartImprovAgentGui(unittest.TestCase):
97+ # XXX frankban 2014-12-10: change this test case so that functions being
98+ # tested are better separated. Also avoid manually patching helper
99+ # functions and use the mock library instead.
100
101 def setUp(self):
102 self.service_names = []
103@@ -801,6 +804,7 @@
104
105 def run(*args):
106 self.run_call_count += 1
107+ return ''
108
109 @contextmanager
110 def su(user):
111@@ -1051,6 +1055,34 @@
112 js_conf = self.files['config']
113 self.assertIn('cachedFonts: true', js_conf)
114
115+ def test_write_gui_config_with_provided_version(self):
116+ # The Juju version is included in the GUI config file when provided as
117+ # an option.
118+ write_gui_config(
119+ False, 'This is login help.', False, False, self.charmworld_url,
120+ self.build_dir, sandbox=True, juju_core_version='1.20',
121+ config_js_path='config')
122+ self.assertIn('jujuCoreVersion: "1.20"', self.files['config'])
123+
124+ def test_write_gui_config_with_version_from_jujud(self):
125+ # If not provided as an option, the Juju version is dynamically
126+ # retrieved and included in the GUI config file.
127+ with mock.patch('utils.run', return_value='1.42.47\n'):
128+ write_gui_config(
129+ False, None, True, True, self.charmworld_url, self.build_dir,
130+ config_js_path='config')
131+ self.assertIn('jujuCoreVersion: "1.42.47"', self.files['config'])
132+
133+ def test_write_gui_config_with_provided_empty_version(self):
134+ # If the provided Juju version is empty, the Juju version is still
135+ # dynamically retrieved and included in the GUI config file.
136+ with mock.patch('utils.run', return_value='1.20.13-trusty-amd64\n'):
137+ write_gui_config(
138+ False, None, True, True, self.charmworld_url, self.build_dir,
139+ config_js_path='config', juju_core_version='')
140+ self.assertIn(
141+ 'jujuCoreVersion: "1.20.13-trusty-amd64"', self.files['config'])
142+
143
144 class TestPortInRange(unittest.TestCase):
145

Subscribers

People subscribed via source and target branches