def setUp(self): application_id = "000001" self.parameters = { "control_parameters": { "metric_source": "redis", "schedule_strategy": "default", "actuator": 'nop', "trigger_down": 1, "trigger_up": 1, "min_rep": 2, "max_rep": 10, "check_interval": 1, "actuation_size": 3}, "redis_ip": "192.168.0.0", "redis_port": "5000", "application_id": application_id } self.kubejobs1 = KubeJobs(self.parameters) self.kubejobs1.metric_source = \ MetricSourceMock("2018-11-26T15:00:00.000Z", -2) self.kubejobs1.actuator = ActuatorMock() self.controller = KubejobsController(application_id, self.parameters) self.controller.alarm = self.kubejobs1
def setUp(self): parameters = { "control_parameters": { "check_interval": 2, "trigger_down": 1, "trigger_up": 1, "min_rep": 2, "max_rep": 10, "actuation_size": 3, "actuator": "nop", "metric_source": "redis", "redis_ip": "192.168.0.0", "redis_port": "5000" }, "redis_ip": "192.168.0.0", "redis_port": "5000" } application_id = "000001" metric_source_1 = MetricSourceMock("2018-11-26T15:00:00.000Z", -2) actuator = ActuatorMock() trigger_down = 1 trigger_up = 1 min_cap = 2 max_cap = 10 actuation_size = 3 alarm = self.kubejobs1 = KubeJobs(actuator, metric_source_1, trigger_down, trigger_up, min_cap, max_cap, actuation_size, application_id) self.controller = KubejobsController(application_id, parameters) self.controller.alarm = alarm
def setUp(self): metric_source_1 = MetricSourceMock("2018-11-26T15:00:00.000Z", -2) actuator = ActuatorMock() trigger_down = 1 trigger_up = 1 min_cap = 2 max_cap = 10 actuation_size = 3 application_id_1 = "00001" application_id_2 = "00002" metric_source_2 = MetricSourceMock("2017-08-06T07:00:00.000Z", 0.0002) self.kubejobs1 = KubeJobs(actuator, metric_source_1, trigger_down, trigger_up, min_cap, max_cap, actuation_size, application_id_1) self.kubejobs2 = KubeJobs(actuator, metric_source_2, trigger_down, trigger_up, min_cap, max_cap, actuation_size, application_id_2)
def test_status(self): self.kubejobs1.metric_source = MetricSourceMock( "2018-11-26T15:00:00.000Z", 0.0001) initial_state1 = "" final_state1 = "Progress error-[%s]-%f" % \ self.kubejobs1._get_progress_error("00001") self.assertEqual(self.kubejobs1.status(), initial_state1) self.kubejobs1.check_application_state() self.assertEqual(self.kubejobs1.status(), final_state1) self.kubejobs2.metric_source = MetricSourceMock( "0001-01-01T00:00:00.0Z", 0.0002) initial_state2 = "" final_state2 = "Progress error-[%s]-%f" % \ self.kubejobs2._get_progress_error("00002") \ + " Could not acquire more recent metrics" self.assertEqual(self.kubejobs2.status(), initial_state2) self.kubejobs2.check_application_state() self.assertEqual(self.kubejobs2.status(), final_state2)
def setUp(self): data1 = {"metric_source": "redis", "schedule_strategy": "default", "actuator": 'nop', "trigger_down": 0, "trigger_up": 0, "min_rep": 1, "max_rep": 10, "actuation_size": 1} data2 = {"metric_source": 'redis', "schedule_strategy": "default", "actuator": "nop", "trigger_down": 0, "trigger_up": 0, "min_rep": 1, "max_rep": 10, "actuation_size": 1} self.kubejobs1 = KubeJobs({"redis_ip": "0.0.0.0", "redis_port": "2352", "application_id": "00001", "control_parameters": data1}) self.kubejobs2 = KubeJobs({"redis_ip": "0.0.0.0", "redis_port": "2352", "application_id": "00002", "control_parameters": data2}) self.kubejobs1.metric_source = \ MetricSourceMock("2017-08-06T07:00:00.000Z", -2) self.kubejobs1.actuator = ActuatorMock() # self.kubejobs1.scheduler = SchedulerMock() self.kubejobs2.metric_source = \ MetricSourceMock("2018-11-26T15:00:00.000Z", 0.0002) self.kubejobs2.actuator = ActuatorMock()