~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!${buildout:executable} -S
#
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Kill all the test services that may persist between test runs."""

# Initialize our paths.
${python-relative-path-setup}
import sys
sys.path.insert(0, ${scripts:parts-directory|path-repr})
import site

# Tell canonical.config to use the testrunner config instance, so that
# we don't kill the real services.
from canonical.config import config
config.setInstance('testrunner')
config.generate_overrides()

import sys

from canonical.testing.layers import MemcachedLayer
from canonical.librarian.ftests.harness import (
    LibrarianTestSetup, TacLibrarianTestSetup)
from lp.services.osutils import kill_by_pidfile


def main(args):
    if '-h' in args or '--help' in args:
        print __doc__
        return 0
    print "Killing Memcached....",
    kill_by_pidfile(MemcachedLayer.getPidFile())
    print "done."
    print "Killing Librarian....",
    TacLibrarianTestSetup().tearDown()
    LibrarianTestSetup().tearDownRoot()
    print "done."
    return 0


if __name__ == '__main__':
    sys.exit(main(sys.argv[1:]))