Commit d9e40d34 authored by Thomas Larrieu's avatar Thomas Larrieu

finished working on periodicity 'always force/always skip'

parent 0b2b9f6d
...@@ -587,13 +587,15 @@ class Slapgrid(object): ...@@ -587,13 +587,15 @@ class Slapgrid(object):
last_runtime = int(os.path.getmtime(timestamp_path)) last_runtime = int(os.path.getmtime(timestamp_path))
if timestamp: if timestamp:
try: try:
if int(timestamp) <= int(old_timestamp): if periodicity == 0:
os.remove(timestamp_path)
elif int(timestamp) <= int(old_timestamp):
if computer_partition.getState() != COMPUTER_PARTITION_STARTED_STATE: if computer_partition.getState() != COMPUTER_PARTITION_STARTED_STATE:
return return
# Check periodicity, i.e if periodicity is one day, partition # Check periodicity, i.e if periodicity is one day, partition
# should be processed at least every day. # should be processed at least every day.
# Only do it for "started" instances # Only do it for "started" instances
if int(time.time()) <= (last_runtime + periodicity): if int(time.time()) <= (last_runtime + periodicity) or periodicity < 0:
self.logger.info('Partition already up-to-date, skipping.') self.logger.info('Partition already up-to-date, skipping.')
return return
else: else:
......
...@@ -1168,6 +1168,48 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase): ...@@ -1168,6 +1168,48 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
last_runtime) last_runtime)
self.assertNotEqual(wanted_periodicity, self.grid.maximum_periodicity) self.assertNotEqual(wanted_periodicity, self.grid.maximum_periodicity)
def test_one_partition_is_never_processed_when_periodicity_is_negative(self):
"""
Checks that a partition is not processed when
its periodicity is negative
"""
def get_runtime(instance):
self.assertTrue(os.path.exists(os.path.join(instance.partition_path, '.timestamp')))
return os.path.getmtime(os.path.join(instance.partition_path, '.timestamp'))
periodicity = -1
timestamp = str(int(time.time()))
computer = ComputerForTest(self.software_root, self.instance_root, 1, 1)
instance = computer.instance_list[0]
instance.software.setPeriodicity(periodicity)
instance.timestamp = timestamp
self.launchSlapgrid()
first_runtime = get_runtime(instance)
self.launchSlapgrid()
second_runtime = get_runtime(instance)
self.assertEqual(first_runtime, second_runtime)
def test_one_partition_is_always_processed_when_periodicity_is_zero(self):
"""
Checks that a partition is always processed when
its periodicity is 0
"""
def get_runtime(instance):
self.assertTrue(os.path.exists(os.path.join(instance.partition_path, '.timestamp')))
return os.path.getmtime(os.path.join(instance.partition_path, '.timestamp'))
periodicity = 0
timestamp = str(int(time.time()))
computer = ComputerForTest(self.software_root, self.instance_root, 1, 1)
instance = computer.instance_list[0]
instance.software.setPeriodicity(periodicity)
instance.timestamp = timestamp
self.launchSlapgrid()
first_runtime = get_runtime(instance)
self.launchSlapgrid()
second_runtime = get_runtime(instance)
self.assertNotEqual(first_runtime, second_runtime)
def test_one_partition_buildout_fail_does_not_disturb_others(self): def test_one_partition_buildout_fail_does_not_disturb_others(self):
""" """
1. We set up two instance one using a corrupted buildout 1. We set up two instance one using a corrupted buildout
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment