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:
parent
20218394b9
commit
fc26982132
4 changed files with 39 additions and 1 deletions
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -155,6 +155,13 @@ class ServiceTest(unittest.TestCase):
|
|||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||
self.assertFalse('domainname' in opts, 'domainname')
|
||||
|
||||
def test_memory_swap_limit(self):
|
||||
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, mem_limit=1000000000, memswap_limit=2000000000)
|
||||
self.mock_client.containers.return_value = []
|
||||
opts = service._get_container_create_options({'some': 'overrides'}, 1)
|
||||
self.assertEqual(opts['memswap_limit'], 2000000000)
|
||||
self.assertEqual(opts['mem_limit'], 1000000000)
|
||||
|
||||
def test_split_domainname_fqdn(self):
|
||||
service = Service(
|
||||
'foo',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue