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):
if options.get('all'):
options['develop'] = True
if options.get('maximum_periodicity') is not None:
options['force_periodicity'] = True
# Supervisord configuration location
if not options.get('supervisord_configuration_path'):
options['supervisord_configuration_path'] = \
......@@ -199,8 +196,7 @@ def create_slapgrid_object(options, logger):
supervisord_configuration_path=op['supervisord_configuration_path'],
buildout=op.get('buildout'),
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'),
cert_file=op.get('cert_file'),
signature_private_key_file=op.get('signature_private_key_file'),
......@@ -256,7 +252,6 @@ class Slapgrid(object):
supervisord_configuration_path,
buildout,
logger,
force_periodicity=False,
maximum_periodicity=86400,
key_file=None,
cert_file=None,
......@@ -331,7 +326,6 @@ class Slapgrid(object):
self.computer_partition_filter_list = \
computer_partition_filter_list.split(",")
self.maximum_periodicity = maximum_periodicity
self.force_periodicity = force_periodicity
def getWatchdogLine(self):
invocation_list = [WATCHDOG_PATH]
......@@ -576,15 +570,13 @@ class Slapgrid(object):
periodicity = self.maximum_periodicity
if software_path:
# Get periodicity from periodicity file if not forced
if not self.force_periodicity:
periodicity_path = os.path.join(software_path, 'periodicity')
if os.path.exists(periodicity_path):
try:
periodicity = int(open(periodicity_path).read())
except ValueError:
os.remove(periodicity_path)
self.logger.exception('')
periodicity_path = os.path.join(software_path, 'periodicity')
if os.path.exists(periodicity_path):
try:
periodicity = int(open(periodicity_path).read())
except ValueError:
os.remove(periodicity_path)
self.logger.exception('')
# Check if timestamp from server is more recent than local one.
# If not: it's not worth processing this partition (nothing has
......
......@@ -1027,7 +1027,6 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance.timestamp = timestamp
instance.requested_state = 'started'
instance.software.setPeriodicity(1)
self.grid.force_periodicity = True
self.launchSlapgrid()
partition = os.path.join(self.instance_root, '0')
......@@ -1043,36 +1042,7 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
self.assertItemsEqual(os.listdir(partition),
['.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):
"""
......@@ -1558,26 +1528,6 @@ class TestSlapgridArgumentTuple(SlapgridInitialization):
slapgrid_object = parser(*self.default_arg_tuple)[0]
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):
"""
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