diff --git a/tests/memlimit.py b/tests/memlimit.py new file mode 100644 index 00000000..9f08fc4a --- /dev/null +++ b/tests/memlimit.py @@ -0,0 +1,36 @@ +import subprocess + +def test_memlimit_nondockerfile(): + """ + Test if memory limited builds are working for non dockerfile builds + """ + try: + subprocess.check_call([ + 'repo2docker', + '--no-run', + '--build-memory-limit', '4M', + 'tests/memlimit/non-dockerfile' + ]) + # If this doesn't throw an exception, then memory limit was + # not enforced! + assert False + except subprocess.CalledProcessError as e: + assert True + + +def test_memlimit_dockerfile(): + """ + Test if memory limited builds are working for non dockerfile builds + """ + try: + subprocess.check_call([ + 'repo2docker', + '--no-run', + '--build-memory-limit', '4M', + 'tests/memlimit/dockerfile' + ]) + # If this doesn't throw an exception, then memory limit was + # not enforced! + assert False + except subprocess.CalledProcessError as e: + assert True diff --git a/tests/memlimit/dockerfile/Dockerfile b/tests/memlimit/dockerfile/Dockerfile new file mode 100644 index 00000000..484911e6 --- /dev/null +++ b/tests/memlimit/dockerfile/Dockerfile @@ -0,0 +1,4 @@ +FROM python:3.6 + +COPY postBuild /usr/local/bin/postBuild +RUN ./postBuild diff --git a/tests/memlimit/dockerfile/postBuild b/tests/memlimit/dockerfile/postBuild new file mode 100755 index 00000000..1426cb5b --- /dev/null +++ b/tests/memlimit/dockerfile/postBuild @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +array = [] +for i in range(1024 * 1024 * 64): + array.append(i) diff --git a/tests/memlimit/non-dockerfile/postBuild b/tests/memlimit/non-dockerfile/postBuild new file mode 100755 index 00000000..1426cb5b --- /dev/null +++ b/tests/memlimit/non-dockerfile/postBuild @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +array = [] +for i in range(1024 * 1024 * 64): + array.append(i)