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

Side by Side Diff: tests/deploy.test

Issue 6940084: Serve the GUI assets over HTTPS
Patch Set: Serve the GUI assets over HTTPS Created 12 years, 3 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
« no previous file with comments | « revision ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 #-*- python -*- 2 #-*- python -*-
3 3
4 import time 4 import time
5 import unittest 5 import unittest
6 import urllib2 6 import urllib2
7 7
8 from charmhelpers import make_charm_config_file 8 from charmhelpers import make_charm_config_file
9 from shelltoolbox import command 9 from shelltoolbox import command
10 10
(...skipping 17 matching lines...) Expand all
28 except urllib2.URLError as err: 28 except urllib2.URLError as err:
29 retries -= 1 29 retries -= 1
30 time.sleep(0.5) 30 time.sleep(0.5)
31 raise err 31 raise err
32 32
33 33
34 class DeployTestMixin(object): 34 class DeployTestMixin(object):
35 35
36 def setUp(self): 36 def setUp(self):
37 self.charm = 'juju-gui' 37 self.charm = 'juju-gui'
38 self.port = '80' 38 self.port = '443'
39 39
40 def tearDown(self): 40 def tearDown(self):
41 juju('destroy-service', self.charm) 41 juju('destroy-service', self.charm)
42 42
43 def stop_services(self, hostname, services): 43 def stop_services(self, hostname, services):
44 # XXX 2012-11-29 frankban bug=872264: 44 # XXX 2012-11-29 frankban bug=872264:
45 # Just invoking ``juju destroy-service juju-gui`` in tearDown 45 # Just invoking ``juju destroy-service juju-gui`` in tearDown
46 # should execute the ``stop`` hook, stopping all the services 46 # should execute the ``stop`` hook, stopping all the services
47 # started by the charm in the machine. Right now this does not 47 # started by the charm in the machine. Right now this does not
48 # work, so the same behavior is accomplished keeping track of 48 # work, so the same behavior is accomplished keeping track of
49 # started services and manually stopping them here. 49 # started services and manually stopping them here.
50 target = 'ubuntu@{0}'.format(hostname) 50 target = 'ubuntu@{0}'.format(hostname)
51 for service in services: 51 for service in services:
52 ssh(target, 'sudo', 'service', service, 'stop') 52 ssh(target, 'sudo', 'service', service, 'stop')
53 53
54 def check_services(self, hostname, ws_port=8080): 54 def check_services(self, hostname, ws_port=8080):
55 """Check the services are listening on their tcp ports.""" 55 """Check the services are listening on their tcp ports."""
56 url = 'http://{0}:{1}'.format(hostname, self.port) 56 url = 'https://{0}:{1}'.format(hostname, self.port)
57 response = open_url(url) 57 response = open_url(url)
58 self.assertEqual(200, response.getcode()) 58 self.assertEqual(200, response.getcode())
59 ws_url = 'http://{0}:{1}/ws'.format(hostname, ws_port) 59 ws_url = 'http://{0}:{1}/ws'.format(hostname, ws_port)
60 # A bad request status code here means the websocket resource is found. 60 # A bad request status code here means the websocket resource is found.
61 # It would take an actual websocket client to properly interact with 61 # It would take an actual websocket client to properly interact with
62 # the websocket server. 62 # the websocket server.
63 with self.assertRaises(urllib2.HTTPError) as context_manager: 63 with self.assertRaises(urllib2.HTTPError) as context_manager:
64 open_url(ws_url) 64 open_url(ws_url)
65 self.assertEqual(400, context_manager.exception.getcode()) 65 self.assertEqual(400, context_manager.exception.getcode())
66 66
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 # the Juju bootstrap node. 136 # the Juju bootstrap node.
137 hostname = self.deploy_to() 137 hostname = self.deploy_to()
138 # XXX 2012-11-29 frankban bug=872264: see *stop_services* above. 138 # XXX 2012-11-29 frankban bug=872264: see *stop_services* above.
139 self.addCleanup( 139 self.addCleanup(
140 self.stop_services, hostname, ['juju-api-agent', 'juju-gui']) 140 self.stop_services, hostname, ['juju-api-agent', 'juju-gui'])
141 self.check_services(hostname) 141 self.check_services(hostname)
142 142
143 143
144 if __name__ == '__main__': 144 if __name__ == '__main__':
145 unittest.main(verbosity=2) 145 unittest.main(verbosity=2)
OLDNEW
« no previous file with comments | « revision ('k') | no next file » | no next file with comments »

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