Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jupyter Docker Stacks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Jupyter Docker Stacks
Commits
2b75a5af
Commit
2b75a5af
authored
Nov 27, 2017
by
Peter Parente
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to pytest for container testing
parent
18e0e8cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
14 deletions
+61
-14
.travis.yml
.travis.yml
+5
-3
Makefile
Makefile
+4
-11
test/test_notebook.py
test/test_notebook.py
+52
-0
No files found.
.travis.yml
View file @
2b75a5af
language
:
generic
language
:
python
python
:
-
3.6
sudo
:
required
sudo
:
required
services
:
services
:
-
docker
-
docker
install
:
-
pip install pytest docker
script
:
script
:
-
make build-test-all
-
make build-test-all
Makefile
View file @
2b75a5af
...
@@ -54,15 +54,8 @@ dev/%: PORT?=8888
...
@@ -54,15 +54,8 @@ dev/%: PORT?=8888
dev/%
:
##
run a foreground container for a stack
dev/%
:
##
run a foreground container for a stack
docker run
-it
--rm
-p
$(PORT)
:8888
$(DARGS)
$(OWNER)
/
$(
notdir
$@
)
$(ARGS)
docker run
-it
--rm
-p
$(PORT)
:8888
$(DARGS)
$(OWNER)
/
$(
notdir
$@
)
$(ARGS)
test/%
:
@
TEST_IMAGE
=
"
$(OWNER)
/
$(
notdir
$@
)
"
pytest
test
test/base-notebook
:
##
test supported options in the base notebook
test/%
:
##
run a stack container
,
check for jupyter server liveliness
@
TEST_IMAGE
=
"
$(OWNER)
/
$(
notdir
$@
)
"
pytest
test
base-notebook/test
@
-docker
rm
-f
iut
\ No newline at end of file
@
docker run
-d
--name
iut
$(OWNER)
/
$(
notdir
$@
)
@
for
i
in
$$
(
seq
0 9
)
;
do
\
sleep
$$
i
;
\
docker
exec
iut bash
-c
'wget http://localhost:8888 -O- | grep -i jupyter'
;
\
if
[[
$$
?
==
0
]]
;
then
exit
0
;
fi
;
\
done
;
exit
1
test-all
:
$(ALL_IMAGES:%=test/%)
##
test all stacks
\ No newline at end of file
test/test_notebook.py
0 → 100644
View file @
2b75a5af
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import
os
import
time
import
docker
import
pytest
import
requests
@
pytest
.
fixture
(
scope
=
'session'
)
def
docker_client
():
"""Docker client to use"""
return
docker
.
from_env
()
@
pytest
.
fixture
(
scope
=
'session'
)
def
image_name
():
"""Image name to test"""
return
os
.
getenv
(
'TEST_IMAGE'
,
'jupyter/base-notebook'
)
@
pytest
.
fixture
(
scope
=
'function'
)
def
nb_container
(
docker_client
,
image_name
):
"""Notebook container to test"""
container
=
docker_client
.
containers
.
run
(
image_name
,
detach
=
True
,
auto_remove
=
True
,
ports
=
{
'8888/tcp'
:
8888
}
)
yield
container
container
.
kill
()
def
test_server_liveliness
(
nb_container
):
"""Notebook server should eventually respond with HTTP 200 OK."""
for
i
in
range
(
10
):
try
:
resp
=
requests
.
get
(
'http://localhost:8888'
)
except
requests
.
exceptions
.
ConnectionError
:
# Wait a bit and try again. Just because the docker container
# is running doesn't mean the notebook server is ready to accept
# connections inside it.
time
.
sleep
(
i
)
else
:
assert
resp
.
status_code
==
200
break
else
:
assert
False
,
'could not connect to server'
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