Changed the type of migration_time from int to float
This commit is contained in:
parent
e70f15fb48
commit
6815679aa2
@ -221,31 +221,31 @@ def execute(config, state):
|
||||
underload_detection_params = json.loads(
|
||||
config['algorithm_underload_detection_parameters'])
|
||||
underload_detection_state = None
|
||||
underload_detection = \
|
||||
config['algorithm_underload_detection_factory'](
|
||||
time_step,
|
||||
migration_time,
|
||||
underload_detection_params)
|
||||
underload_detection = common.call_function_by_name(
|
||||
config['algorithm_underload_detection_factory'],
|
||||
[time_step,
|
||||
migration_time,
|
||||
underload_detection_params])
|
||||
state['underload_detection'] = underload_detection
|
||||
|
||||
overload_detection_params = json.loads(
|
||||
config['algorithm_overload_detection_parameters'])
|
||||
overload_detection_state = None
|
||||
overload_detection = \
|
||||
config['algorithm_overload_detection_factory'](
|
||||
time_step,
|
||||
migration_time,
|
||||
overload_detection_params)
|
||||
overload_detection = common.call_function_by_name(
|
||||
config['algorithm_overload_detection_factory'],
|
||||
[time_step,
|
||||
migration_time,
|
||||
overload_detection_params])
|
||||
state['overload_detection'] = overload_detection
|
||||
|
||||
vm_selection_params = json.loads(
|
||||
config['algorithm_vm_selection_parameters'])
|
||||
vm_selection_state = None
|
||||
vm_selection = \
|
||||
config['algorithm_vm_selection_factory'](
|
||||
time_step,
|
||||
migration_time,
|
||||
vm_selection_params)
|
||||
vm_selection = common.call_function_by_name(
|
||||
config['algorithm_vm_selection_factory'],
|
||||
[time_step,
|
||||
migration_time,
|
||||
vm_selection_params])
|
||||
state['vm_selection'] = vm_selection
|
||||
else:
|
||||
underload_detection = state['underload_detection']
|
||||
|
@ -30,7 +30,7 @@ def otf_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -52,7 +52,7 @@ def otf_limit_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -75,7 +75,7 @@ def otf_migration_time_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -99,7 +99,7 @@ def otf_limit_migration_time_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -163,7 +163,7 @@ def otf_migration_time(threshold, migration_time, utilization):
|
||||
:type threshold: float,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time steps.
|
||||
:type migration_time: number,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param utilization: The history of the host's CPU utilization.
|
||||
:type utilization: list(float)
|
||||
@ -186,7 +186,7 @@ def otf_limit_migration_time(threshold, limit, migration_time, utilization):
|
||||
:type limit: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time steps.
|
||||
:type migration_time: number,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param utilization: The history of the host's CPU utilization.
|
||||
:type utilization: list(float)
|
||||
|
@ -34,7 +34,7 @@ def loess_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -59,7 +59,7 @@ def loess_robust_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -84,7 +84,7 @@ def mad_threshold_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -107,7 +107,7 @@ def iqr_threshold_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
|
@ -30,7 +30,7 @@ def no_migrations_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -49,7 +49,7 @@ def threshold_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
|
@ -30,7 +30,7 @@ def threshold_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
|
@ -33,7 +33,7 @@ def random_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -52,7 +52,7 @@ def minimum_utilization_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
@ -72,7 +72,7 @@ def minimum_migration_time_factory(time_step, migration_time, params):
|
||||
:type time_step: int,>=0
|
||||
|
||||
:param migration_time: The VM migration time in time seconds.
|
||||
:type migration_time: int,>=0
|
||||
:type migration_time: float,>=0
|
||||
|
||||
:param params: A dictionary containing the algorithm's parameters.
|
||||
:type params: dict(str: *)
|
||||
|
@ -41,77 +41,77 @@ class Otf(TestCase):
|
||||
|
||||
def test_otf_migration_time(self):
|
||||
self.assertTrue(otf.otf_migration_time(
|
||||
0.5, 100, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 100., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertTrue(otf.otf_migration_time(
|
||||
0.5, 100, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 100., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
self.assertTrue(otf.otf_migration_time(
|
||||
0.5, 1, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 1., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertFalse(otf.otf_migration_time(
|
||||
0.5, 1, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 1., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
|
||||
def test_otf_limit_migration_time(self):
|
||||
self.assertFalse(otf.otf_limit_migration_time(
|
||||
0.5, 10, 100, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 10, 100., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertFalse(otf.otf_limit_migration_time(
|
||||
0.5, 10, 100, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 10, 100., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
self.assertFalse(otf.otf_limit_migration_time(
|
||||
0.5, 10, 1, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 10, 1., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertFalse(otf.otf_limit_migration_time(
|
||||
0.5, 10, 1, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 10, 1., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
self.assertTrue(otf.otf_limit_migration_time(
|
||||
0.5, 5, 100, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 5, 100., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertTrue(otf.otf_limit_migration_time(
|
||||
0.5, 5, 100, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 5, 100., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
self.assertTrue(otf.otf_limit_migration_time(
|
||||
0.5, 5, 1, [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
0.5, 5, 1., [0.9, 0.8, 1.1, 1.2, 1.3]))
|
||||
self.assertFalse(otf.otf_limit_migration_time(
|
||||
0.5, 5, 1, [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
0.5, 5, 1., [0.9, 0.8, 1.1, 1.2, 0.3]))
|
||||
|
||||
def test_otf_factory(self):
|
||||
alg = otf.otf_factory(
|
||||
300, 20, {'threshold': 0.5})
|
||||
300, 20., {'threshold': 0.5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
def test_otf_limit_factory(self):
|
||||
alg = otf.otf_limit_factory(
|
||||
300, 20, {'threshold': 0.5, 'limit': 10})
|
||||
300, 20., {'threshold': 0.5, 'limit': 10})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (False, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
alg = otf.otf_limit_factory(
|
||||
300, 20, {'threshold': 0.5, 'limit': 5})
|
||||
300, 20., {'threshold': 0.5, 'limit': 5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
def test_otf_migration_time_factory(self):
|
||||
alg = otf.otf_migration_time_factory(
|
||||
30, 3000, {'threshold': 0.5})
|
||||
30, 3000., {'threshold': 0.5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (True, {}))
|
||||
|
||||
alg = otf.otf_migration_time_factory(
|
||||
300, 1, {'threshold': 0.5})
|
||||
300, 1., {'threshold': 0.5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
def test_otf_limit_migration_time_factory(self):
|
||||
alg = otf.otf_limit_migration_time_factory(
|
||||
30, 3000, {'threshold': 0.5, 'limit': 10})
|
||||
30, 3000., {'threshold': 0.5, 'limit': 10})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (False, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
alg = otf.otf_limit_migration_time_factory(
|
||||
300, 1, {'threshold': 0.5, 'limit': 10})
|
||||
300, 1., {'threshold': 0.5, 'limit': 10})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (False, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
||||
alg = otf.otf_limit_migration_time_factory(
|
||||
30, 3000, {'threshold': 0.5, 'limit': 5})
|
||||
30, 3000., {'threshold': 0.5, 'limit': 5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (True, {}))
|
||||
|
||||
alg = otf.otf_limit_migration_time_factory(
|
||||
300, 1, {'threshold': 0.5, 'limit': 5})
|
||||
300, 1., {'threshold': 0.5, 'limit': 5})
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEqual(alg([0.9, 0.8, 1.1, 1.2, 0.3]), (False, {}))
|
||||
|
@ -22,7 +22,7 @@ class Statistics(TestCase):
|
||||
|
||||
def test_loess_factory(self):
|
||||
alg = stats.loess_factory(
|
||||
300, 20, {'param': 1.2, 'limit': 3})
|
||||
300, 20., {'param': 1.2, 'limit': 3})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
|
||||
data = [1.05, 1.09, 1.07, 1.12, 1.02, 1.18,
|
||||
@ -36,7 +36,7 @@ class Statistics(TestCase):
|
||||
|
||||
def test_loess_robust_factory(self):
|
||||
alg = stats.loess_robust_factory(
|
||||
300, 20, {'param': 1.2, 'limit': 3})
|
||||
300, 20., {'param': 1.2, 'limit': 3})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
|
||||
data = [1.05, 1.09, 1.07, 1.12, 1.02, 1.18,
|
||||
@ -52,7 +52,7 @@ class Statistics(TestCase):
|
||||
with MockTransaction:
|
||||
expect(stats).mad.and_return(0.125).exactly(6).times()
|
||||
alg = stats.mad_threshold_factory(
|
||||
300, 20, {'threshold': 1.6, 'limit': 3})
|
||||
300, 20., {'threshold': 1.6, 'limit': 3})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
self.assertEqual(alg([0., 0., 0.0]), (False, {}))
|
||||
self.assertEqual(alg([0., 0., 0.5]), (False, {}))
|
||||
@ -65,7 +65,7 @@ class Statistics(TestCase):
|
||||
with MockTransaction:
|
||||
expect(stats).iqr.and_return(0.125).exactly(6).times()
|
||||
alg = stats.iqr_threshold_factory(
|
||||
300, 20, {'threshold': 1.6, 'limit': 3})
|
||||
300, 20., {'threshold': 1.6, 'limit': 3})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
self.assertEqual(alg([0., 0., 0.0]), (False, {}))
|
||||
self.assertEqual(alg([0., 0., 0.5]), (False, {}))
|
||||
|
@ -23,7 +23,7 @@ class Trivial(TestCase):
|
||||
@qc(10)
|
||||
def overloading_steps(
|
||||
time_step=int_(min=0, max=10),
|
||||
migration_time=int_(min=0, max=10),
|
||||
migration_time=float_(min=0, max=10),
|
||||
utilization=list_(of=float)
|
||||
):
|
||||
alg = trivial.no_migrations_factory(time_step, migration_time,
|
||||
@ -38,7 +38,7 @@ class Trivial(TestCase):
|
||||
self.assertFalse(trivial.threshold(0.5, []))
|
||||
|
||||
def test_threshold_factory(self):
|
||||
alg = trivial.threshold_factory(300, 20, {'threshold': 0.5})
|
||||
alg = trivial.threshold_factory(300, 20., {'threshold': 0.5})
|
||||
self.assertEquals(alg([0.9, 0.8, 1.1, 1.2, 1.3]), (True, {}))
|
||||
self.assertEquals(alg([0.9, 0.8, 1.1, 1.2, 0.6]), (True, {}))
|
||||
self.assertEquals(alg([0.9, 0.8, 1.1, 1.2, 0.5]), (False, {}))
|
||||
|
@ -21,7 +21,7 @@ import neat.locals.underload.trivial as trivial
|
||||
class Trivial(TestCase):
|
||||
|
||||
def test_threshold_factory(self):
|
||||
alg = trivial.threshold_factory(300, 20, {'threshold': 0.5})
|
||||
alg = trivial.threshold_factory(300, 20., {'threshold': 0.5})
|
||||
self.assertEqual(alg([]), (False, {}))
|
||||
self.assertEqual(alg([0.0, 0.0]), (True, {}))
|
||||
self.assertEqual(alg([0.0, 0.4]), (True, {}))
|
||||
|
@ -28,7 +28,7 @@ class Selection(TestCase):
|
||||
min_length=1, max_length=5
|
||||
)
|
||||
):
|
||||
alg = selection.minimum_migration_time_factory(300, 20, dict())
|
||||
alg = selection.minimum_migration_time_factory(300, 20., dict())
|
||||
values = x.values()
|
||||
vm_index = values.index(min(values))
|
||||
vm = x.keys()[vm_index]
|
||||
@ -43,7 +43,7 @@ class Selection(TestCase):
|
||||
min_length=1, max_length=5
|
||||
)
|
||||
):
|
||||
alg = selection.minimum_utilization_factory(300, 20, dict())
|
||||
alg = selection.minimum_utilization_factory(300, 20., dict())
|
||||
last_utilization = []
|
||||
for utilization in x.values():
|
||||
last_utilization.append(utilization[-1])
|
||||
@ -61,7 +61,7 @@ class Selection(TestCase):
|
||||
)
|
||||
):
|
||||
with MockTransaction:
|
||||
alg = selection.random_factory(300, 20, dict())
|
||||
alg = selection.random_factory(300, 20., dict())
|
||||
vm = x.keys()[random.randrange(len(x))]
|
||||
expect(selection).choice(x.keys()).and_return(vm).once()
|
||||
assert alg(x, dict()) == (vm, {})
|
||||
|
Loading…
x
Reference in New Issue
Block a user