def setUp(self): self.compute_1 = "compute1" self.compute_2 = "compute2" self.user = "******" self.vm_id = "vm-id" self.ssh_utils = SSH_Utils({}) self.compute_nodes = [self.compute_1, self.compute_2] self.compute_nodes_key = "key" self.instance_locator = Instance_Locator(self.ssh_utils, self.compute_nodes, self.compute_nodes_key)
def setUp(self): self.vm_id1 = "vm_id1" self.vm_id2 = "vm_id2" self.host_ip1 = "host_ip1" self.host_ip2 = "host_ip2" self.cap1 = 50 self.cap2 = 78 self.io_cap = 75 self.bigsea_username = "******" self.bigsea_password = "******" self.authorization_url = "authorization_url" self.authorization_data = dict( authorization_url=self.authorization_url, bigsea_username=self.bigsea_username, bigsea_password=self.bigsea_password) compute_nodes = [] compute_nodes_key = "key" self.instance_locator = Instance_Locator(SSH_Utils({}), compute_nodes, compute_nodes_key) self.remote_kvm = Remote_KVM(SSH_Utils({}), compute_nodes_key) self.actuator = KVM_Actuator(self.instance_locator, self.remote_kvm, self.authorization_data, self.io_cap)
def setUp(self): self.application_id_0 = "app-00" self.application_id_1 = "app-01" self.application_id_2 = "app-02" self.timestamp_1 = datetime.datetime.strptime("2000-01-01T00:00:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_2 = datetime.datetime.strptime("2000-01-01T00:05:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_3 = datetime.datetime.strptime("2000-01-01T00:10:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_4 = datetime.datetime.strptime("2000-01-01T00:15:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.instance_name_1 = "instance1" self.instance_name_2 = "instance2" self.instances = [self.instance_name_1, self.instance_name_2] self.trigger_down = 30.0 self.trigger_up = 10.0 self.min_cap = 10.0 self.max_cap = 100.0 self.actuation_size = 10.0 self.allocated_resources = 50 self.metric_round = 2 self.default_io_cap = 78 self.bigsea_username = "******" self.bigsea_password = "******" self.authorization_url = "authorization_url" self.authorization_data = dict(authorization_url=self.authorization_url, bigsea_username=self.bigsea_username, bigsea_password=self.bigsea_password) compute_nodes = [] compute_nodes_key = "key" self.instances = [self.instance_name_1, self.instance_name_2] self.metric_source = Metric_Source_Builder().get_metric_source("nop", {}) self.instance_locator = Instance_Locator( SSH_Utils({}), compute_nodes, compute_nodes_key) self.remote_kvm = Remote_KVM(SSH_Utils({}), compute_nodes_key) self.actuator = KVM_Actuator(self.instance_locator, self.remote_kvm, self.authorization_data, self.default_io_cap) self.proportional_factor = 1 self.factor_up = 1 self.factor_down = 0.5 self.heuristic_options_error_proportional = {"heuristic_name": "error_proportional", "proportional_factor": self.proportional_factor} self.heuristic_options_error_proportional_up_down = \ {"heuristic_name": "error_proportional_up_down", "factor_up": self.factor_up, "factor_down": self.factor_down} self.progress_error = {self.application_id_0: -20.0, self.application_id_1: 0.00, self.application_id_2: 30.0} self.timestamps = [self.timestamp_1, self.timestamp_2, self.timestamp_3, self.timestamp_4]
def setUp(self): self.application_id_0 = "app-00" self.application_id_1 = "app-01" self.application_id_2 = "app-02" self.application_id_3 = "app-03" self.application_id_4 = "app-04" self.timestamp_1 = datetime.datetime.strptime("2000-01-01T00:00:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_2 = datetime.datetime.strptime("2000-01-01T00:05:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_3 = datetime.datetime.strptime("2000-01-01T00:10:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.timestamp_4 = datetime.datetime.strptime("2000-01-01T00:15:00.0Z", '%Y-%m-%dT%H:%M:%S.%fZ') self.instance_name_1 = "instance1" self.instance_name_2 = "instance2" self.instances = [self.instance_name_1, self.instance_name_2] self.trigger_down = 30.0 self.trigger_up = 10.0 self.min_cap = 10.0 self.max_cap = 100.0 self.actuation_size = 10.0 self.allocated_resources = 50 self.metric_round = 2 self.default_io_cap = 45 self.bigsea_username = "******" self.bigsea_password = "******" self.authorization_url = "authorization_url" self.authorization_data = dict( authorization_url=self.authorization_url, bigsea_username=self.bigsea_username, bigsea_password=self.bigsea_password) compute_nodes = [] compute_nodes_key = "key" self.instances = [self.instance_name_1, self.instance_name_2] self.metric_source = Metric_Source_Builder().get_metric_source( "nop", {}) self.instance_locator = Instance_Locator(SSH_Utils({}), compute_nodes, compute_nodes_key) self.remote_kvm = Remote_KVM(SSH_Utils({}), compute_nodes_key) self.actuator = KVM_Actuator(self.instance_locator, self.remote_kvm, self.authorization_data, self.default_io_cap) self.timestamps = [ self.timestamp_1, self.timestamp_2, self.timestamp_3, self.timestamp_4 ]
class Test_Instance_Locator(unittest.TestCase): def setUp(self): self.compute_1 = "compute1" self.compute_2 = "compute2" self.user = "******" self.vm_id = "vm-id" self.ssh_utils = SSH_Utils({}) self.compute_nodes = [self.compute_1, self.compute_2] self.compute_nodes_key = "key" self.instance_locator = Instance_Locator(self.ssh_utils, self.compute_nodes, self.compute_nodes_key) def tearDown(self): pass def located(self, command, user, host, key): return {self.compute_1: "0\n", self.compute_2: "1\n"}[host] def impossible_to_locate(self, command, user, host, key): return {self.compute_1: "1\n", self.compute_2: "1\n"}[host] def test_locate(self): self.ssh_utils.run_and_get_result = MagicMock() self.ssh_utils.run_and_get_result.side_effect = self.located result = self.instance_locator.locate(self.vm_id) self.ssh_utils.run_and_get_result.assert_any_call( "virsh schedinfo %s > /dev/null 2> /dev/null ; echo $?" % (self.vm_id), self.user, self.compute_1, self.compute_nodes_key) self.assertEquals(result, self.compute_1) def test_locate_impossible_to_find_instance(self): self.ssh_utils.run_and_get_result = MagicMock() self.ssh_utils.run_and_get_result.side_effect = self.impossible_to_locate self.assertRaises(InstanceNotFoundException, self.instance_locator.locate, self.vm_id) self.ssh_utils.run_and_get_result.assert_any_call( "virsh schedinfo %s > /dev/null 2> /dev/null ; echo $?" % (self.vm_id), self.user, self.compute_1, self.compute_nodes_key) self.ssh_utils.run_and_get_result.assert_any_call( "virsh schedinfo %s > /dev/null 2> /dev/null ; echo $?" % (self.vm_id), self.user, self.compute_2, self.compute_nodes_key)
def setUp(self): self.application_id_0 = "app-00" self.application_id_1 = "app-01" self.application_id_2 = "app-02" self.application_id_3 = "app-03" self.application_id_4 = "app-04" self.application_id_5 = "app-05" self.application_id_6 = "app-06" self.application_id_7 = "app-07" self.timestamp_1 = datetime.datetime.strptime("2000-01-01T00:00:00.0Z", "%Y-%m-%dT%H:%M:%S.%fZ") self.timestamp_2 = datetime.datetime.strptime("2000-01-01T00:05:00.0Z", "%Y-%m-%dT%H:%M:%S.%fZ") self.timestamp_3 = datetime.datetime.strptime("2000-01-01T00:10:00.0Z", "%Y-%m-%dT%H:%M:%S.%fZ") self.timestamp_4 = datetime.datetime.strptime("2000-01-01T00:15:00.0Z", "%Y-%m-%dT%H:%M:%S.%fZ") self.timestamps = [ self.timestamp_1, self.timestamp_2, self.timestamp_3, self.timestamp_4 ] self.instance_name_1 = "instance1" self.instance_name_2 = "instance2" self.instances = [self.instance_name_1, self.instance_name_2] self.trigger_down = 10.0 self.trigger_up = 10.0 self.min_cap = 10.0 self.max_cap = 100.0 self.actuation_size = 10.0 self.allocated_resources_scale_down = 100 self.allocated_resources_scale_up = 10 self.metric_round = 2 self.default_io_cap = 34 self.bigsea_username = "******" self.bigsea_password = "******" self.authorization_url = "authorization_url" self.authorization_data = dict( authorization_url=self.authorization_url, bigsea_username=self.bigsea_username, bigsea_password=self.bigsea_password) compute_nodes = [] compute_nodes_key = "key" self.instances = [self.instance_name_1, self.instance_name_2] self.metric_source = Metric_Source_Builder().get_metric_source( "nop", {}) self.instance_locator = Instance_Locator(SSH_Utils({}), compute_nodes, compute_nodes_key) self.remote_kvm = Remote_KVM(SSH_Utils({}), compute_nodes_key) self.actuator = KVM_Actuator(self.instance_locator, self.remote_kvm, self.authorization_data, self.default_io_cap) self.proportional_factor = 1.5 self.derivative_factor = 0.5 self.heuristic_options = { "heuristic_name": "error_proportional_derivative", "proportional_factor": self.proportional_factor, "derivative_factor": self.derivative_factor } self.progress_error = { # CASE 1 self.application_id_0: { self.timestamp_1: -30.0, self.timestamp_2: -20.0, self.timestamp_3: -15.0 }, # CASE 2 self.application_id_1: { self.timestamp_1: -30.0, self.timestamp_2: -40.0, self.timestamp_3: -60.0 }, # CASE 3 self.application_id_2: { self.timestamp_1: 30.0, self.timestamp_2: 20.0, self.timestamp_3: 15.0 }, # CASE 4 self.application_id_3: { self.timestamp_1: 30.0, self.timestamp_2: 40.0, self.timestamp_3: 55.0 }, # CASE 5 self.application_id_4: { self.timestamp_1: 100.0, self.timestamp_2: 100.0, self.timestamp_3: 100.0 }, # CASE 6 self.application_id_5: { self.timestamp_1: -100.0, self.timestamp_2: -100.0, self.timestamp_3: -100.0 }, # CASE 7 self.application_id_6: { self.timestamp_1: -30.0, self.timestamp_2: 10.0, self.timestamp_3: 30.0 }, # CASE 8 self.application_id_7: { self.timestamp_1: -5.0, self.timestamp_2: -1.0, self.timestamp_3: 2.0 } }