Cap the memory of each container a heavy command makes under run-heavy at its slot's share, and have stability-reviewer size a mutation run's concurrency to fit it
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import unittest
|
||||
|
||||
from docker_command import capped
|
||||
|
||||
|
||||
class Capped(unittest.TestCase):
|
||||
def test_a_container_without_limits_gets_the_share_for_both(self):
|
||||
for given, expected in [
|
||||
(["run", "--rm", "img", "true"], ["run", "--memory", "6144m", "--memory-swap", "6144m", "--rm", "img", "true"]),
|
||||
(["-H", "unix:///d.sock", "run", "img"], ["-H", "unix:///d.sock", "run", "--memory", "6144m", "--memory-swap", "6144m", "img"]),
|
||||
(["container", "create", "img"], ["container", "create", "--memory", "6144m", "--memory-swap", "6144m", "img"]),
|
||||
(["run", "img", "python", "-m", "pytest"], ["run", "--memory", "6144m", "--memory-swap", "6144m", "img", "python", "-m", "pytest"]),
|
||||
]:
|
||||
with self.subTest(given):
|
||||
self.assertEqual(capped(given, "6144m"), expected)
|
||||
|
||||
def test_a_container_s_own_memory_limit_is_kept_and_caps_its_swap(self):
|
||||
self.assertEqual(capped(["run", "-m", "10g", "img"], "6144m"), ["run", "--memory-swap", "10g", "-m", "10g", "img"])
|
||||
self.assertEqual(capped(["run", "--memory=12g", "img"], "6144m"), ["run", "--memory-swap", "12g", "--memory=12g", "img"])
|
||||
|
||||
def test_a_container_with_both_limits_or_another_docker_call_is_left_alone(self):
|
||||
for given in [["run", "-m", "10g", "--memory-swap", "12g", "img"], ["ps"], ["build", "."], ["run", "--help"], ["compose", "run", "app"], ["exec", "box", "true"]]:
|
||||
with self.subTest(given):
|
||||
self.assertEqual(capped(given, "6144m"), given)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user