Ejemplo n.º 1
0
 def test_get_current_response_time_percentile(self):
     s = StatsEntry(self.stats, "/", "GET", use_response_times_cache=True)
     t = int(time.time())
     s.response_times_cache[t-10] = CachedResponseTimes(
         response_times={i:1 for i in xrange(100)},
         num_requests=200
     )
     s.response_times_cache[t-10].response_times[1] = 201
     
     s.response_times = {i:2 for i in xrange(100)}
     s.response_times[1] = 202
     s.num_requests = 300
     
     assert 95 == s.get_current_response_time_percentile(0.95)
Ejemplo n.º 2
0
    def test_fail_ratio_with_half_failures(self):
        REQUEST_COUNT = 10
        FAILURE_COUNT = 5
        EXPECTED_FAIL_RATIO = 0.5

        s = StatsEntry(self.stats, "/", "GET")
        s.num_requests = REQUEST_COUNT
        s.num_failures = FAILURE_COUNT

        self.assertAlmostEqual(s.fail_ratio, EXPECTED_FAIL_RATIO)
        output_fields = self.parse_string_output(str(s))
        self.assertEqual(output_fields['request_count'], REQUEST_COUNT)
        self.assertEqual(output_fields['failure_count'], FAILURE_COUNT)
        self.assertAlmostEqual(output_fields['failure_precentage'],
                               EXPECTED_FAIL_RATIO * 100)
Ejemplo n.º 3
0
 def test_fail_ratio_with_failures(self):
     s = StatsEntry(self.stats, "/", "GET")
     s.num_requests = 10
     s.num_failures = 5
     self.assertAlmostEqual(s.fail_ratio, 0.5)
Ejemplo n.º 4
0
 def test_fail_ratio_with_failures(self):
     s = StatsEntry(self.stats, "/", "GET")
     s.num_requests = 10
     s.num_failures = 5
     self.assertAlmostEqual(s.fail_ratio, 0.5)