Commit 0b2b9f6d authored by Thomas Larrieu's avatar Thomas Larrieu

Removing check_periodicity behavior that might introduce weird use

cases (at least in this implementation). We might want to add a feature
request to get that behavior back, but in a more predictable way.
parent ac66550a
...@@ -135,9 +135,6 @@ def merged_options(args, configp): ...@@ -135,9 +135,6 @@ def merged_options(args, configp):
if options.get('all'): if options.get('all'):
options['develop'] = True options['develop'] = True
if options.get('maximum_periodicity') is not None:
options['force_periodicity'] = True
# Supervisord configuration location # Supervisord configuration location
if not options.get('supervisord_configuration_path'): if not options.get('supervisord_configuration_path'):
options['supervisord_configuration_path'] = \ options['supervisord_configuration_path'] = \
...@@ -199,8 +196,7 @@ def create_slapgrid_object(options, logger): ...@@ -199,8 +196,7 @@ def create_slapgrid_object(options, logger):
supervisord_configuration_path=op['supervisord_configuration_path'], supervisord_configuration_path=op['supervisord_configuration_path'],
buildout=op.get('buildout'), buildout=op.get('buildout'),
logger=logger, logger=logger,
force_periodicity=op.get('force_periodicity', False), maximum_periodicity = op.get('maximum_periodicity', 86400),
maximum_periodicity=op.get('maximum_periodicity', 86400),
key_file=op.get('key_file'), key_file=op.get('key_file'),
cert_file=op.get('cert_file'), cert_file=op.get('cert_file'),
signature_private_key_file=op.get('signature_private_key_file'), signature_private_key_file=op.get('signature_private_key_file'),
...@@ -256,7 +252,6 @@ class Slapgrid(object): ...@@ -256,7 +252,6 @@ class Slapgrid(object):
supervisord_configuration_path, supervisord_configuration_path,
buildout, buildout,
logger, logger,
force_periodicity=False,
maximum_periodicity=86400, maximum_periodicity=86400,
key_file=None, key_file=None,
cert_file=None, cert_file=None,
...@@ -331,7 +326,6 @@ class Slapgrid(object): ...@@ -331,7 +326,6 @@ class Slapgrid(object):
self.computer_partition_filter_list = \ self.computer_partition_filter_list = \
computer_partition_filter_list.split(",") computer_partition_filter_list.split(",")
self.maximum_periodicity = maximum_periodicity self.maximum_periodicity = maximum_periodicity
self.force_periodicity = force_periodicity
def getWatchdogLine(self): def getWatchdogLine(self):
invocation_list = [WATCHDOG_PATH] invocation_list = [WATCHDOG_PATH]
...@@ -576,15 +570,13 @@ class Slapgrid(object): ...@@ -576,15 +570,13 @@ class Slapgrid(object):
periodicity = self.maximum_periodicity periodicity = self.maximum_periodicity
if software_path: if software_path:
# Get periodicity from periodicity file if not forced periodicity_path = os.path.join(software_path, 'periodicity')
if not self.force_periodicity: if os.path.exists(periodicity_path):
periodicity_path = os.path.join(software_path, 'periodicity') try:
if os.path.exists(periodicity_path): periodicity = int(open(periodicity_path).read())
try: except ValueError:
periodicity = int(open(periodicity_path).read()) os.remove(periodicity_path)
except ValueError: self.logger.exception('')
os.remove(periodicity_path)
self.logger.exception('')
# Check if timestamp from server is more recent than local one. # Check if timestamp from server is more recent than local one.
# If not: it's not worth processing this partition (nothing has # If not: it's not worth processing this partition (nothing has
......
...@@ -1027,7 +1027,6 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase): ...@@ -1027,7 +1027,6 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance.timestamp = timestamp instance.timestamp = timestamp
instance.requested_state = 'started' instance.requested_state = 'started'
instance.software.setPeriodicity(1) instance.software.setPeriodicity(1)
self.grid.force_periodicity = True
self.launchSlapgrid() self.launchSlapgrid()
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
...@@ -1043,36 +1042,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase): ...@@ -1043,36 +1042,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
self.assertItemsEqual(os.listdir(partition), self.assertItemsEqual(os.listdir(partition),
['.timestamp', 'buildout.cfg', 'software_release', 'worked']) ['.timestamp', 'buildout.cfg', 'software_release', 'worked'])
def test_partition_periodicity_is_not_overloaded_if_forced(self):
"""
If periodicity file in software directory but periodicity is forced
periodicity will be the one given by parameter
1. We set force_periodicity parameter to True
2. We put a periodicity file in the software release directory
with an unwanted periodicity
3. We process partition list and wait more than unwanted periodicity
4. We relaunch, partition should not be processed
"""
computer = ComputerForTest(self.software_root, self.instance_root)
instance = computer.instance_list[0]
timestamp = str(int(time.time()))
instance.timestamp = timestamp
instance.requested_state = 'started'
unwanted_periodicity = 2
instance.software.setPeriodicity(unwanted_periodicity)
self.grid.force_periodicity = True
self.launchSlapgrid()
time.sleep(unwanted_periodicity + 1)
self.setSlapgrid()
self.grid.force_periodicity = True
self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS)
self.assertNotEqual(unwanted_periodicity, self.grid.maximum_periodicity)
self.assertEqual(computer.sequence,
['getFullComputerInformation', 'availableComputerPartition',
'startedComputerPartition', 'getFullComputerInformation'])
def test_one_partition_periodicity_from_file_does_not_disturb_others(self): def test_one_partition_periodicity_from_file_does_not_disturb_others(self):
""" """
...@@ -1558,26 +1528,6 @@ class TestSlapgridArgumentTuple(SlapgridInitialization): ...@@ -1558,26 +1528,6 @@ class TestSlapgridArgumentTuple(SlapgridInitialization):
slapgrid_object = parser(*self.default_arg_tuple)[0] slapgrid_object = parser(*self.default_arg_tuple)[0]
self.assertFalse(slapgrid_object.develop) self.assertFalse(slapgrid_object.develop)
def test_force_periodicity_if_periodicity_not_given(self):
"""
Check if not giving --maximum-periodicity triggers "force_periodicity"
option to be false.
"""
parser = parseArgumentTupleAndReturnSlapgridObject
slapgrid_object = parser(*self.default_arg_tuple)[0]
self.assertFalse(slapgrid_object.force_periodicity)
def test_force_periodicity_if_periodicity_given(self):
"""
Check if giving --maximum-periodicity triggers "force_periodicity" option.
"""
parser = parseArgumentTupleAndReturnSlapgridObject
slapgrid_object = parser('--maximum-periodicity', '40', *self.default_arg_tuple)[0]
self.assertTrue(slapgrid_object.force_periodicity)
class TestSlapgridConfigurationFile(SlapgridInitialization):
def test_upload_binary_cache_blacklist(self): def test_upload_binary_cache_blacklist(self):
""" """
Check if giving --upload-to-binary-cache-url-blacklist triggers option. Check if giving --upload-to-binary-cache-url-blacklist triggers option.
......
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