def test_apply_cgroup_limits(self): """Test cgroup creation.""" # Disable W0212: Access to a protected member # pylint: disable=W0212 cgroups = { 'cpu': '/some/path', 'cpuacct': '/some/other/path', 'memory': '/mem/path', 'blkio': '/io/path', } app_run._apply_cgroup_limits(cgroups, ) treadmill.cgroups.join.assert_has_calls( [mock.call(ss, path) for ss, path in cgroups.items()], any_order=True)
def test_apply_cgroup_limits(self): """Test cgroup creation.""" # Disable W0212: Access to a protected member # pylint: disable=W0212 manifest = { 'type': 'native', 'proid': 'foo', 'environment': 'dev', 'shared_network': False, 'cpu': '100', 'memory': '100M', 'disk': '100G', 'services': [ { 'name': 'web_server', 'command': '/bin/true', 'restart': { 'limit': 5, 'interval': 60, }, }, ], 'endpoints': [ { 'name': 'http', 'port': '8000', }, ], 'name': 'proid.myapp#0', 'uniqueid': 'AAAAA', } app_unique_name = 'proid.myapp-0-00000000AAAAA' mock_cgroup_client = self.tm_env.svc_cgroup.make_client.return_value mock_ld_client = self.tm_env.svc_localdisk.make_client.return_value mock_nwrk_client = self.tm_env.svc_network.make_client.return_value cgroups = { 'cpu': '/some/path', 'cpuacct': '/some/other/path', 'memory': '/mem/path', 'blkio': '/io/path', } mock_cgroup_client.wait.return_value = cgroups app_dir = os.path.join(self.root, 'apps', app_unique_name) os.makedirs(app_dir) app_run._apply_cgroup_limits(self.tm_env, app_dir, manifest) self.tm_env.svc_cgroup.make_client.assert_called_with( os.path.join(app_dir, 'cgroups')) mock_cgroup_client.put.assert_called_with(app_unique_name, { 'memory': '100M', 'cpu': '100', }) self.tm_env.svc_localdisk.make_client.assert_called_with( os.path.join(app_dir, 'localdisk')) mock_ld_client.put.assert_called_with(app_unique_name, { 'size': '100G', }) self.tm_env.svc_network.make_client.assert_called_with( os.path.join(app_dir, 'network')) mock_nwrk_client.put.assert_called_with(app_unique_name, { 'environment': 'dev', }) mock_cgroup_client.wait.assert_called_with( 'proid.myapp-0-00000000AAAAA') treadmill.cgroups.join.assert_has_calls( [mock.call(ss, path) for ss, path in cgroups.items()], any_order=True)