'``read_request_load_scenario`` raises ``RequestOverload`` if the
difference between sent requests and received requests exceeds
the tolerated difference once we start monitoring the scenario.
Note that, right now, the only way to make it fail is to generate
this difference before we start monitoring the scenario.
Once we implement some kind of tolerance, to allow fluctuations
in the rate, we can update this tests to trigger the exception
in a more realistic manner.'

@capture_logging(None)
def test_scenario_throws_exception_if_overloaded(self, _logger):

    c = Clock()
    cluster = self.make_cluster(RequestDroppingFakeFlockerClient)
    target_rate = 10
    sample_size = 20
    s = read_request_load_scenario(c, cluster, request_rate=target_rate, sample_size=sample_size)
    dropped_rate = (target_rate / 2)
    seconds_to_overload = (s.max_outstanding / dropped_rate)
    s.start()
    cluster.get_control_service(c).drop_requests = True
    c.pump(repeat(1, (seconds_to_overload + 1)))
    cluster.get_control_service(c).drop_requests = False
    c.pump(repeat(1, sample_size))
    c.advance(1)
    failure = self.failureResultOf(s.maintained())
    self.assertIsInstance(failure.value, RequestOverload)
