Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
beat.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
beat
beat.core
Commits
8eb5c22a
Commit
8eb5c22a
authored
Feb 18, 2019
by
André Anjos
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[test] Pull docker images once before begin of tests (during buildout or conda-build)
parent
96019628
Pipeline
#27203
canceled with stage
in 2 minutes and 47 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
55 additions
and
56 deletions
+55
-56
beat/core/dock.py
beat/core/dock.py
+39
-0
beat/core/test/__init__.py
beat/core/test/__init__.py
+0
-39
beat/core/test/test_docker.py
beat/core/test/test_docker.py
+0
-3
beat/core/test/test_docker_databases_provider.py
beat/core/test/test_docker_databases_provider.py
+0
-3
beat/core/test/test_docker_environments.py
beat/core/test/test_docker_environments.py
+0
-3
beat/core/test/test_docker_execution.py
beat/core/test/test_docker_execution.py
+0
-3
beat/core/test/test_docker_worker.py
beat/core/test/test_docker_worker.py
+0
-3
buildout.cfg
buildout.cfg
+7
-1
conda/meta.yaml
conda/meta.yaml
+2
-0
develop.cfg
develop.cfg
+7
-1
No files found.
beat/core/dock.py
View file @
8eb5c22a
...
@@ -48,6 +48,45 @@ from beat.core import stats
...
@@ -48,6 +48,45 @@ from beat.core import stats
logger
=
logging
.
getLogger
(
__name__
)
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
):
class
Host
(
object
):
"""An object of this class can connect to the docker host and resolve stuff
"""An object of this class can connect to the docker host and resolve stuff
"""
"""
...
...
beat/core/test/__init__.py
View file @
8eb5c22a
...
@@ -73,45 +73,6 @@ if VERBOSE_TEST_LOGGING:
...
@@ -73,45 +73,6 @@ if VERBOSE_TEST_LOGGING:
logger
.
addHandler
(
handler
)
logger
.
addHandler
(
handler
)
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
"""
def
setup_docker_test_images
():
"""To be called when you need to set those up. Check ``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
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
)
def
setup_package
():
def
setup_package
():
prefixes
=
[
prefixes
=
[
pkg_resources
.
resource_filename
(
'beat.backend.python.test'
,
'prefix'
),
pkg_resources
.
resource_filename
(
'beat.backend.python.test'
,
'prefix'
),
...
...
beat/core/test/test_docker.py
View file @
8eb5c22a
...
@@ -50,9 +50,6 @@ from .utils import skipif
...
@@ -50,9 +50,6 @@ from .utils import skipif
from
.
import
network_name
from
.
import
network_name
from
.
import
DOCKER_NETWORK_TEST_ENABLED
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
):
class
NoDiscoveryTests
(
unittest
.
TestCase
):
"""Test cases that don't require the discovery of database and runtime
"""Test cases that don't require the discovery of database and runtime
...
...
beat/core/test/test_docker_databases_provider.py
View file @
8eb5c22a
...
@@ -54,9 +54,6 @@ from ..utils import find_free_port
...
@@ -54,9 +54,6 @@ from ..utils import find_free_port
from
.
import
prefix
from
.
import
prefix
from
.
import
tmp_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 @
8eb5c22a
...
@@ -33,9 +33,6 @@ from .. import environments
...
@@ -33,9 +33,6 @@ from .. import environments
from
.utils
import
slow
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
):
class
EnvironmentTest
(
unittest
.
TestCase
):
...
...
beat/core/test/test_docker_execution.py
View file @
8eb5c22a
...
@@ -44,9 +44,6 @@ from . import network_name
...
@@ -44,9 +44,6 @@ from . import network_name
from
.
import
prefix_folder
from
.
import
prefix_folder
from
.
import
DOCKER_NETWORK_TEST_ENABLED
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"
BUILDER_IMAGE
=
"docker.idiap.ch/beat/beat.env.client:2.0.0r0"
#----------------------------------------------------------
#----------------------------------------------------------
...
...
beat/core/test/test_docker_worker.py
View file @
8eb5c22a
...
@@ -32,9 +32,6 @@ from ..dock import Host
...
@@ -32,9 +32,6 @@ from ..dock import Host
from
.test_worker
import
TestOneWorker
,
TestTwoWorkers
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
#----------------------------------------------------------
#----------------------------------------------------------
...
...
buildout.cfg
View file @
8eb5c22a
[buildout]
[buildout]
parts = scripts
parts = scripts
docker
eggs = beat.core
eggs = beat.core
develop = .
develop = .
newest = false
newest = false
[scripts]
[scripts]
recipe = bob.buildout:scripts
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()'
on_install = true
on_update = true
conda/meta.yaml
View file @
8eb5c22a
...
@@ -52,6 +52,8 @@ test:
...
@@ -52,6 +52,8 @@ test:
-
{{
name
}}
-
{{
name
}}
commands
:
commands
:
# pulls required images once before running the tests
-
python -c "from beat.core.dock import pull_docker_test_images as f; f()"
-
worker --help
-
worker --help
-
nosetests --with-coverage --cover-package={{ name }} -sv {{ name }}
-
nosetests --with-coverage --cover-package={{ name }} -sv {{ name }}
-
sphinx-build -aEW {{ project_dir }}/doc {{ project_dir }}/sphinx
-
sphinx-build -aEW {{ project_dir }}/doc {{ project_dir }}/sphinx
...
...
develop.cfg
View file @
8eb5c22a
[buildout]
[buildout]
parts = scripts
parts = scripts
docker
extensions = mr.developer
extensions = mr.developer
auto-checkout = *
auto-checkout = *
develop = src/beat.backend.python
develop = src/beat.backend.python
...
@@ -13,3 +13,9 @@ beat.backend.python = git https://gitlab.idiap.ch/beat/beat.backend.python
...
@@ -13,3 +13,9 @@ beat.backend.python = git https://gitlab.idiap.ch/beat/beat.backend.python
[scripts]
[scripts]
recipe = bob.buildout:scripts
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()'
on_install = true
on_update = true
Write
Preview
Markdown
is supported
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