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

[tor-commits] [sbws/master] Merge branch 'ticket28563_rebased_ticket28565'



commit 6070d36022dc2130518dd0c68332166b2bf76c73
Merge: f9df765 4729aa8
Author: juga0 <juga@xxxxxxxxxx>
Date:   Thu Mar 21 14:14:33 2019 +0000

    Merge branch 'ticket28563_rebased_ticket28565'
    
    Conflicts:
            sbws/lib/v3bwfile.py
            tests/unit/lib/test_v3bwfile.py

 sbws/lib/v3bwfile.py            | 98 +++++++++++++++++++++++++++++------------
 tests/unit/lib/test_v3bwfile.py | 17 +++++--
 2 files changed, 84 insertions(+), 31 deletions(-)

diff --cc sbws/lib/v3bwfile.py
index 6a433d0,50e353c..34e988c
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@@ -598,41 -547,63 +604,72 @@@ class V3BWLine(object)
          # explained the what it means the strings returned.
          # They rules were introduced in #28061 and #27338
          # In #28565 we introduce the KeyValues to know why they're excluded.
 -        # In #28563 will include again these lines, but make them unparseable
 -        # by Tor.
 +        # In #28563 we report these relays, but make Tor ignore them.
          # This might confirm #28042.
  
+         # If the relay is non-`eligible`:
+         # Create a bandwidth line with the relay, but set ``vote=0`` so that
+         # Tor versions with patch #29806 does not vote on the relay.
+         # Set ``bw=1`` so that Tor versions without the patch,
+         # will give the relay low bandwidth.
+         # Include ``unmeasured=1`` in case Tor would vote on unmeasured relays
+         # in future versions.
+         # And return because there are not bandwidth values.
+         # NOTE: the bandwidth values could still be obtained if:
+         # 1. ``ResultError`` will store them
+         # 2. assign ``results_recent = results`` when there is a ``exclusion
+         # reason.
+         # This could be done in a better way as part of a refactor #28684.
+ 
+         kwargs['vote'] = '0'
+         kwargs['unmeasured'] = '1'
+ 
+         exclusion_reason = None
 -        kwargs['relay_recent_measurement_exclusion_not_success_count'] = \
 -            len(results) - len(success_results)
++
 +        number_excluded_error = len(results) - len(success_results)
 +        if number_excluded_error > 0:
 +            # then the number of error results is the number of results
 +            kwargs['relay_recent_measurements_excluded_error_count'] = \
 +                number_excluded_error
          if not success_results:
-             return None, 'recent_measurements_excluded_error_count'
 -            exclusion_reason = 'recent_measurement_exclusion_not_success_count'
++            exclusion_reason = 'recent_measurements_excluded_error_count'
+             return (cls(node_id, 1, **kwargs), exclusion_reason)
 +
          results_away = \
              cls.results_away_each_other(success_results, secs_away)
 -        kwargs['relay_recent_measurement_exclusion_not_distanciated_count'] = \
 -            len(success_results) - len(results_away)
 +        number_excluded_near = len(success_results) - len(results_away)
 +        if number_excluded_near > 0:
 +            kwargs['relay_recent_measurements_excluded_near_count'] = \
-                 len(success_results) - len(results_away)
++                number_excluded_near
          if not results_away:
-             return None, 'recent_measurements_excluded_near_count'
- 
+             exclusion_reason = \
 -                'recent_measurement_exclusion_not_distanciated_count'
++                'recent_measurements_excluded_near_count'
+             return (cls(node_id, 1, **kwargs), exclusion_reason)
          # log.debug("Results away from each other: %s",
          #           [unixts_to_isodt_str(r.time) for r in results_away])
++
          results_recent = cls.results_recent_than(results_away, secs_recent)
 -        kwargs['relay_recent_measurement_exclusion_not_recent_count'] = \
 -            len(results_away) - len(results_recent)
 +        number_excluded_old = len(results_away) - len(results_recent)
 +        if number_excluded_old > 0:
 +            kwargs['relay_recent_measurements_excluded_old_count'] = \
 +                number_excluded_old
          if not results_recent:
-             return None, 'recent_measurements_excluded_old_count'
+             exclusion_reason = \
 -                'recent_measurement_exclusion_not_recent_count'
++                'recent_measurements_excluded_old_count'
+             return (cls(node_id, 1, **kwargs), exclusion_reason)
  
          if not len(results_recent) >= min_num:
 -            kwargs['relay_recent_measurement_exclusion_not_min_num_count'] = \
 +            kwargs['relay_recent_measurements_excluded_few_count'] = \
                  len(results_recent)
              # log.debug('The number of results is less than %s', min_num)
-             return None, 'recent_measurements_excluded_few_count'
+             exclusion_reason = \
 -                'recent_measurement_exclusion_not_min_num_count'
++                'recent_measurements_excluded_few_count'
+             return (cls(node_id, 1, **kwargs), exclusion_reason)
+ 
+         # For any line not excluded, do not include vote and unmeasured
+         # KeyValues
+         del kwargs['vote']
+         del kwargs['unmeasured']
  
          rtt = cls.rtt_from_results(results_recent)
          if rtt:
@@@ -903,8 -883,8 +947,8 @@@ class V3BWFile(object)
              # log.debug(bw_lines[-1])
          # Not using the result for now, just warning
          cls.is_max_bw_diff_perc_reached(bw_lines, max_bw_diff_perc)
 -        # Include excluded lines that does not have ``bw`` attribute.
 +        header.add_time_report_half_network()
-         f = cls(header, bw_lines)
+         f = cls(header, bw_lines + bw_lines_excluded)
          return f
  
      @classmethod
diff --cc tests/unit/lib/test_v3bwfile.py
index 9212a69,021eb95..be823a3
--- a/tests/unit/lib/test_v3bwfile.py
+++ b/tests/unit/lib/test_v3bwfile.py
@@@ -320,9 -324,9 +323,11 @@@ def test_results_away_each_other(datadi
      values = results["AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"]
  
      # There is one result excluded, but the relay is not excluded
 -    bwl, _ = V3BWLine.from_results(values, secs_away=secs_away, min_num=2)
 +    bwl, reason = V3BWLine.from_results(values, secs_away=secs_away, min_num=2)
 +    assert bwl.relay_recent_measurements_excluded_error_count == 1
 +    assert reason is None
+     assert not hasattr(bwl, "vote")
+     assert not hasattr(bwl, "unmeasured")
  
      success_results = [r for r in values if isinstance(r, ResultSuccess)]
      assert len(success_results) >= min_num
@@@ -334,33 -338,31 +339,37 @@@
  
      # Two measurements are excluded and there were only 2,
      # the relay is excluded
 -    bwl, _ = V3BWLine.from_results(values, secs_away=secs_away, min_num=2)
 +    bwl, reason = V3BWLine.from_results(values, secs_away=secs_away, min_num=2)
-     # TODO ticket28563: uncomment
-     # assert bwl.relay_recent_measurements_excluded_near_count == 2
++    assert bwl.relay_recent_measurements_excluded_near_count == 2
 +    assert reason == 'recent_measurements_excluded_near_count'
+     assert bwl.vote == '0'
+     assert bwl.unmeasured == '1'
  
 +    success_results = [r for r in values if isinstance(r, ResultSuccess)]
 +    assert len(success_results) >= min_num
 +    results_away = V3BWLine.results_away_each_other(success_results, secs_away)
 +    assert not results_away
++
      secs_away = 43200  # 12h
      values = results["BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"]
      success_results = [r for r in values if isinstance(r, ResultSuccess)]
      assert len(success_results) >= min_num
      results_away = V3BWLine.results_away_each_other(success_results, secs_away)
      assert len(results_away) == 2
+ 
      # C has 1 result
      values = results["CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"]
 -    success_results = [r for r in values if isinstance(r, ResultSuccess)]
 -    assert len(success_results) < min_num
  
      # There is only 1 result, the relay is excluded
 -    bwl, _ = V3BWLine.from_results(values, min_num=2)
 +    bwl, reason = V3BWLine.from_results(values, min_num=2)
-     # TODO ticket28563: uncomment
-     # assert bwl.recent_measurements_excluded_few_count == 1
++    assert bwl.relay_recent_measurements_excluded_few_count == 1
 +    assert reason == 'recent_measurements_excluded_few_count'
+     assert bwl.vote == '0'
+     assert bwl.unmeasured == '1'
  
 +    success_results = [r for r in values if isinstance(r, ResultSuccess)]
 +    assert len(success_results) < min_num
 +
  
  def test_measured_progress_stats(datadir):
      number_consensus_relays = 3



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