diff --git a/beat/core/test/test_docker.py b/beat/core/test/test_docker.py index 44b84d1c7ed400880361cdffefdca0362b2c864b..23c538376ef5da628f0afa83ddbca3a6e0ad2968 100644 --- a/beat/core/test/test_docker.py +++ b/beat/core/test/test_docker.py @@ -269,14 +269,20 @@ class AsyncWithEnvironmentTest(unittest.TestCase): cmd = ['python', '-c', '; '.join([ "print('Before')", "import sys; sys.stdout.flush()", - "d = '0' * (10 * 1024 * 1024)", + "d = '0' * (40 * 1024 * 1024)", "import time; time.sleep(5)", "print('After')", ]) ] container = self.host.create_container(self.test_environment, cmd) - self.host.start(container, virtual_memory_in_megabytes=4) + # The amount of memory in megabytes should be greater than whatever + # the docker process is started with (see: + # https://unix.stackexchange.com/questions/412040/cgroups-memory-limit-write-error-device-or-resource-busy) + # If you start seeing EBUSY (device or resource busy errors) from + # docker, then try increasing a bit this value such that it still + # triggers the memory allocation error for the array defined above. + self.host.start(container, virtual_memory_in_megabytes=20) time.sleep(2) @@ -313,7 +319,7 @@ class AsyncWithEnvironmentTest(unittest.TestCase): assert stats['memory']['percent'] > 10, 'Memory check failed, ' \ '%d%% <= 10%%' % stats['memory']['percent'] - assert stats['memory']['percent'] < 15, 'Memory check failed, ' \ + assert stats['memory']['percent'] < 20, 'Memory check failed, ' \ '%d%% >= 15%%' % stats['memory']['percent'] self.assertEqual(self.host.status(container), 'exited') diff --git a/beat/core/test/test_docker_execution.py b/beat/core/test/test_docker_execution.py index ac358b1060f1467b1d47132deb0ce833f1218d81..79fc9265efa792a788b45b14a02590c291053f31 100644 --- a/beat/core/test/test_docker_execution.py +++ b/beat/core/test/test_docker_execution.py @@ -44,7 +44,9 @@ from . import network_name from . import prefix_folder from . import DOCKER_NETWORK_TEST_ENABLED -BUILDER_IMAGE = "docker.idiap.ch/beat/beat.env.client:2.0.0r0" +from .utils import DOCKER_TEST_IMAGES +BUILDER_CONTAINER_NAME = "docker.idiap.ch/beat/beat.env.client" +BUILDER_IMAGE = BUILDER_CONTAINER_NAME + ':' + DOCKER_TEST_IMAGES[BUILDER_CONTAINER_NAME] #---------------------------------------------------------- diff --git a/beat/core/test/utils.py b/beat/core/test/utils.py index 9c3ab459bdebce2041b619d97e1814413bbc87ef..1f67df9773a72e22f79334b4574d447c8be53d63 100644 --- a/beat/core/test/utils.py +++ b/beat/core/test/utils.py @@ -70,11 +70,12 @@ def pull_docker_test_images(): if not has_image: #must pull (network connection required) token = os.environ.get('CI_BUILD_TOKEN') - params = (image, tag) + args = (image, tag) + kwargs = {} if token is not None: #running on CI, setup auth_config = dict(username='gitlab-ci-token', password=token) - params += (auth_config,) - client.images.pull(*params) + kwargs['auth_config'] = auth_config + client.images.pull(*args, **kwargs) #----------------------------------------------------------