def test_connect_is_called_if_not_enough_requests(self):
     """Test that only a small ratio is not enough to cause a host to be
     skipped; we also need to have a considerable number of requests.
     """
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO - 1
     timeouts = requests
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failUnless(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # _NOT_ cause a given host to be skipped.
     self.failIf(should_skip_host(self.host))
 def test_connect_is_called_if_not_many_timeouts(self):
     # If the ratio is not too small we consider it's safe to keep
     # issuing connections on that host.
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO
     timeouts = (
         (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) - 2)
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failUnless(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # _NOT_ cause a given host to be skipped.
     self.failIf(should_skip_host(self.host))
 def test_connect_is_called_if_not_many_timeouts(self):
     # If the ratio is not too small we consider it's safe to keep
     # issuing connections on that host.
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO
     timeouts = (
         (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) - 2)
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failUnless(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # _NOT_ cause a given host to be skipped.
     self.failIf(should_skip_host(self.host))
 def test_connect_is_called_if_not_enough_requests(self):
     """Test that only a small ratio is not enough to cause a host to be
     skipped; we also need to have a considerable number of requests.
     """
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO - 1
     timeouts = requests
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failUnless(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # _NOT_ cause a given host to be skipped.
     self.failIf(should_skip_host(self.host))
    def test_failure_after_too_many_timeouts(self):
        host = 'foo.bar'
        requests = MIN_REQUESTS_TO_CONSIDER_RATIO
        timeouts = (
            (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) + 2)
        distributionmirror_prober.host_requests = {host: requests}
        distributionmirror_prober.host_timeouts = {host: timeouts}
        # Ensure the number of requests and timeouts we're using should
        # cause a given host to be skipped.
        self.failUnless(should_skip_host(host))

        d = self._createProberAndProbe(u'http://%s:%s/timeout' %
                                       (host, self.port))
        return self.assertFailure(d, ConnectionSkipped)
 def test_connect_is_not_called_after_too_many_timeouts(self):
     """If we get a small requests/timeouts ratio on a given host, we'll
     stop issuing requests on that host.
     """
     # If the ratio is small enough and we have a considerable number of
     # requests, we won't issue more connections on that host.
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO
     timeouts = (
         (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) + 2)
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failIf(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # actually cause a given host to be skipped.
     self.failUnless(should_skip_host(self.host))
    def test_failure_after_too_many_timeouts(self):
        host = 'foo.bar'
        requests = MIN_REQUESTS_TO_CONSIDER_RATIO
        timeouts = (
            (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) + 2)
        distributionmirror_prober.host_requests = {host: requests}
        distributionmirror_prober.host_timeouts = {host: timeouts}
        # Ensure the number of requests and timeouts we're using should
        # cause a given host to be skipped.
        self.failUnless(should_skip_host(host))

        d = self._createProberAndProbe(
            u'http://%s:%s/timeout' % (host, self.port))
        return self.assertFailure(d, ConnectionSkipped)
 def test_connect_is_not_called_after_too_many_timeouts(self):
     """If we get a small requests/timeouts ratio on a given host, we'll
     stop issuing requests on that host.
     """
     # If the ratio is small enough and we have a considerable number of
     # requests, we won't issue more connections on that host.
     requests = MIN_REQUESTS_TO_CONSIDER_RATIO
     timeouts = (
         (MIN_REQUESTS_TO_CONSIDER_RATIO / MIN_REQUEST_TIMEOUT_RATIO) + 2)
     prober = self._createProberStubConnectAndProbe(requests, timeouts)
     self.failIf(prober.connectCalled)
     # Ensure the number of requests and timeouts we're using should
     # actually cause a given host to be skipped.
     self.failUnless(should_skip_host(self.host))