~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: John Arbash Meinel
  • Date: 2011-02-10 23:06:59 UTC
  • mfrom: (423.2.8 load-test)
  • Revision ID: john@arbash-meinel.com-20110210230659-ejcgl2r4z768beho
Land the load-test code into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009, 2010 Canonical Ltd
 
1
# Copyright 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
38
38
if __name__ == 'bzrlib.plugins.loggerhead':
39
39
    import bzrlib
40
40
    from bzrlib.api import require_any_api
 
41
    from bzrlib import commands
41
42
 
42
43
    require_any_api(bzrlib, bzr_compatible_versions)
43
44
 
93
94
 
94
95
    transport_server_registry.register('http', serve_http, help=HELP)
95
96
 
 
97
    class cmd_load_test_loggerhead(commands.Command):
 
98
        """Run a load test against a live loggerhead instance.
 
99
 
 
100
        Pass in the name of a script file to run. See loggerhead/load_test.py
 
101
        for a description of the file format.
 
102
        """
 
103
 
 
104
        takes_args = ["filename"]
 
105
 
 
106
        def run(self, filename):
 
107
            from bzrlib.plugins.loggerhead.loggerhead import load_test
 
108
            script = load_test.run_script(filename)
 
109
            for thread_id in sorted(script._threads):
 
110
                worker = script._threads[thread_id][0]
 
111
                for url, success, time in worker.stats:
 
112
                    self.outf.write(' %5.3fs %s %s\n'
 
113
                                    % (time, str(success)[0], url))
 
114
 
 
115
    commands.register_command(cmd_load_test_loggerhead)
 
116
 
96
117
    def load_tests(standard_tests, module, loader):
97
118
        _ensure_loggerhead_path()
98
119
        standard_tests.addTests(loader.loadTestsFromModuleNames(