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
e304f91b
Kaydet (Commit)
e304f91b
authored
Ock 30, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Update detach tests to work with AF_INET as well
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
dd858648
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
36 deletions
+54
-36
Makefile
Makefile
+1
-1
helpers.py
tests/helpers.py
+12
-5
api_container_test.py
tests/integration/api_container_test.py
+15
-16
api_exec_test.py
tests/integration/api_exec_test.py
+26
-14
No files found.
Makefile
Dosyayı görüntüle @
e304f91b
...
...
@@ -54,7 +54,7 @@ integration-dind-py2: build
-H
tcp://0.0.0.0:2375
--experimental
docker run
-t
--rm
--env
=
"DOCKER_HOST=tcp://docker:2375"
--env
=
"DOCKER_TEST_API_VERSION=
${
TEST_API_VERSION
}
"
\
--link
=
dpy-dind-py2:docker docker-sdk-python py.test tests/integration
docker
rm
-vf
dpy-dind-py
3
docker
rm
-vf
dpy-dind-py
2
.PHONY
:
integration-dind-py3
integration-dind-py3
:
build-py3
...
...
tests/helpers.py
Dosyayı görüntüle @
e304f91b
...
...
@@ -6,8 +6,8 @@ import tarfile
import
tempfile
import
time
import
re
import
socket
import
six
import
socket
import
docker
import
pytest
...
...
@@ -107,16 +107,23 @@ def swarm_listen_addr():
return
'0.0.0.0:{0}'
.
format
(
random
.
randrange
(
10000
,
25000
))
def
assert_
socket_clos
ed_with_keys
(
sock
,
inputs
):
def
assert_
cat_socket_detach
ed_with_keys
(
sock
,
inputs
):
if
six
.
PY3
:
sock
=
sock
.
_sock
for
i
in
inputs
:
sock
.
send
(
i
)
time
.
sleep
(
1
)
with
pytest
.
raises
(
socket
.
error
):
time
.
sleep
(
0.5
)
# If we're using a Unix socket, the sock.send call will fail with a
# BrokenPipeError ; INET sockets will just stop receiving / sending data
# but will not raise an error
if
sock
.
family
==
getattr
(
socket
,
'AF_UNIX'
,
-
1
):
with
pytest
.
raises
(
socket
.
error
):
sock
.
send
(
b
'make sure the socket is closed
\n
'
)
else
:
sock
.
send
(
b
"make sure the socket is closed
\n
"
)
assert
sock
.
recv
(
32
)
==
b
''
def
ctrl_with
(
char
):
...
...
tests/integration/api_container_test.py
Dosyayı görüntüle @
e304f91b
...
...
@@ -17,7 +17,7 @@ import six
from
.base
import
BUSYBOX
,
BaseAPIIntegrationTest
from
..
import
helpers
from
..helpers
import
(
requires_api_version
,
ctrl_with
,
assert_
socket_clos
ed_with_keys
requires_api_version
,
ctrl_with
,
assert_
cat_socket_detach
ed_with_keys
)
...
...
@@ -1227,55 +1227,54 @@ class AttachContainerTest(BaseAPIIntegrationTest):
def
test_detach_with_default
(
self
):
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'
/bin/sh
'
,
BUSYBOX
,
'
cat
'
,
detach
=
True
,
stdin_open
=
True
,
tty
=
True
)
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
container
)
self
.
client
.
start
(
container
)
sock
=
self
.
client
.
attach_socket
(
container
,
{
'stdin'
:
True
,
'stream'
:
True
}
)
assert_socket_closed_with_keys
(
sock
,
[
ctrl_with
(
'p'
),
ctrl_with
(
'q'
)])
assert_cat_socket_detached_with_keys
(
sock
,
[
ctrl_with
(
'p'
),
ctrl_with
(
'q'
)]
)
def
test_detach_with_config_file
(
self
):
self
.
client
.
_general_configs
[
'detachKeys'
]
=
'ctrl-p'
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'
/bin/sh
'
,
BUSYBOX
,
'
cat
'
,
detach
=
True
,
stdin_open
=
True
,
tty
=
True
)
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
container
)
self
.
client
.
start
(
container
)
sock
=
self
.
client
.
attach_socket
(
container
,
{
'stdin'
:
True
,
'stream'
:
True
}
)
assert_
socket_clos
ed_with_keys
(
sock
,
[
ctrl_with
(
'p'
)])
assert_
cat_socket_detach
ed_with_keys
(
sock
,
[
ctrl_with
(
'p'
)])
def
test_detach_with_arg
(
self
):
self
.
client
.
_general_configs
[
'detachKeys'
]
=
'ctrl-p'
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'
/bin/sh
'
,
BUSYBOX
,
'
cat
'
,
detach
=
True
,
stdin_open
=
True
,
tty
=
True
)
id
=
container
[
'Id'
]
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
container
)
self
.
client
.
start
(
container
)
sock
=
self
.
client
.
attach_socket
(
container
,
{
'stdin'
:
True
,
'stream'
:
True
,
'detachKeys'
:
'ctrl-x'
}
)
assert_
socket_clos
ed_with_keys
(
sock
,
[
ctrl_with
(
'x'
)])
assert_
cat_socket_detach
ed_with_keys
(
sock
,
[
ctrl_with
(
'x'
)])
class
PauseTest
(
BaseAPIIntegrationTest
):
...
...
tests/integration/api_exec_test.py
Dosyayı görüntüle @
e304f91b
...
...
@@ -3,7 +3,7 @@ from docker.utils.socket import read_exactly
from
.base
import
BaseAPIIntegrationTest
,
BUSYBOX
from
..helpers
import
(
requires_api_version
,
ctrl_with
,
assert_
socket_clos
ed_with_keys
requires_api_version
,
ctrl_with
,
assert_
cat_socket_detach
ed_with_keys
)
...
...
@@ -152,42 +152,54 @@ class ExecTest(BaseAPIIntegrationTest):
assert
exec_log
==
b
'/var/www
\n
'
def
test_detach_with_default
(
self
):
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
exec_id
=
self
.
client
.
exec_create
(
id
,
'/bin/sh'
,
stdin
=
True
,
tty
=
True
)
exec_id
=
self
.
client
.
exec_create
(
id
,
'cat'
,
stdin
=
True
,
tty
=
True
,
stdout
=
True
)
sock
=
self
.
client
.
exec_start
(
exec_id
,
tty
=
True
,
socket
=
True
)
self
.
addCleanup
(
sock
.
close
)
assert_socket_closed_with_keys
(
sock
,
[
ctrl_with
(
'p'
),
ctrl_with
(
'q'
)])
assert_cat_socket_detached_with_keys
(
sock
,
[
ctrl_with
(
'p'
),
ctrl_with
(
'q'
)]
)
def
test_detach_with_config_file
(
self
):
self
.
client
.
_general_configs
[
'detachKeys'
]
=
'ctrl-p'
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
exec_id
=
self
.
client
.
exec_create
(
id
,
'/bin/sh'
,
stdin
=
True
,
tty
=
True
)
exec_id
=
self
.
client
.
exec_create
(
id
,
'cat'
,
stdin
=
True
,
tty
=
True
,
stdout
=
True
)
sock
=
self
.
client
.
exec_start
(
exec_id
,
tty
=
True
,
socket
=
True
)
self
.
addCleanup
(
sock
.
close
)
assert_
socket_clos
ed_with_keys
(
sock
,
[
ctrl_with
(
'p'
)])
assert_
cat_socket_detach
ed_with_keys
(
sock
,
[
ctrl_with
(
'p'
)])
def
test_detach_with_arg
(
self
):
self
.
client
.
_general_configs
[
'detachKeys'
]
=
'ctrl-p'
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
id
=
container
[
'Id'
]
self
.
client
.
start
(
id
)
self
.
tmp_containers
.
append
(
id
)
exec_id
=
self
.
client
.
exec_create
(
id
,
'
/bin/sh
'
,
stdin
=
True
,
tty
=
True
,
detach_keys
=
'ctrl-x'
id
,
'
cat
'
,
stdin
=
True
,
tty
=
True
,
detach_keys
=
'ctrl-x'
,
stdout
=
True
)
sock
=
self
.
client
.
exec_start
(
exec_id
,
tty
=
True
,
socket
=
True
)
self
.
addCleanup
(
sock
.
close
)
assert_
socket_clos
ed_with_keys
(
sock
,
[
ctrl_with
(
'x'
)])
assert_
cat_socket_detach
ed_with_keys
(
sock
,
[
ctrl_with
(
'x'
)])
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