Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2512)

Side by Side Diff: tests/20-functional.test

Issue 33230043: Use a random service name for tests.
Patch Set: Use a random service name for tests. Created 10 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!tests/.venv/bin/python 1 #!tests/.venv/bin/python
2 2
3 # This file is part of the Juju GUI, which lets users view and manage Juju 3 # This file is part of the Juju GUI, which lets users view and manage Juju
4 # environments within a graphical interface (https://launchpad.net/juju-gui). 4 # environments within a graphical interface (https://launchpad.net/juju-gui).
5 # Copyright (C) 2012-2013 Canonical Ltd. 5 # Copyright (C) 2012-2013 Canonical Ltd.
6 # 6 #
7 # This program is free software: you can redistribute it and/or modify it under 7 # This program is free software: you can redistribute it and/or modify it under
8 # the terms of the GNU Affero General Public License version 3, as published by 8 # the terms of the GNU Affero General Public License version 3, as published by
9 # the Free Software Foundation. 9 # the Free Software Foundation.
10 # 10 #
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 def juju_deploy(self, *args, **kwargs): 138 def juju_deploy(self, *args, **kwargs):
139 """Shim in our additional cleanup for pyJuju.""" 139 """Shim in our additional cleanup for pyJuju."""
140 # XXX 2012-11-29 frankban bug=872264: 140 # XXX 2012-11-29 frankban bug=872264:
141 # Just invoking ``juju destroy-service juju-gui`` in tearDown 141 # Just invoking ``juju destroy-service juju-gui`` in tearDown
142 # should execute the ``stop`` hook, stopping all the services 142 # should execute the ``stop`` hook, stopping all the services
143 # started by the charm in the machine. Right now this does not 143 # started by the charm in the machine. Right now this does not
144 # work in pyJuju, so the desired effect is achieved by keeping 144 # work in pyJuju, so the desired effect is achieved by keeping
145 # track of started services and manually stopping them here. 145 # track of started services and manually stopping them here.
146 # Once pyJuju works correctly or we drop support for it altogether, we 146 # Once pyJuju works correctly or we drop support for it altogether, we
147 # can remove this shim. 147 # can remove this shim.
148 unit_info = juju_deploy(*args, **kwargs) 148 unit_info, self.service_name = juju_deploy(*args, **kwargs)
benji 2013/11/26 20:21:31 Now that juju_deploy returns the service name, we
149 if is_legacy_juju: 149 if is_legacy_juju:
150 hostname = unit_info['public-address'] 150 hostname = unit_info['public-address']
151 options = kwargs.get('options', {}) 151 options = kwargs.get('options', {})
152 # Either stop the builtin server or the old apache2/haproxy setup. 152 # Either stop the builtin server or the old apache2/haproxy setup.
153 if options.get('builtin-server') == 'true': 153 if options.get('builtin-server') == 'true':
154 services = ['guiserver'] 154 services = ['guiserver']
155 else: 155 else:
156 services = ['haproxy', 'apache2'] 156 services = ['haproxy', 'apache2']
157 # Staging uses improv, otherwise the API agent is used. 157 # Staging uses improv, otherwise the API agent is used.
158 if options.get('staging') == 'true': 158 if options.get('staging') == 'true':
159 services.append('juju-api-improv') 159 services.append('juju-api-improv')
160 else: 160 else:
161 services.append('juju-api-agent') 161 services.append('juju-api-agent')
162 self.addCleanup(stop_services, hostname, services) 162 self.addCleanup(stop_services, hostname, services)
163 return unit_info 163 return unit_info
164 164
165 165
166 class TestDeploy(DeployTestMixin, unittest.TestCase): 166 class TestDeploy(DeployTestMixin, unittest.TestCase):
167 167
168 def tearDown(self): 168 def tearDown(self):
169 juju_destroy_service(self.charm) 169 juju_destroy_service(self.service_name)
bac 2013/11/26 20:35:46 That clearly looked silly before.
170 170
171 def test_local_release(self): 171 def test_local_release(self):
172 # Ensure the Juju GUI and API agent services are correctly set up when 172 # Ensure the Juju GUI and API agent services are correctly set up when
173 # deploying the local release. 173 # deploying the local release.
174 unit_info = self.juju_deploy(self.charm) 174 unit_info = self.juju_deploy(self.charm)
175 hostname = unit_info['public-address'] 175 hostname = unit_info['public-address']
176 self.navigate_to(hostname) 176 self.navigate_to(hostname)
177 self.handle_browser_warning() 177 self.handle_browser_warning()
178 self.assertEnvironmentIsConnected() 178 self.assertEnvironmentIsConnected()
179 179
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 message = 'ADDRESS in check-app-access.sh is not accessible.' 256 message = 'ADDRESS in check-app-access.sh is not accessible.'
257 self.assertEqual(200, conn.getresponse().status, message) 257 self.assertEqual(200, conn.getresponse().status, message)
258 258
259 259
260 class TestBuiltinServer(DeployTestMixin, unittest.TestCase): 260 class TestBuiltinServer(DeployTestMixin, unittest.TestCase):
261 261
262 @classmethod 262 @classmethod
263 def setUpClass(cls): 263 def setUpClass(cls):
264 # Deploy the charm. The resulting service is used by all the tests 264 # Deploy the charm. The resulting service is used by all the tests
265 # in this test case. 265 # in this test case.
266 unit_info = juju_deploy(cls.charm) 266 unit_info, cls.service_name = juju_deploy(cls.charm)
267 cls.hostname = unit_info['public-address'] 267 cls.hostname = unit_info['public-address']
268 # The counter is used to produce API request identifiers. 268 # The counter is used to produce API request identifiers.
269 cls.counter = itertools.count() 269 cls.counter = itertools.count()
270 270
271 @classmethod 271 @classmethod
272 def tearDownClass(cls): 272 def tearDownClass(cls):
273 # Destroy the GUI service, and perform additional clean up in the case 273 # Destroy the GUI service, and perform additional clean up in the case
274 # we are in a pyJuju environment. 274 # we are in a pyJuju environment.
275 juju_destroy_service(cls.charm) 275 juju_destroy_service(cls.service_name)
276 if is_legacy_juju: 276 if is_legacy_juju:
277 # XXX 2012-11-29 frankban bug=872264: 277 # XXX 2012-11-29 frankban bug=872264:
278 # see DeployTestMixin.juju_deploy above. 278 # see DeployTestMixin.juju_deploy above.
279 stop_services(cls.hostname, ['guiserver', 'juju-api-agent']) 279 stop_services(cls.hostname, ['guiserver', 'juju-api-agent'])
280 280
281 def make_websocket_client(self, authenticated=True): 281 def make_websocket_client(self, authenticated=True):
282 """Create and return a WebSocket client connected to the Juju backend. 282 """Create and return a WebSocket client connected to the Juju backend.
283 283
284 If authenticated is set to True, also log in to the Juju API server. 284 If authenticated is set to True, also log in to the Juju API server.
285 """ 285 """
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 }) 475 })
476 self.assertIn('LastChanges', response['Response']) 476 self.assertIn('LastChanges', response['Response'])
477 changes = response['Response']['LastChanges'] 477 changes = response['Response']['LastChanges']
478 self.assertEqual(2, len(changes)) 478 self.assertEqual(2, len(changes))
479 statuses = [change['Status'] for change in changes] 479 statuses = [change['Status'] for change in changes]
480 self.assertEqual(['completed', 'completed'], statuses) 480 self.assertEqual(['completed', 'completed'], statuses)
481 481
482 482
483 if __name__ == '__main__': 483 if __name__ == '__main__':
484 unittest.main(verbosity=2) 484 unittest.main(verbosity=2)
OLDNEW
« no previous file with comments | « [revision details] ('k') | tests/deploy.py » ('j') | tests/deploy.py » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b