Add in memswap_limit run option

By allowing the memswap_limit option to be defined we also need to
check that mem_limit is set, you can't have swap without a limit.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-07-06 17:07:31 +01:00
commit fc26982132
4 changed files with 39 additions and 1 deletions

View file

@ -260,6 +260,31 @@ class MergeLabelsTest(unittest.TestCase):
self.assertEqual(service_dict['labels'], {'foo': '1', 'bar': ''})
class MemoryOptionsTest(unittest.TestCase):
def test_validation_fails_with_just_memswap_limit(self):
"""
When you set a 'memswap_limit' it is invalid config unless you also set
a mem_limit
"""
with self.assertRaises(config.ConfigurationError):
make_service_dict(
'foo', {
'memswap_limit': 2000000,
},
'tests/'
)
def test_validation_with_correct_memswap_values(self):
service_dict = make_service_dict(
'foo', {
'mem_limit': 1000000,
'memswap_limit': 2000000,
},
'tests/'
)
self.assertEqual(service_dict['memswap_limit'], 2000000)
class EnvTest(unittest.TestCase):
def test_parse_environment_as_list(self):
environment = [