Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
54244d0a
Kaydet (Commit)
54244d0a
authored
Mar 14, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add service_logs integration test
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
672a9ee6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
service.py
docker/api/service.py
+2
-1
helpers.py
tests/helpers.py
+10
-0
api_service_test.py
tests/integration/api_service_test.py
+19
-3
No files found.
docker/api/service.py
Dosyayı görüntüle @
54244d0a
...
...
@@ -167,6 +167,7 @@ class ServiceApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.25'
)
@utils.check_resource
def
service_logs
(
self
,
service
,
details
=
False
,
follow
=
False
,
stdout
=
False
,
stderr
=
False
,
since
=
0
,
timestamps
=
False
,
tail
=
'all'
,
is_tty
=
None
):
...
...
@@ -176,7 +177,7 @@ class ServiceApiMixin(object):
or ``journald`` logging drivers.
Args:
service (str): ID or name of the
container
service (str): ID or name of the
service
details (bool): Show extra details provided to logs.
Default: ``False``
follow (bool): Keep connection open to read logs as they are
...
...
tests/helpers.py
Dosyayı görüntüle @
54244d0a
import
functools
import
os
import
os.path
import
random
...
...
@@ -53,6 +54,15 @@ def requires_api_version(version):
)
def
requires_experimental
(
f
):
@functools.wraps
(
f
)
def
wrapped
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
client
.
info
()[
'ExperimentalBuild'
]:
pytest
.
skip
(
'Feature requires Docker Engine experimental mode'
)
return
f
(
self
,
*
args
,
**
kwargs
)
return
wrapped
def
wait_on_condition
(
condition
,
delay
=
0.1
,
timeout
=
40
):
start_time
=
time
.
time
()
while
not
condition
():
...
...
tests/integration/api_service_test.py
Dosyayı görüntüle @
54244d0a
...
...
@@ -5,7 +5,9 @@ import time
import
docker
from
..helpers
import
force_leave_swarm
,
requires_api_version
from
..helpers
import
(
force_leave_swarm
,
requires_api_version
,
requires_experimental
)
from
.base
import
BaseAPIIntegrationTest
,
BUSYBOX
...
...
@@ -27,13 +29,15 @@ class ServiceTest(BaseAPIIntegrationTest):
def
get_service_name
(
self
):
return
'dockerpytest_{0:x}'
.
format
(
random
.
getrandbits
(
64
))
def
get_service_container
(
self
,
service_name
,
attempts
=
20
,
interval
=
0.5
):
def
get_service_container
(
self
,
service_name
,
attempts
=
20
,
interval
=
0.5
,
include_stopped
=
False
):
# There is some delay between the service's creation and the creation
# of the service's containers. This method deals with the uncertainty
# when trying to retrieve the container associated with a service.
while
True
:
containers
=
self
.
client
.
containers
(
filters
=
{
'name'
:
[
service_name
]},
quiet
=
True
filters
=
{
'name'
:
[
service_name
]},
quiet
=
True
,
all
=
include_stopped
)
if
len
(
containers
)
>
0
:
return
containers
[
0
]
...
...
@@ -97,6 +101,18 @@ class ServiceTest(BaseAPIIntegrationTest):
assert
len
(
services
)
==
1
assert
services
[
0
][
'ID'
]
==
svc_id
[
'ID'
]
@requires_api_version
(
'1.25'
)
@requires_experimental
def
test_service_logs
(
self
):
name
,
svc_id
=
self
.
create_simple_service
()
assert
self
.
get_service_container
(
name
,
include_stopped
=
True
)
logs
=
self
.
client
.
service_logs
(
svc_id
,
stdout
=
True
,
is_tty
=
False
)
log_line
=
next
(
logs
)
assert
'hello
\n
'
in
log_line
assert
'com.docker.swarm.service.id={}'
.
format
(
svc_id
[
'ID'
]
)
in
log_line
def
test_create_service_custom_log_driver
(
self
):
container_spec
=
docker
.
types
.
ContainerSpec
(
BUSYBOX
,
[
'echo'
,
'hello'
]
...
...
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