Skip to content
GitLab
Menu
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
71a722c4
Commit
71a722c4
authored
Feb 15, 2019
by
André Anjos
💬
Browse files
[test][docker] Make auto-image pulling a function; Call it to setup various docker modules
parent
5358a362
Pipeline
#27142
passed with stage
in 19 minutes and 23 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/core/test/__init__.py
View file @
71a722c4
...
...
@@ -83,27 +83,27 @@ TEST_IMAGES = {
"""
def
setup_package
():
prefixes
=
[
pkg_resources
.
resource_filename
(
'beat.backend.python.test'
,
'prefix'
),
pkg_resources
.
resource_filename
(
'beat.core.test'
,
'prefix'
)
]
def
setup_docker_test_images
():
"""To be called when you need to set those up. Check ``TEST_IMAGES``
for
path
in
prefixes
:
subprocess
.
check_call
([
'rsync'
,
'-arz'
,
path
,
prefix_folder
])
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
"""
# Docker setup - 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
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
...
...
@@ -111,7 +111,19 @@ def setup_package():
params
+=
(
auth_config
,)
client
.
images
.
pull
(
*
params
)
def
setup_package
():
prefixes
=
[
pkg_resources
.
resource_filename
(
'beat.backend.python.test'
,
'prefix'
),
pkg_resources
.
resource_filename
(
'beat.core.test'
,
'prefix'
)
]
for
path
in
prefixes
:
subprocess
.
check_call
([
'rsync'
,
'-arz'
,
path
,
prefix_folder
])
if
DOCKER_NETWORK_TEST_ENABLED
:
import
docker
client
=
docker
.
from_env
()
try
:
network
=
client
.
networks
.
get
(
network_name
)
except
docker
.
errors
.
NotFound
:
...
...
beat/core/test/test_docker.py
View file @
71a722c4
...
...
@@ -50,6 +50,10 @@ from .utils import skipif
from
.
import
network_name
from
.
import
DOCKER_NETWORK_TEST_ENABLED
# this will ensure we pull the required images for the tests
from
.
import
setup_docker_test_images
as
setup_module
class
NoDiscoveryTests
(
unittest
.
TestCase
):
"""Test cases that don't require the discovery of database and runtime
environments.
...
...
beat/core/test/test_docker_databases_provider.py
View file @
71a722c4
...
...
@@ -54,6 +54,9 @@ from ..utils import find_free_port
from
.
import
prefix
from
.
import
tmp_prefix
# this will ensure we pull the required images for the tests
from
.
import
setup_docker_test_images
as
setup_module
#----------------------------------------------------------
...
...
beat/core/test/test_docker_environments.py
View file @
71a722c4
...
...
@@ -33,6 +33,9 @@ from .. import environments
from
.utils
import
slow
# this will ensure we pull the required images for the tests
from
.
import
setup_docker_test_images
as
setup_module
class
EnvironmentTest
(
unittest
.
TestCase
):
...
...
beat/core/test/test_docker_execution.py
View file @
71a722c4
...
...
@@ -44,6 +44,9 @@ from . import network_name
from
.
import
prefix_folder
from
.
import
DOCKER_NETWORK_TEST_ENABLED
# this will ensure we pull the required images for the tests
from
.
import
setup_docker_test_images
as
setup_module
BUILDER_IMAGE
=
"docker.idiap.ch/beat/beat.env.client:2.0.0r0"
#----------------------------------------------------------
...
...
beat/core/test/test_docker_worker.py
View file @
71a722c4
...
...
@@ -32,6 +32,10 @@ from ..dock import Host
from
.test_worker
import
TestOneWorker
,
TestTwoWorkers
# this will ensure we pull the required images for the tests
from
.
import
setup_docker_test_images
as
setup_module
#----------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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