~gmb/charms/oneiric/buildbot-slave/use-builders

« back to all changes in this revision

Viewing changes to tests/open-port.py

  • Committer: Graham Binns
  • Date: 2012-02-01 17:04:49 UTC
  • Revision ID: graham@canonical.com-20120201170449-rhpk963ev56gwjr7
Added a simple script to open a port on the slave for tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# A little python script to open a port on the buildslave so that we can
 
3
# test that it's actually deployed successfully.
 
4
 
 
5
import subprocess
 
6
import SimpleHTTPServer
 
7
import SocketServer
 
8
 
 
9
PORT = 9000
 
10
 
 
11
simple_html = """
 
12
<html>
 
13
    <head>
 
14
        <title>Here's some HTML</title>
 
15
    </head>
 
16
    <body><p>The slave is UP!</p></body>
 
17
</html>
 
18
"""
 
19
 
 
20
with open('/tmp/index.html', 'w') as index_file:
 
21
    index_file.write(simple_html)
 
22
 
 
23
subprocess.call(['open-port', '9000/TCP'])
 
24
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
 
25
httpd = SocketServer.TCPServer(("", PORT), Handler)
 
26
httpd.serve_forever()