Esempio n. 1
0
 def test_result(self):
     sla1 = max_average_duration.MaxAverageDuration(42)
     sla2 = max_average_duration.MaxAverageDuration(3.62)
     for sla_inst in [sla1, sla2]:
         sla_inst.add_iteration({"duration": 3.14})
         sla_inst.add_iteration({"duration": 6.28})
     self.assertTrue(sla1.result()["success"])  # 42 > avg([3.14, 6.28])
     self.assertFalse(sla2.result()["success"])  # 3.62 < avg([3.14, 6.28])
     self.assertEqual("Passed", sla1.status())
     self.assertEqual("Failed", sla2.status())
 def test_add_iteration(self):
     sla = max_average_duration.MaxAverageDuration(4.0)
     self.assertTrue(sla.add_iteration({"duration": 3.5}))
     self.assertTrue(sla.add_iteration({"duration": 2.5}))
     self.assertTrue(sla.add_iteration({"duration": 5.0}))   # avg = 3.667
     self.assertFalse(sla.add_iteration({"duration": 7.0}))  # avg = 4.5
     self.assertTrue(sla.add_iteration({"duration": 1.0}))   # avg = 3.8
    def test_merge(self, durations):

        single_sla = max_average_duration.MaxAverageDuration(4.0)

        for dd in durations:
            for d in dd:
                single_sla.add_iteration({"duration": d})

        slas = [max_average_duration.MaxAverageDuration(4.0)
                for _ in durations]

        for idx, sla in enumerate(slas):
            for duration in durations[idx]:
                sla.add_iteration({"duration": duration})

        merged_sla = slas[0]
        for sla in slas[1:]:
            merged_sla.merge(sla)

        self.assertEqual(single_sla.success, merged_sla.success)
        self.assertEqual(single_sla.avg, merged_sla.avg)
Esempio n. 4
0
 def test_result_no_iterations(self):
     sla_inst = max_average_duration.MaxAverageDuration(42)
     self.assertTrue(sla_inst.result()["success"])