OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Setups a local Rietveld instance to test against a live server for | 6 """Setups a local Rietveld instance to test against a live server for |
7 integration tests. | 7 integration tests. |
8 | 8 |
9 It makes sure Google AppEngine SDK is found, download Rietveld and Django code | 9 It makes sure Google AppEngine SDK is found, download Rietveld and Django code |
10 if necessary and starts the server on a free inbound TCP port. | 10 if necessary and starts the server on a free inbound TCP port. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 else: | 89 else: |
90 pipe = subprocess2.VOID | 90 pipe = subprocess2.VOID |
91 cmd = [ | 91 cmd = [ |
92 sys.executable, | 92 sys.executable, |
93 self.dev_app, | 93 self.dev_app, |
94 '--skip_sdk_update_check', | 94 '--skip_sdk_update_check', |
95 '.', | 95 '.', |
96 '--port=%d' % self.port, | 96 '--port=%d' % self.port, |
97 '--datastore_path=' + os.path.join(self.rietveld, 'tmp.db'), | 97 '--datastore_path=' + os.path.join(self.rietveld, 'tmp.db'), |
98 '-c'] | 98 '-c'] |
| 99 |
| 100 # CHEAP TRICK |
| 101 # By default you only want to bind on loopback but I'm testing over a |
| 102 # headless computer so it's useful to be able to access the test instance |
| 103 # remotely. |
| 104 if os.environ.get('GAE_LISTEN_ALL', '') == 'true': |
| 105 cmd.extend(('-a', '0.0.0.0')) |
| 106 |
99 self.test_server = subprocess2.Popen( | 107 self.test_server = subprocess2.Popen( |
100 cmd, stdout=pipe, stderr=pipe, cwd=self.rietveld) | 108 cmd, stdout=pipe, stderr=pipe, cwd=self.rietveld) |
101 # Loop until port 127.0.0.1:port opens or the process dies. | 109 # Loop until port 127.0.0.1:port opens or the process dies. |
102 while not test_port(self.port): | 110 while not test_port(self.port): |
103 self.test_server.poll() | 111 self.test_server.poll() |
104 if self.test_server.returncode is not None: | 112 if self.test_server.returncode is not None: |
105 raise Failure( | 113 raise Failure( |
106 'Test rietveld instance failed early on port %s' % | 114 'Test rietveld instance failed early on port %s' % |
107 self.port) | 115 self.port) |
108 time.sleep(0.01) | 116 time.sleep(0.01) |
(...skipping 17 matching lines...) Expand all Loading... |
126 instance.start_server(verbose=options.verbose) | 134 instance.start_server(verbose=options.verbose) |
127 print 'Local rietveld instance started on port %d' % instance.port | 135 print 'Local rietveld instance started on port %d' % instance.port |
128 while True: | 136 while True: |
129 time.sleep(0.1) | 137 time.sleep(0.1) |
130 finally: | 138 finally: |
131 instance.stop_server() | 139 instance.stop_server() |
132 | 140 |
133 | 141 |
134 if __name__ == '__main__': | 142 if __name__ == '__main__': |
135 main() | 143 main() |
OLD | NEW |