def test_aggregation(self): s1 = StatsEntry(self.stats, "aggregate me!", "GET") s1.log(12, 0) s1.log(12, 0) s1.log(38, 0) s1.log_error("Dummy exzeption") s2 = StatsEntry(self.stats, "aggregate me!", "GET") s2.log_error("Dummy exzeption") s2.log_error("Dummy exzeption") s2.log(12, 0) s2.log(99, 0) s2.log(14, 0) s2.log(55, 0) s2.log(38, 0) s2.log(55, 0) s2.log(97, 0) s = StatsEntry(self.stats, "GET", "") s.extend(s1, full_request_history=True) s.extend(s2, full_request_history=True) self.assertEqual(s.num_requests, 10) self.assertEqual(s.num_failures, 3) self.assertEqual(s.median_response_time, 38) self.assertEqual(s.avg_response_time, 43.2)
def test_aggregation(self): s1 = StatsEntry(self.stats, "aggregate me!", "GET") s1.log(12, 0) s1.log(12, 0) s1.log(38, 0) s1.log_error("Dummy exzeption") s2 = StatsEntry(self.stats, "aggregate me!", "GET") s2.log_error("Dummy exzeption") s2.log_error("Dummy exzeption") s2.log(12, 0) s2.log(99, 0) s2.log(14, 0) s2.log(55, 0) s2.log(38, 0) s2.log(55, 0) s2.log(97, 0) s = StatsEntry(self.stats, "GET", "") s.extend(s1) s.extend(s2) self.assertEqual(s.num_requests, 10) self.assertEqual(s.num_failures, 3) self.assertEqual(s.median_response_time, 38) self.assertEqual(s.avg_response_time, 43.2)
def test_aggregation_min_response_time(self): s1 = StatsEntry(self.stats, "min", "GET") s1.log(10, 0) self.assertEqual(10, s1.min_response_time) s2 = StatsEntry(self.stats, "min", "GET") s1.extend(s2) self.assertEqual(10, s1.min_response_time)
def test_aggregation(self): s1 = StatsEntry(self.stats, "aggregate me!", "GET") s1.log(12, 0) s1.log(12, 0) s1.log(38, 0) s1.log_error("Dummy exzeption") s2 = StatsEntry(self.stats, "aggregate me!", "GET") s2.log_error("Dummy exzeption") s2.log_error("Dummy exzeption") s2.log(12, 0) s2.log(99, 0) s2.log(14, 0) s2.log(55, 0) s2.log(38, 0) s2.log(55, 0) s2.log(97, 0) s = StatsEntry(self.stats, "GET", "") s.extend(s1) s.extend(s2) assert s.num_requests == 10 assert s.num_failures == 3 assert s.median_response_time == 38 assert s.avg_response_time == 43.2
def test_aggregation_last_request_timestamp(self): s1 = StatsEntry(self.stats, "r", "GET") s2 = StatsEntry(self.stats, "r", "GET") s1.extend(s2) self.assertEqual(None, s1.last_request_timestamp) s1 = StatsEntry(self.stats, "r", "GET") s2 = StatsEntry(self.stats, "r", "GET") s1.last_request_timestamp = 666 s1.extend(s2) self.assertEqual(666, s1.last_request_timestamp) s1 = StatsEntry(self.stats, "r", "GET") s2 = StatsEntry(self.stats, "r", "GET") s2.last_request_timestamp = 666 s1.extend(s2) self.assertEqual(666, s1.last_request_timestamp) s1 = StatsEntry(self.stats, "r", "GET") s2 = StatsEntry(self.stats, "r", "GET") s1.last_request_timestamp = 666 s1.last_request_timestamp = 700 s1.extend(s2) self.assertEqual(700, s1.last_request_timestamp)