~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/utilities/lpwindmill.py

  • Committer: Curtis Hovey
  • Date: 2011-07-15 15:46:51 UTC
  • mto: This revision was merged to the branch mainline in revision 13449.
  • Revision ID: curtis.hovey@canonical.com-20110715154651-eahw01tqq6z60mnk
Removed code and tools that think windmill is still a test layer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
 
# GNU Affero General Public License version 3 (see the file LICENSE).
3
 
 
4
 
"""Windmill test integration wrapper for Launchpad.
5
 
 
6
 
This wrapper starts a test Launchpad instance that can be
7
 
used by Windmill.
8
 
 
9
 
If the --server-only option is given, only the Launchpad server
10
 
is started.  This allows one to invoke the windmill script multiple
11
 
time directly.
12
 
"""
13
 
 
14
 
import atexit
15
 
import sys
16
 
import time
17
 
 
18
 
import windmill.bin.windmill_bin
19
 
 
20
 
from canonical.config import config
21
 
from canonical.testing.layers import (
22
 
    BaseLayer,
23
 
    DatabaseLayer,
24
 
    GoogleServiceLayer,
25
 
    LayerProcessController,
26
 
    LibrarianLayer,
27
 
    )
28
 
 
29
 
 
30
 
def runLaunchpad():
31
 
    """Set-up the Launchpad app-server against which windmill tests are run.
32
 
    """
33
 
    config.setInstance('testrunner-appserver')
34
 
    # Hard-code the app-server configuration, since that's what can
35
 
    # work with windmill.
36
 
    sys.stderr.write('Starting up Launchpad... ')
37
 
    BaseLayer.setUp()
38
 
    DatabaseLayer.setUp()
39
 
    # The below tests installs atexit handler that will clean-up their
40
 
    # resources on. So we install only one for the Database.
41
 
    atexit.register(DatabaseLayer.tearDown)
42
 
    LibrarianLayer.setUp()
43
 
    GoogleServiceLayer.setUp()
44
 
    LayerProcessController._setConfig()
45
 
    LayerProcessController.startSMTPServer()
46
 
    LayerProcessController.startAppServer()
47
 
    sys.stderr.write('done.\n')
48
 
 
49
 
 
50
 
def runWindmill():
51
 
    """Start windmill using our command line arguments.
52
 
 
53
 
    This function exits once windmill has terminated.
54
 
    """
55
 
    # The windmill main function will interpret the command-line arguments
56
 
    # for us.
57
 
    windmill.bin.windmill_bin.main()
58
 
 
59
 
 
60
 
def waitForInterrupt():
61
 
    """Sits in a sleep loop waiting for a Ctrl-C."""
62
 
    try:
63
 
        sys.stderr.write('Waiting for Ctrl-C...\n')
64
 
        while True:
65
 
            time.sleep(10)
66
 
    except KeyboardInterrupt:
67
 
        pass
68
 
 
69
 
 
70
 
def main():
71
 
    runLaunchpad()
72
 
    if sys.argv[1] == '--server-only':
73
 
        waitForInterrupt()
74
 
    else:
75
 
        runWindmill()
76
 
    sys.stderr.write('Shutting down Launchpad...\n')