[tor-commits] [stem/master] Testing errors when descriptors are unavailable

atagar at torproject.org atagar at torproject.org
Sun Mar 24 02:26:58 UTC 2013


commit cefe584cd57c45a77379428a4c15fb225c0afdcc
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Mar 23 19:17:31 2013 -0700

    Testing errors when descriptors are unavailable
    
    Fixing a couple testing errors spotted by Dererk. These arise when we're either
    unable to fetch descriptors (disconnected with a fresh test data directory) or
    possably if descriptors are still in the process of being fetched.
    
    ======================================================================
    ERROR: test_get_microdescriptors
    ----------------------------------------------------------------------
    Traceback:
      File "/home/dererk/stem/stem/test/integ/control/controller.py", line 843, in test_get_microdescriptors
        for desc in controller.get_microdescriptors():
      File "/home/dererk/stem/stem/stem/control.py", line 1050, in get_microdescriptors
        raise exc
    OperationFailed: Data directory doens't contain cached microescriptors
    
    ======================================================================
    FAIL: test_get_microdescriptor
    ----------------------------------------------------------------------
    Traceback:
      File "/home/dererk/stem/stem/test/integ/control/controller.py", line 823, in test_get_microdescriptor
        test_relay = self._get_router_status_entry(controller)
      File "/home/dererk/stem/stem/test/integ/control/controller.py", line 1018, in _get_router_status_entry
        self.fail("Unable to find any relays without a nickname of 'Unnamed'")
    AssertionError: Unable to find any relays without a nickname of 'Unnamed'
    
    He also got a third error that mystifies me a bit. Fingers crossed that earlier
    changes have addressed it, if not then I'll need repro steps to dig in
    further...
    
    ======================================================================
    ERROR: test_get_network_status
    ----------------------------------------------------------------------
    Traceback:
      File "/home/dererk/stem/stem/test/integ/control/controller.py", line 922, in test_get_network_status
        self.assertRaises(stem.ControllerError, controller.get_network_status, "blargg")
      File "/usr/lib/python2.7/unittest/case.py", line 476, in assertRaises
        callableObj(*args, **kwargs)
      File "/home/dererk/stem/stem/stem/control.py", line 1166, in get_network_status
        raise exc
    ValueError: Router status entries must have a 'r' line:
---
 test/integ/control/controller.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 3255fb3..d94bcd9 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -2,6 +2,7 @@
 Integration tests for the stem.control.Controller class.
 """
 
+import os
 import shutil
 import socket
 import tempfile
@@ -834,6 +835,9 @@ class TestController(unittest.TestCase):
 
     if test.runner.require_control(self):
       return
+    elif not os.path.exists(runner.get_test_dir("cached-descriptors")):
+      test.runner.skip(self, "(no cached microdescriptors)")
+      return
 
     with runner.get_tor_controller() as controller:
       count = 0
@@ -1013,6 +1017,8 @@ class TestController(unittest.TestCase):
           break
 
       if TEST_ROUTER_STATUS_ENTRY is None:
-        self.fail("Unable to find any relays without a nickname of 'Unnamed'")
+        # this is only likely to occure if we can't get descriptors
+        test.runner.skip(self, "(no named relays)")
+        return
 
     return TEST_ROUTER_STATUS_ENTRY



More information about the tor-commits mailing list