[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Integ test with bridge extra-info content



commit 860cd87212d6caca7f23423940ed1807cf3f0f84
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Jun 10 13:58:23 2012 -0700

    Integ test with bridge extra-info content
    
    Adding a bridge extra-info descriptor from metrics. I'm currently being a bit
    lazy and only parsing some of the mapping fields. The rest should be covered
    by unit tests, so I'll only add the rest if this ends up bitting us.
---
 stem/descriptor/extrainfo_descriptor.py            |    2 +-
 .../descriptor/data/extrainfo_bridge_descriptor    |   22 ++++++
 test/integ/descriptor/data/extrainfo_descriptor    |   13 ---
 .../descriptor/data/extrainfo_relay_descriptor     |   13 +++
 test/integ/descriptor/extrainfo_descriptor.py      |   78 +++++++++++++++++++-
 5 files changed, 112 insertions(+), 16 deletions(-)

diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 0515099..257b747 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -727,7 +727,7 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
       "router-signature",
     )
     
-    filter(lambda e: not e in excluded_fields, REQUIRED_FIELDS)
+    return filter(lambda e: not e in excluded_fields, REQUIRED_FIELDS)
   
   def _last_keyword(self):
     return None
diff --git a/test/integ/descriptor/data/extrainfo_bridge_descriptor b/test/integ/descriptor/data/extrainfo_bridge_descriptor
new file mode 100644
index 0000000..e78c354
--- /dev/null
+++ b/test/integ/descriptor/data/extrainfo_bridge_descriptor
@@ -0,0 +1,22 @@
+@type bridge-extra-info 1.0
+extra-info ec2bridgereaac65a3 1EC248422B57D9C0BD751892FE787585407479A4
+published 2012-06-08 02:21:27
+write-history 2012-06-08 02:10:38 (900 s) 343040,991232,5649408,49548288,24411136,486400,465920,975872,930816,758784,5650432,1844224,4387840,7417856,789504,623616,7376896,3940352,10039296,6054912,2051072,462848,4260864,5298176,500736,717824,714752,1370112,760832,576512,1521664,3986432,724992,615424,7079936,20995072,17465344,2592768,1014784,3082240,11468800,2770944,5660672,7646208,3385344,5404672,1158144,7741440,3275776,5239808,5291008,2197504,6070272,4919296,1180672,2245632,2362368,1641472,6153216,4660224,9184256,1488896,9736192,768000,65536,176128,2268160,3023872,704512,905216,866304,2375680,3688448,5181440,5433344,5259264,8285184,9391104,7015424,7180288,3436544,3713024,4473856,10705920,10529792,3154944,1815552,3443712,4566016,2668544,2688000,2391040,3181568,2749440,3214336,8974336
+read-history 2012-06-08 02:10:38 (900 s) 337920,437248,3995648,48726016,24125440,479232,477184,1010688,988160,772096,6388736,776192,3093504,7187456,787456,657408,7360512,3588096,9319424,5211136,2034688,474112,4222976,5154816,490496,1878016,610304,757760,667648,593920,1484800,3638272,1307648,672768,6614016,19262464,14863360,2612224,525312,1494016,11119616,3160064,1986560,5619712,3290112,5457920,1145856,7060480,3262464,5570560,5933056,2245632,4548608,3614720,829440,1765376,2379776,2531328,4306944,4244480,9225216,1054720,9806848,880640,66560,192512,2135040,3038208,830464,804864,941056,2386944,3660800,4835328,6406144,5152768,8714240,9145344,6902784,6781952,3648512,3876864,5474304,9958400,10851328,3322880,2239488,4790272,4343808,2404352,2615296,1551360,3295232,2869248,2924544,4941824
+dirreq-write-history 2012-06-08 02:10:38 (900 s) 5120,664576,2419712,578560,3072,5120,5120,3072,11264,5120,54272,1130496,1381376,202752,47104,0,6144,1064960,716800,835584,2048,0,3072,128000,4096,1024,222208,604160,129024,7168,118784,353280,0,0,761856,2236416,2574336,3072,526336,2037760,214016,726016,3592192,2205696,134144,1024,86016,656384,8192,9216,402432,14336,1617920,1436672,445440,481280,7168,1024,1959936,442368,14336,544768,4096,1024,0,4096,1052672,78848,0,223232,51200,5120,5120,1191936,1024,579584,2048,231424,68608,1305600,38912,4096,8192,1433600,5120,4096,330752,574464,382976,225280,940032,1185792,6144,1024,374784,4173824
+dirreq-read-history 2012-06-08 02:10:38 (900 s) 0,71680,99328,25600,0,0,0,0,0,0,3072,45056,74752,13312,2048,0,0,69632,18432,39936,0,0,0,8192,0,0,16384,25600,9216,0,7168,8192,0,0,96256,92160,138240,0,18432,128000,0,81920,149504,113664,8192,0,11264,46080,2048,0,25600,0,75776,77824,0,6144,19456,0,58368,14336,0,21504,0,0,0,0,25600,6144,0,0,5120,4096,0,54272,0,23552,0,0,4096,64512,2048,0,0,34816,0,0,6144,8192,10240,0,31744,48128,0,0,10240,236544
+geoip-db-digest A27BE984989AB31C50D0861C7106B17A7EEC3756
+dirreq-stats-end 2012-06-07 06:33:46 (86400 s)
+dirreq-v3-ips 
+dirreq-v2-ips 
+dirreq-v3-reqs 
+dirreq-v2-reqs 
+dirreq-v3-resp ok=72,not-enough-sigs=0,unavailable=0,not-found=0,not-modified=0,busy=0
+dirreq-v2-resp ok=0,unavailable=0,not-found=0,not-modified=0,busy=0
+dirreq-v3-direct-dl complete=0,timeout=0,running=0
+dirreq-v2-direct-dl complete=0,timeout=0,running=0
+dirreq-v3-tunneled-dl complete=68,timeout=4,running=0,min=2626,d1=7795,d2=14369,q1=18695,d3=29117,d4=52562,md=70626,d6=102271,d7=164175,q3=181522,d8=271682,d9=563791,max=32136142
+dirreq-v2-tunneled-dl complete=0,timeout=0,running=0
+bridge-stats-end 2012-06-07 06:33:53 (86400 s)
+bridge-ips cn=16,ir=16,sy=16,us=16,??=8,bn=8,br=8,by=8,cu=8,dk=8,dz=8,es=8,lb=8,ph=8,sd=8,tw=8
+router-digest 00A2AECCEAD3FEE033CFE29893387143146728EC
diff --git a/test/integ/descriptor/data/extrainfo_descriptor b/test/integ/descriptor/data/extrainfo_descriptor
deleted file mode 100644
index ecaabe0..0000000
--- a/test/integ/descriptor/data/extrainfo_descriptor
+++ /dev/null
@@ -1,13 +0,0 @@
-@type extra-info 1.0
-extra-info NINJA B2289C3EAB83ECD6EB916A2F481A02E6B76A0A48
-published 2012-05-05 17:03:50
-write-history 2012-05-05 17:02:45 (900 s) 1082368,19456,50176,272384,485376,1850368,1132544,1790976,2459648,4091904,6310912,13701120,3209216,3871744,7873536,5440512,7287808,10561536,9979904,11247616,11982848,7590912,10611712,20728832,38534144,6839296,3173376,16678912
-read-history 2012-05-05 17:02:45 (900 s) 3309568,9216,41984,27648,123904,2004992,364544,576512,1607680,3808256,4672512,12783616,2938880,2562048,7348224,3574784,6488064,10954752,9359360,4438016,6286336,6438912,4502528,10720256,38165504,1524736,2336768,8186880
-dirreq-write-history 2012-05-05 17:02:45 (900 s) 0,0,0,227328,349184,382976,738304,1171456,850944,657408,1675264,987136,702464,1335296,587776,1941504,893952,533504,695296,6828032,6326272,1287168,6310912,10085376,1048576,5372928,894976,8610816
-dirreq-read-history 2012-05-05 17:02:45 (900 s) 0,0,0,0,33792,27648,48128,46080,60416,51200,63488,64512,45056,27648,37888,48128,57344,34816,46080,50176,37888,51200,25600,33792,39936,32768,28672,30720
-router-signature
------BEGIN SIGNATURE-----
-K5FSywk7qvw/boA4DQcqkls6Ize5vcBYfhQ8JnOeRQC9+uDxbnpm3qaYN9jZ8myj
-k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
-7LZqklu+gVvhMKREpchVqlAwXkWR44VENm24Hs+mT3M=
------END SIGNATURE-----
diff --git a/test/integ/descriptor/data/extrainfo_relay_descriptor b/test/integ/descriptor/data/extrainfo_relay_descriptor
new file mode 100644
index 0000000..ecaabe0
--- /dev/null
+++ b/test/integ/descriptor/data/extrainfo_relay_descriptor
@@ -0,0 +1,13 @@
+@type extra-info 1.0
+extra-info NINJA B2289C3EAB83ECD6EB916A2F481A02E6B76A0A48
+published 2012-05-05 17:03:50
+write-history 2012-05-05 17:02:45 (900 s) 1082368,19456,50176,272384,485376,1850368,1132544,1790976,2459648,4091904,6310912,13701120,3209216,3871744,7873536,5440512,7287808,10561536,9979904,11247616,11982848,7590912,10611712,20728832,38534144,6839296,3173376,16678912
+read-history 2012-05-05 17:02:45 (900 s) 3309568,9216,41984,27648,123904,2004992,364544,576512,1607680,3808256,4672512,12783616,2938880,2562048,7348224,3574784,6488064,10954752,9359360,4438016,6286336,6438912,4502528,10720256,38165504,1524736,2336768,8186880
+dirreq-write-history 2012-05-05 17:02:45 (900 s) 0,0,0,227328,349184,382976,738304,1171456,850944,657408,1675264,987136,702464,1335296,587776,1941504,893952,533504,695296,6828032,6326272,1287168,6310912,10085376,1048576,5372928,894976,8610816
+dirreq-read-history 2012-05-05 17:02:45 (900 s) 0,0,0,0,33792,27648,48128,46080,60416,51200,63488,64512,45056,27648,37888,48128,57344,34816,46080,50176,37888,51200,25600,33792,39936,32768,28672,30720
+router-signature
+-----BEGIN SIGNATURE-----
+K5FSywk7qvw/boA4DQcqkls6Ize5vcBYfhQ8JnOeRQC9+uDxbnpm3qaYN9jZ8myj
+k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
+7LZqklu+gVvhMKREpchVqlAwXkWR44VENm24Hs+mT3M=
+-----END SIGNATURE-----
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 2739985..68b857b 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -9,14 +9,15 @@ import unittest
 import stem.descriptor.extrainfo_descriptor
 import test.runner
 import test.integ.descriptor
+from stem.descriptor.extrainfo_descriptor import DirResponses
 
 class TestExtraInfoDescriptor(unittest.TestCase):
-  def test_metrics_descriptor(self):
+  def test_metrics_relay_descriptor(self):
     """
     Parses and checks our results against an extrainfo descriptor from metrics.
     """
     
-    descriptor_path = test.integ.descriptor.get_resource("extrainfo_descriptor")
+    descriptor_path = test.integ.descriptor.get_resource("extrainfo_relay_descriptor")
     
     descriptor_file = open(descriptor_path)
     descriptor_file.readline() # strip header
@@ -60,6 +61,79 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
     dir_write_values_start = [0, 0, 0, 227328, 349184, 382976, 738304]
     self.assertEquals(dir_write_values_start, desc.dir_write_history_values[:7])
   
+  def test_metrics_bridge_descriptor(self):
+    """
+    Parses and checks our results against an extrainfo bridge descriptor from
+    metrics.
+    """
+    
+    descriptor_path = test.integ.descriptor.get_resource("extrainfo_bridge_descriptor")
+    
+    descriptor_file = open(descriptor_path)
+    descriptor_file.readline() # strip header
+    descriptor_contents = descriptor_file.read()
+    descriptor_file.close()
+    
+    expected_dir_v2_responses = {
+      DirResponses.OK: 0,
+      DirResponses.UNAVAILABLE: 0,
+      DirResponses.NOT_FOUND: 0,
+      DirResponses.NOT_MODIFIED: 0,
+      DirResponses.BUSY: 0,
+    }
+    
+    expected_dir_v3_responses = {
+      DirResponses.OK: 72,
+      DirResponses.NOT_ENOUGH_SIGS: 0,
+      DirResponses.UNAVAILABLE: 0,
+      DirResponses.NOT_FOUND: 0,
+      DirResponses.NOT_MODIFIED: 0,
+      DirResponses.BUSY: 0,
+    }
+    
+    expected_signature = """-----BEGIN SIGNATURE-----
+K5FSywk7qvw/boA4DQcqkls6Ize5vcBYfhQ8JnOeRQC9+uDxbnpm3qaYN9jZ8myj
+k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
+7LZqklu+gVvhMKREpchVqlAwXkWR44VENm24Hs+mT3M=
+-----END SIGNATURE-----"""
+    
+    desc = stem.descriptor.extrainfo_descriptor.BridgeExtraInfoDescriptor(descriptor_contents)
+    self.assertEquals("ec2bridgereaac65a3", desc.nickname)
+    self.assertEquals("1EC248422B57D9C0BD751892FE787585407479A4", desc.fingerprint)
+    self.assertEquals(datetime.datetime(2012, 6, 8, 2, 21, 27), desc.published)
+    self.assertEquals(datetime.datetime(2012, 6, 8, 2, 10, 38), desc.read_history_end)
+    self.assertEquals(900, desc.read_history_interval)
+    self.assertEquals(datetime.datetime(2012, 6, 8, 2, 10, 38), desc.write_history_end)
+    self.assertEquals(900, desc.write_history_interval)
+    self.assertEquals(datetime.datetime(2012, 6, 8, 2, 10, 38), desc.dir_read_history_end)
+    self.assertEquals(900, desc.dir_read_history_interval)
+    self.assertEquals(datetime.datetime(2012, 6, 8, 2, 10, 38), desc.dir_write_history_end)
+    self.assertEquals(900, desc.dir_write_history_interval)
+    
+    # TODO: uncomment when we handle router-digest entries
+    #self.assertEquals([], desc.get_unrecognized_lines())
+    
+    read_values_start = [337920, 437248, 3995648, 48726016]
+    self.assertEquals(read_values_start, desc.read_history_values[:4])
+    
+    write_values_start = [343040, 991232, 5649408, 49548288]
+    self.assertEquals(write_values_start, desc.write_history_values[:4])
+    
+    dir_read_values_start = [0, 71680, 99328, 25600]
+    self.assertEquals(dir_read_values_start, desc.dir_read_history_values[:4])
+    
+    dir_write_values_start = [5120, 664576, 2419712, 578560]
+    self.assertEquals(dir_write_values_start, desc.dir_write_history_values[:4])
+    
+    self.assertEquals({}, desc.dir_v2_requests)
+    self.assertEquals({}, desc.dir_v3_requests)
+    
+    self.assertEquals(expected_dir_v2_responses, desc.dir_v2_responses)
+    self.assertEquals(expected_dir_v3_responses, desc.dir_v3_responses)
+    
+    self.assertEquals({}, desc.dir_v2_responses_unknown)
+    self.assertEquals({}, desc.dir_v2_responses_unknown)
+  
   def test_cached_descriptor(self):
     """
     Parses the cached descriptor file in our data directory, checking that it



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits