Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
90161f61
Commit
90161f61
authored
Feb 18, 2019
by
André Anjos
💬
Browse files
[test][docker] Move test-image pull function to a test submodule on request
parent
8be017cf
Pipeline
#27216
passed with stage
in 18 minutes and 23 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/core/dock.py
View file @
90161f61
...
...
@@ -48,45 +48,6 @@ from beat.core import stats
logger
=
logging
.
getLogger
(
__name__
)
DOCKER_TEST_IMAGES
=
{
"docker.idiap.ch/beat/beat.env.system.python"
:
"1.3.0r4"
,
"docker.idiap.ch/beat/beat.env.db.examples"
:
"1.4.0r4"
,
"docker.idiap.ch/beat/beat.env.cxx"
:
"2.0.0r1"
,
"docker.idiap.ch/beat/beat.env.client"
:
"2.0.0r1"
,
}
"""Images used for docker-enabled tests within this and other BEAT packages
"""
def
pull_docker_test_images
():
"""To be called when you need to set up tests using ``DOCKER_TEST_IMAGES``
This function will pull images that are not locally available yet
This technique prevents errors if docker.idiap.ch is not available,
e.g. when running outside the Idiap network
"""
import
docker
client
=
docker
.
from_env
()
for
image
,
tag
in
DOCKER_TEST_IMAGES
.
items
():
has_image
=
False
for
installed_image
in
client
.
images
.
list
():
for
installed_tag
in
installed_image
.
tags
:
if
installed_tag
==
(
'%s:%s'
%
(
image
,
tag
)):
has_image
=
True
if
not
has_image
:
#must pull (network connection required)
token
=
os
.
environ
.
get
(
'CI_BUILD_TOKEN'
)
params
=
(
image
,
tag
)
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
)
class
Host
(
object
):
"""An object of this class can connect to the docker host and resolve stuff
"""
...
...
beat/core/test/utils.py
View file @
90161f61
...
...
@@ -34,6 +34,49 @@ import shutil
import
nose
import
docker
#----------------------------------------------------------
DOCKER_TEST_IMAGES
=
{
"docker.idiap.ch/beat/beat.env.system.python"
:
"1.3.0r4"
,
"docker.idiap.ch/beat/beat.env.db.examples"
:
"1.4.0r4"
,
"docker.idiap.ch/beat/beat.env.cxx"
:
"2.0.0r1"
,
"docker.idiap.ch/beat/beat.env.client"
:
"2.0.0r1"
,
}
"""Images used for docker-enabled tests within this and other BEAT packages
"""
def
pull_docker_test_images
():
"""To be called when you need to set up tests using ``DOCKER_TEST_IMAGES``
This function will pull images that are not locally available yet
This technique prevents errors if docker.idiap.ch is not available,
e.g. when running outside the Idiap network
"""
import
docker
client
=
docker
.
from_env
()
for
image
,
tag
in
DOCKER_TEST_IMAGES
.
items
():
has_image
=
False
for
installed_image
in
client
.
images
.
list
():
for
installed_tag
in
installed_image
.
tags
:
if
installed_tag
==
(
'%s:%s'
%
(
image
,
tag
)):
has_image
=
True
if
not
has_image
:
#must pull (network connection required)
token
=
os
.
environ
.
get
(
'CI_BUILD_TOKEN'
)
params
=
(
image
,
tag
)
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
)
#----------------------------------------------------------
...
...
buildout.cfg
View file @
90161f61
...
...
@@ -9,6 +9,6 @@ recipe = bob.buildout:scripts
[docker]
recipe = collective.recipe.cmd
cmds = ./bin/python -c 'from beat.core.
dock
import pull_docker_test_images as f; f()'
cmds = ./bin/python -c 'from beat.core.
test.utils
import pull_docker_test_images as f; f()'
on_install = true
on_update = true
conda/meta.yaml
View file @
90161f61
...
...
@@ -53,7 +53,7 @@ test:
commands
:
# pulls required images once before running the tests
-
python -c "from beat.core.
dock
import pull_docker_test_images as f; f()"
-
python -c "from beat.core.
test.utils
import pull_docker_test_images as f; f()"
-
worker --help
-
nosetests --with-coverage --cover-package={{ name }} -sv {{ name }}
-
sphinx-build -aEW {{ project_dir }}/doc {{ project_dir }}/sphinx
...
...
develop.cfg
View file @
90161f61
...
...
@@ -16,6 +16,6 @@ recipe = bob.buildout:scripts
[docker]
recipe = collective.recipe.cmd
cmds = ./bin/python -c 'from beat.core.
dock
import pull_docker_test_images as f; f()'
cmds = ./bin/python -c 'from beat.core.
test.utils
import pull_docker_test_images as f; f()'
on_install = true
on_update = true
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment