Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impose Memory Limit on Test Containers #4494

Merged
merged 2 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt -qqy install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--
libmysqlclient-dev `# Needed for MySQL-python` \
libpq-dev `# Needed for psycopg2`

RUN pip install colorama==0.3.1 requests MySQL-python psycopg2-binary pymongo docker==3.5.0
RUN pip install colorama==0.3.1 requests MySQL-python psycopg2-binary pymongo docker==3.5.0 psutil

ENV PYTHONPATH /FrameworkBenchmarks
ENV FWROOT /FrameworkBenchmarks
Expand Down
5 changes: 5 additions & 0 deletions toolset/utils/docker_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from toolset.utils.output_helper import log
from toolset.utils.database_helper import test_database

from psutil import virtual_memory

# total memory limit allocated for the test container
mem_limit = int(round(virtual_memory().total * .95))

class DockerHelper:
def __init__(self, benchmarker=None):
Expand Down Expand Up @@ -189,6 +193,7 @@ def watch_container(docker_container, docker_file):
extra_hosts=extra_hosts,
privileged=True,
ulimits=ulimit,
mem_limit=mem_limit,
sysctls=sysctl,
remove=True,
log_config={'type': None})
Expand Down