r130 - in /debtorrent/trunk: docs/epydoc.config setup.py test.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed Jun 27 06:52:03 UTC 2007


Author: camrdale-guest
Date: Wed Jun 27 06:52:03 2007
New Revision: 130

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=130
Log:
More tests and testing stuff.

Modified:
    debtorrent/trunk/docs/epydoc.config
    debtorrent/trunk/setup.py
    debtorrent/trunk/test.py

Modified: debtorrent/trunk/docs/epydoc.config
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/docs/epydoc.config?rev=130&op=diff
==============================================================================
--- debtorrent/trunk/docs/epydoc.config (original)
+++ debtorrent/trunk/docs/epydoc.config Wed Jun 27 06:52:03 2007
@@ -3,7 +3,7 @@
 # The list of objects to document.  Objects can be named using
 # dotted names, module filenames, or package directory names.
 # Alases for this option include "objects" and "values".
-modules: DebTorrent btdownloadheadless.py btlaunchmany.py bttrack.py btcompletedir.py btcopyannounce.py btmakemetafile.py btreannounce.py btrename.py btsetdebmirrors.py btshowmetainfo.py
+modules: DebTorrent btdownloadheadless.py btlaunchmany.py bttrack.py btcompletedir.py btcopyannounce.py btmakemetafile.py btreannounce.py btrename.py btsetdebmirrors.py btshowmetainfo.py test.py
 
 # The type of output that should be generated.  Should be one
 # of: html, text, latex, dvi, ps, pdf.

Modified: debtorrent/trunk/setup.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/setup.py?rev=130&op=diff
==============================================================================
--- debtorrent/trunk/setup.py (original)
+++ debtorrent/trunk/setup.py Wed Jun 27 06:52:03 2007
@@ -32,6 +32,6 @@
     scripts = ["btdownloadheadless.py", 
         "bttrack.py", "btmakemetafile.py", "btlaunchmany.py", "btcompletedir.py",
         "btreannounce.py", "btrename.py", "btshowmetainfo.py",
-        'btcopyannounce.py', 'btsetdebmirrors.py',
+        'btcopyannounce.py', 'btsetdebmirrors.py', 'test.py',
         ]
     )

Modified: debtorrent/trunk/test.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/test.py?rev=130&op=diff
==============================================================================
--- debtorrent/trunk/test.py (original)
+++ debtorrent/trunk/test.py Wed Jun 27 06:52:03 2007
@@ -9,6 +9,26 @@
 This script runs several automatic tests of some of the functionality in
 the DebTorrent programs.
 
+ at type tests: C{dictionary}
+ at var tests: all of the tests that can be run.
+    The keys are the test names (strings) which are used on the command-line
+    to identify the tests (can not be 'all' or 'help'). The values are tuples
+    with four elements: a description of the test (C{string}), the trackers
+    to start (C{dictionary}), the downloaders to start (C{dictionary}, and
+    the apt-get commands to run (C{list}).
+    
+    The trackers keys are integers, which must be in the range 1-9. The values
+    are the list of command-line options (strings) to start the tracker with.
+    
+    The downloaders keys are also integers in the range 1-9. The values are
+    tuples with 3 elements: the number of the tracker to connect to, the list
+    of command-line options to start the downloader with, and any other
+    keyword arguments to specify to the L{start_downloader} function.
+    
+    The apt-get commands' list elements are tuples with 2 elements: the
+    downloader to run the command on, and the list of command-line
+    arguments to specify to the apt-get program.
+    
 @type CWD: C{string}
 @var CWD: the working directory the script was run from
 @type apt_conf_template: C{string}
@@ -22,6 +42,130 @@
 from DebTorrent.__init__ import resetPeerIDs
 import sys, os, signal
 from traceback import print_exc
+
+tests = {'1': ('Start a single tracker and downloader, test updating and downloading ' +
+             'using the HTTPDownloader.',
+             {1: []},
+             {1: (1, [], {})},
+             [(1, ['update']), 
+              (1, ['install', 'aboot-base']),
+              (1, ['install', 'aap-doc']),
+              (1, ['install', 'ada-reference-manual']),
+              (1, ['install', 'aspectj-doc']),
+              (1, ['install', 'fop-doc']),
+              (1, ['install', 'jswat-doc']),
+              (1, ['install', 'asis-doc']),
+              (1, ['install', 'bison-doc']),
+              (1, ['install', 'crash-whitepaper']),
+              (1, ['install', 'doc-iana']),
+              ]),
+
+         '2': ('Start a single tracker and 2 downloaders, disable HTTP downloading' +
+               ' on the second one to test downloading from a peer.',
+               {1: []},
+               {1: (1, [], {}),
+                2: (1, ['--disable_http_downloader', '1'], {})},
+               [(1, ['update']),
+                (1, ['install', 'aboot-base']),
+                (1, ['install', 'aap-doc']),
+                (1, ['install', 'ada-reference-manual']),
+                (1, ['install', 'fop-doc']),
+                (1, ['install', 'jswat-doc']),
+                (1, ['install', 'bison-doc']),
+                (1, ['install', 'crash-whitepaper']),
+                (2, ['update']),
+                (2, ['install', 'aboot-base']),
+                (2, ['install', 'aap-doc']),
+                (2, ['install', 'ada-reference-manual']),
+                (2, ['install', 'fop-doc']),
+                (2, ['install', 'jswat-doc']),
+                (2, ['install', 'bison-doc']),
+                (2, ['install', 'crash-whitepaper']),
+                ]),
+                
+         '3': ('Start a single tracker and 6 downloaders, to test downloading' +
+               ' speeds from each other.',
+               {1: []},
+               {1: (1, [], {}),
+                2: (1, [], {}),
+                3: (1, [], {}),
+                4: (1, [], {}),
+                5: (1, [], {}),
+                6: (1, [], {})},
+               [(1, ['update']),
+                (1, ['install', 'aboot-base']),
+                (1, ['install', 'ada-reference-manual']),
+                (1, ['install', 'fop-doc']),
+                (1, ['install', 'doc-iana']),
+                (2, ['update']),
+                (2, ['install', 'aboot-base']),
+                (2, ['install', 'ada-reference-manual']),
+                (2, ['install', 'fop-doc']),
+                (2, ['install', 'doc-iana']),
+                (3, ['update']),
+                (3, ['install', 'aboot-base']),
+                (3, ['install', 'ada-reference-manual']),
+                (3, ['install', 'fop-doc']),
+                (3, ['install', 'doc-iana']),
+                (4, ['update']),
+                (4, ['install', 'aboot-base']),
+                (4, ['install', 'ada-reference-manual']),
+                (4, ['install', 'fop-doc']),
+                (4, ['install', 'doc-iana']),
+                (5, ['update']),
+                (5, ['install', 'aboot-base']),
+                (5, ['install', 'ada-reference-manual']),
+                (5, ['install', 'fop-doc']),
+                (5, ['install', 'doc-iana']),
+                (6, ['update']),
+                (6, ['install', 'aboot-base']),
+                (6, ['install', 'ada-reference-manual']),
+                (6, ['install', 'fop-doc']),
+                (6, ['install', 'doc-iana']),
+                ]),
+
+         '4': ('Start a single tracker and 1 downloader, requesting the same' +
+               ' packages multiple times to test caching.',
+               {1: []},
+               {1: (1, [], {})},
+               [(1, ['update']),
+                (1, ['install', 'aboot-base']),
+                (1, ['install', 'ada-reference-manual']),
+                (1, ['install', 'fop-doc']),
+                (1, ['install', 'doc-iana']),
+                (1, ['update']),
+                (1, ['install', 'aboot-base']),
+                (1, ['install', 'ada-reference-manual']),
+                (1, ['install', 'fop-doc']),
+                (1, ['install', 'doc-iana']),
+                (1, ['update']),
+                (1, ['install', 'aboot-base']),
+                (1, ['install', 'ada-reference-manual']),
+                (1, ['install', 'fop-doc']),
+                (1, ['install', 'doc-iana']),
+                ]),
+                
+         '5': ('Start a single tracker and 6 downloaders, update all to test' +
+               ' that they can all see each other.',
+               {1: []},
+               {1: (1, [], {'suites': 'contrib non-free'}),
+                2: (1, [], {'suites': 'contrib non-free'}),
+                3: (1, [], {'suites': 'contrib non-free'}),
+                4: (1, [], {'suites': 'contrib non-free'}),
+                5: (1, [], {'suites': 'contrib non-free'}),
+                6: (1, [], {'suites': 'contrib non-free'})},
+               [(1, ['update']),
+                (2, ['update']),
+                (3, ['update']),
+                (4, ['update']),
+                (5, ['update']),
+                (6, ['update']),
+                ]),
+
+         }
+
+assert 'all' not in tests
+assert 'help' not in tests
 
 CWD = os.getcwd()
 apt_conf_template = """
@@ -131,8 +275,8 @@
 def touch(path):
     """Create an empty file.
     
-    @type dir: C{list} of C{string}
-    @param dir: the path to create
+    @type path: C{list} of C{string}
+    @param path: the path to create
     
     """
     
@@ -213,8 +357,8 @@
     
     @type num_down: C{int}
     @param num_down: the number of the downloader to use
-    @type func: C{list} of C{string}
-    @param func: the arguments to pass to the apt-get process
+    @type cmd: C{list} of C{string}
+    @param cmd: the arguments to pass to the apt-get process
     @rtype: C{int}
     @return: the PID of the background process
     
@@ -250,11 +394,13 @@
     
     return os.path.join(CWD,'downloader' + str(num_down))
 
-def start_downloader(num_down, options = [], clean = True):
+def start_downloader(num_down, options = [], mirror = 'ftp.us.debian.org/debian', 
+                     suites = 'main contrib non-free', clean = True):
     """Initialize a new downloader process.
 
     The default arguments specified to the downloader invocation are
-    the configuration directory, apt port, minport and maxport. 
+    the configuration directory, apt port, minport, maxport and the
+    maximum upload rate. 
     Any additional arguments needed should be specified by L{options}.
     
     @type num_down: C{int}
@@ -262,6 +408,12 @@
     @type options: C{list} of C{string}
     @param options: the arguments to pass to the downloader
         (optional, defaults to only using the default arguments)
+    @type mirror: C{string}
+    @param mirror: the Debian mirror to use
+        (optional, defaults to 'ftp.us.debian.org/debian')
+    @type suites: C{string}
+    @param suites: space separated list of suites to download
+        (optional, defaults to 'main contrib non-free')
     @type clean: C{boolean}
     @param clean: whether to remove any previous downloader files
         (optional, defaults to removing them)
@@ -291,7 +443,7 @@
 
         # Create apt's config files
         f = open(join([downloader_dir, 'etc', 'apt', 'sources.list']), 'w')
-        f.write('deb http://localhost:' + str(num_down) + '988/ftp.us.debian.org/debian/ stable main contrib non-free\n')
+        f.write('deb http://localhost:' + str(num_down) + '988/' + mirror + '/ stable ' + suites + '\n')
         f.close()
 
         f = open(join([downloader_dir, 'etc', 'apt', 'apt.conf']), 'w')
@@ -304,6 +456,7 @@
 
     pid = start(btlaunchmany.run, ['--config_dir', downloader_dir,
                                    '--port', str(num_down) + '988', 
+                                   '--max_upload_rate', '100',
                                    '--minport', '1' + str(num_down) + '000', 
                                    '--maxport', '1' + str(num_down) + '999'] + options,
                 downloader_dir)
@@ -372,7 +525,8 @@
         sleep(5)
         
         for k, v in downloaders.items():
-            running_downloaders[k] = start_downloader(k, v[1] + ['--default_tracker', tracker_address(v[0])])
+            opts = v[1] + ['--default_tracker', tracker_address(v[0])]
+            running_downloaders[k] = start_downloader(k, opts, **v[2])
     
         sleep(10)
         
@@ -432,9 +586,9 @@
         s = str(num_down) + ': "apt-get ' + ' '.join(cmd) + '" '
         if len(apt_get_results) > i:
             (elapsed, r_value) = apt_get_results[i]
-            s += 'took ' + str(elapsed) + ' secs (' + str(r_value) + ')\n'
+            s += 'took ' + str(elapsed) + ' secs (' + str(r_value) + ')'
         else:
-            s += 'did not complete\n'
+            s += 'did not complete'
         print s
     
     return apt_get_results
@@ -452,36 +606,12 @@
     s += '  help   - display this usage information\n'
     s += '  <test> - run the <test> test (see list below for valid tests)\n\n'
     
-    for k, v in tests.items():
+    t = tests.items()
+    t.sort()
+    for k, v in t:
         s += 'test "' + str(k) + '" - ' + v[0] + '\n'
     
     return s
-
-tests = {'1': ('Start a single tracker and downloader, test updating and downloading ' +
-             'using the HTTPDownloader.',
-             {1: []},
-             {1: (1, [])},
-             [(1, ['update']), 
-              (1, ['install', 'aboot-base']),
-              (1, ['install', 'aap-doc']),
-              (1, ['install', 'ada-reference-manual']),
-              (1, ['install', 'aspectj-doc']),
-              (1, ['install', 'fop-doc']),
-              (1, ['install', 'jswat-doc']),
-              (1, ['install', 'asis-doc']),
-              (1, ['install', 'bison-doc']),
-              (1, ['install', 'crash-whitepaper']),
-              (1, ['install', 'doc-iana']),
-              ]),
-
-         '2': ('Unconfigured test.',
-               {},
-               {},
-               []),
-         }
-
-assert 'all' not in tests
-assert 'help' not in tests
 
 if __name__ == '__main__':
     if len(sys.argv) != 2:




More information about the Debtorrent-commits mailing list