From 98aceac76d93277ed3bcc3a7bb25681050bd93d1 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 11 Nov 2022 07:55:42 +0100 Subject: [PATCH] tests: cleanup legacy logic These files are no longer used as of repo2docker PR 912 --- tests/memlimit/.gitignore | 1 - tests/memlimit/dockerfile/Dockerfile | 6 ------ tests/memlimit/dockerfile/postBuild | 27 ------------------------- tests/memlimit/non-dockerfile/postBuild | 27 ------------------------- tests/unit/test_memlimit.py | 19 ----------------- 5 files changed, 80 deletions(-) delete mode 100644 tests/memlimit/.gitignore delete mode 100644 tests/memlimit/dockerfile/Dockerfile delete mode 100755 tests/memlimit/dockerfile/postBuild delete mode 100755 tests/memlimit/non-dockerfile/postBuild diff --git a/tests/memlimit/.gitignore b/tests/memlimit/.gitignore deleted file mode 100644 index 1320de82..00000000 --- a/tests/memlimit/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cachebust diff --git a/tests/memlimit/dockerfile/Dockerfile b/tests/memlimit/dockerfile/Dockerfile deleted file mode 100644 index 9513e5e4..00000000 --- a/tests/memlimit/dockerfile/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ubuntu:bionic - -RUN apt-get update && apt-get install --yes python3 - -COPY . . -RUN ./postBuild diff --git a/tests/memlimit/dockerfile/postBuild b/tests/memlimit/dockerfile/postBuild deleted file mode 100755 index 1d781924..00000000 --- a/tests/memlimit/dockerfile/postBuild +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -""" -Simplest program that tries to allocate a large amount of RAM. - -malloc lies on Linux by default, so we use memset to force the -kernel to actually give us real memory. - -NOTE: This file has to be duplicated & present in all the following locations: - - tests/memlimit/dockerfile/postBuild - - tests/memlimit/dockerfile/postBuild -See https://github.com/jupyterhub/repo2docker/issues/160 for reason -""" -import os -from ctypes import c_void_p, cdll, memset - -libc = cdll.LoadLibrary("libc.so.6") -libc.malloc.restype = c_void_p - -with open("mem_allocate_mb") as f: - mem_allocate_mb = int(f.read().strip()) - -size = 1024 * 1024 * mem_allocate_mb -print(f"trying to allocate {mem_allocate_mb}MB") - -ret = libc.malloc(size) - -memset(ret, 0, size) diff --git a/tests/memlimit/non-dockerfile/postBuild b/tests/memlimit/non-dockerfile/postBuild deleted file mode 100755 index 1d781924..00000000 --- a/tests/memlimit/non-dockerfile/postBuild +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -""" -Simplest program that tries to allocate a large amount of RAM. - -malloc lies on Linux by default, so we use memset to force the -kernel to actually give us real memory. - -NOTE: This file has to be duplicated & present in all the following locations: - - tests/memlimit/dockerfile/postBuild - - tests/memlimit/dockerfile/postBuild -See https://github.com/jupyterhub/repo2docker/issues/160 for reason -""" -import os -from ctypes import c_void_p, cdll, memset - -libc = cdll.LoadLibrary("libc.so.6") -libc.malloc.restype = c_void_p - -with open("mem_allocate_mb") as f: - mem_allocate_mb = int(f.read().strip()) - -size = 1024 * 1024 * mem_allocate_mb -print(f"trying to allocate {mem_allocate_mb}MB") - -ret = libc.malloc(size) - -memset(ret, 0, size) diff --git a/tests/unit/test_memlimit.py b/tests/unit/test_memlimit.py index ee2f2b35..7fcb541f 100644 --- a/tests/unit/test_memlimit.py +++ b/tests/unit/test_memlimit.py @@ -47,25 +47,6 @@ def test_memory_limit_enforced(tmpdir): } -def test_memlimit_same_postbuild(): - """ - Validate that the postBuild files for the dockerfile and non-dockerfile - tests are the same - - Until https://github.com/jupyterhub/repo2docker/issues/160 gets fixed. - """ - filepaths = [ - os.path.join(basedir, "memlimit", t, "postBuild") - for t in ("dockerfile", "non-dockerfile") - ] - file_contents = [] - for fp in filepaths: - with open(fp) as f: - file_contents.append(f.read()) - # Make sure they're all the same - assert len(set(file_contents)) == 1 - - @pytest.mark.parametrize("BuildPack", [BaseImage, DockerBuildPack]) def test_memlimit_argument_type(BuildPack): # check that an exception is raised when the memory limit isn't an int