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
bb148380
Kaydet (Commit)
bb148380
authored
Eki 26, 2017
tarafından
Joffrey F
Kaydeden (comit)
Joffrey F
Eki 27, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More ContainerSpec tests
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
856414bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
32 deletions
+69
-32
api_config_test.py
tests/integration/api_config_test.py
+9
-6
api_secret_test.py
tests/integration/api_secret_test.py
+9
-6
api_service_test.py
tests/integration/api_service_test.py
+37
-14
base.py
tests/integration/base.py
+14
-6
No files found.
tests/integration/api_config_test.py
Dosyayı görüntüle @
bb148380
...
@@ -9,13 +9,16 @@ from .base import BaseAPIIntegrationTest
...
@@ -9,13 +9,16 @@ from .base import BaseAPIIntegrationTest
@requires_api_version
(
'1.30'
)
@requires_api_version
(
'1.30'
)
class
ConfigAPITest
(
BaseAPIIntegrationTest
):
class
ConfigAPITest
(
BaseAPIIntegrationTest
):
def
setUp
(
self
):
@classmethod
super
(
ConfigAPITest
,
self
)
.
setUp
()
def
setup_class
(
cls
):
self
.
init_swarm
()
client
=
cls
.
get_client_instance
()
force_leave_swarm
(
client
)
cls
.
_init_swarm
(
client
)
def
tearDown
(
self
):
@classmethod
super
(
ConfigAPITest
,
self
)
.
tearDown
()
def
teardown_class
(
cls
):
force_leave_swarm
(
self
.
client
)
client
=
cls
.
get_client_instance
()
force_leave_swarm
(
client
)
def
test_create_config
(
self
):
def
test_create_config
(
self
):
config_id
=
self
.
client
.
create_config
(
config_id
=
self
.
client
.
create_config
(
...
...
tests/integration/api_secret_test.py
Dosyayı görüntüle @
bb148380
...
@@ -9,13 +9,16 @@ from .base import BaseAPIIntegrationTest
...
@@ -9,13 +9,16 @@ from .base import BaseAPIIntegrationTest
@requires_api_version
(
'1.25'
)
@requires_api_version
(
'1.25'
)
class
SecretAPITest
(
BaseAPIIntegrationTest
):
class
SecretAPITest
(
BaseAPIIntegrationTest
):
def
setUp
(
self
):
@classmethod
super
(
SecretAPITest
,
self
)
.
setUp
()
def
setup_class
(
cls
):
self
.
init_swarm
()
client
=
cls
.
get_client_instance
()
force_leave_swarm
(
client
)
cls
.
_init_swarm
(
client
)
def
tearDown
(
self
):
@classmethod
super
(
SecretAPITest
,
self
)
.
tearDown
()
def
teardown_class
(
cls
):
force_leave_swarm
(
self
.
client
)
client
=
cls
.
get_client_instance
()
force_leave_swarm
(
client
)
def
test_create_secret
(
self
):
def
test_create_secret
(
self
):
secret_id
=
self
.
client
.
create_secret
(
secret_id
=
self
.
client
.
create_secret
(
...
...
tests/integration/api_service_test.py
Dosyayı görüntüle @
bb148380
...
@@ -13,19 +13,24 @@ from .base import BaseAPIIntegrationTest, BUSYBOX
...
@@ -13,19 +13,24 @@ from .base import BaseAPIIntegrationTest, BUSYBOX
class
ServiceTest
(
BaseAPIIntegrationTest
):
class
ServiceTest
(
BaseAPIIntegrationTest
):
def
setUp
(
self
):
@classmethod
super
(
ServiceTest
,
self
)
.
setUp
()
def
setup_class
(
cls
):
force_leave_swarm
(
self
.
client
)
client
=
cls
.
get_client_instance
()
self
.
init_swarm
()
force_leave_swarm
(
client
)
cls
.
_init_swarm
(
client
)
@classmethod
def
teardown_class
(
cls
):
client
=
cls
.
get_client_instance
()
force_leave_swarm
(
client
)
def
tearDown
(
self
):
def
tearDown
(
self
):
super
(
ServiceTest
,
self
)
.
tearDown
()
for
service
in
self
.
client
.
services
(
filters
=
{
'name'
:
'dockerpytest_'
}):
for
service
in
self
.
client
.
services
(
filters
=
{
'name'
:
'dockerpytest_'
}):
try
:
try
:
self
.
client
.
remove_service
(
service
[
'ID'
])
self
.
client
.
remove_service
(
service
[
'ID'
])
except
docker
.
errors
.
APIError
:
except
docker
.
errors
.
APIError
:
pass
pass
force_leave_swarm
(
self
.
client
)
super
(
ServiceTest
,
self
)
.
tearDown
(
)
def
get_service_name
(
self
):
def
get_service_name
(
self
):
return
'dockerpytest_{0:x}'
.
format
(
random
.
getrandbits
(
64
))
return
'dockerpytest_{0:x}'
.
format
(
random
.
getrandbits
(
64
))
...
@@ -473,7 +478,7 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -473,7 +478,7 @@ class ServiceTest(BaseAPIIntegrationTest):
secret_data
=
u'東方花映塚'
secret_data
=
u'東方花映塚'
secret_id
=
self
.
client
.
create_secret
(
secret_name
,
secret_data
)
secret_id
=
self
.
client
.
create_secret
(
secret_name
,
secret_data
)
self
.
tmp_secrets
.
append
(
secret_id
)
self
.
tmp_secrets
.
append
(
secret_id
)
secret_ref
=
docker
.
types
.
Config
Reference
(
secret_id
,
secret_name
)
secret_ref
=
docker
.
types
.
Secret
Reference
(
secret_id
,
secret_name
)
container_spec
=
docker
.
types
.
ContainerSpec
(
container_spec
=
docker
.
types
.
ContainerSpec
(
'busybox'
,
[
'sleep'
,
'999'
],
secrets
=
[
secret_ref
]
'busybox'
,
[
'sleep'
,
'999'
],
secrets
=
[
secret_ref
]
)
)
...
@@ -481,8 +486,8 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -481,8 +486,8 @@ class ServiceTest(BaseAPIIntegrationTest):
name
=
self
.
get_service_name
()
name
=
self
.
get_service_name
()
svc_id
=
self
.
client
.
create_service
(
task_tmpl
,
name
=
name
)
svc_id
=
self
.
client
.
create_service
(
task_tmpl
,
name
=
name
)
svc_info
=
self
.
client
.
inspect_service
(
svc_id
)
svc_info
=
self
.
client
.
inspect_service
(
svc_id
)
assert
'
Config
s'
in
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
]
assert
'
Secret
s'
in
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
]
secrets
=
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
][
'
Config
s'
]
secrets
=
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
][
'
Secret
s'
]
assert
secrets
[
0
]
==
secret_ref
assert
secrets
[
0
]
==
secret_ref
container
=
self
.
get_service_container
(
name
)
container
=
self
.
get_service_container
(
name
)
...
@@ -494,7 +499,7 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -494,7 +499,7 @@ class ServiceTest(BaseAPIIntegrationTest):
container_secret
=
container_secret
.
decode
(
'utf-8'
)
container_secret
=
container_secret
.
decode
(
'utf-8'
)
assert
container_secret
==
secret_data
assert
container_secret
==
secret_data
@requires_api_version
(
'1.
25
'
)
@requires_api_version
(
'1.
30
'
)
def
test_create_service_with_config
(
self
):
def
test_create_service_with_config
(
self
):
config_name
=
'favorite_touhou'
config_name
=
'favorite_touhou'
config_data
=
b
'phantasmagoria of flower view'
config_data
=
b
'phantasmagoria of flower view'
...
@@ -515,11 +520,11 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -515,11 +520,11 @@ class ServiceTest(BaseAPIIntegrationTest):
container
=
self
.
get_service_container
(
name
)
container
=
self
.
get_service_container
(
name
)
assert
container
is
not
None
assert
container
is
not
None
exec_id
=
self
.
client
.
exec_create
(
exec_id
=
self
.
client
.
exec_create
(
container
,
'cat /
run/configs/
{0}'
.
format
(
config_name
)
container
,
'cat /{0}'
.
format
(
config_name
)
)
)
assert
self
.
client
.
exec_start
(
exec_id
)
==
config_data
assert
self
.
client
.
exec_start
(
exec_id
)
==
config_data
@requires_api_version
(
'1.
25
'
)
@requires_api_version
(
'1.
30
'
)
def
test_create_service_with_unicode_config
(
self
):
def
test_create_service_with_unicode_config
(
self
):
config_name
=
'favorite_touhou'
config_name
=
'favorite_touhou'
config_data
=
u'東方花映塚'
config_data
=
u'東方花映塚'
...
@@ -540,7 +545,7 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -540,7 +545,7 @@ class ServiceTest(BaseAPIIntegrationTest):
container
=
self
.
get_service_container
(
name
)
container
=
self
.
get_service_container
(
name
)
assert
container
is
not
None
assert
container
is
not
None
exec_id
=
self
.
client
.
exec_create
(
exec_id
=
self
.
client
.
exec_create
(
container
,
'cat /
run/configs/
{0}'
.
format
(
config_name
)
container
,
'cat /{0}'
.
format
(
config_name
)
)
)
container_config
=
self
.
client
.
exec_start
(
exec_id
)
container_config
=
self
.
client
.
exec_start
(
exec_id
)
container_config
=
container_config
.
decode
(
'utf-8'
)
container_config
=
container_config
.
decode
(
'utf-8'
)
...
@@ -618,7 +623,7 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -618,7 +623,7 @@ class ServiceTest(BaseAPIIntegrationTest):
second
=
1000000000
second
=
1000000000
hc
=
docker
.
types
.
Healthcheck
(
hc
=
docker
.
types
.
Healthcheck
(
test
=
'true'
,
retries
=
3
,
timeout
=
1
*
second
,
test
=
'true'
,
retries
=
3
,
timeout
=
1
*
second
,
start_period
=
3
*
second
,
interval
=
second
/
2
,
start_period
=
3
*
second
,
interval
=
int
(
second
/
2
)
,
)
)
container_spec
=
docker
.
types
.
ContainerSpec
(
container_spec
=
docker
.
types
.
ContainerSpec
(
BUSYBOX
,
[
'sleep'
,
'999'
],
healthcheck
=
hc
BUSYBOX
,
[
'sleep'
,
'999'
],
healthcheck
=
hc
...
@@ -665,3 +670,21 @@ class ServiceTest(BaseAPIIntegrationTest):
...
@@ -665,3 +670,21 @@ class ServiceTest(BaseAPIIntegrationTest):
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
][
'StopSignal'
]
==
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
][
'StopSignal'
]
==
'SIGINT'
'SIGINT'
)
)
@requires_api_version
(
'1.30'
)
def
test_create_service_with_privileges
(
self
):
priv
=
docker
.
types
.
Privileges
(
selinux_disable
=
True
)
container_spec
=
docker
.
types
.
ContainerSpec
(
BUSYBOX
,
[
'sleep'
,
'999'
],
privileges
=
priv
)
task_tmpl
=
docker
.
types
.
TaskTemplate
(
container_spec
)
name
=
self
.
get_service_name
()
svc_id
=
self
.
client
.
create_service
(
task_tmpl
,
name
=
name
)
svc_info
=
self
.
client
.
inspect_service
(
svc_id
)
assert
(
'Privileges'
in
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
]
)
privileges
=
(
svc_info
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
][
'Privileges'
]
)
assert
privileges
[
'SELinuxContext'
][
'Disable'
]
is
True
tests/integration/base.py
Dosyayı görüntüle @
bb148380
...
@@ -78,14 +78,24 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
...
@@ -78,14 +78,24 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
BaseAPIIntegrationTest
,
self
)
.
setUp
()
super
(
BaseAPIIntegrationTest
,
self
)
.
setUp
()
self
.
client
=
docker
.
APIClient
(
self
.
client
=
self
.
get_client_instance
()
version
=
TEST_API_VERSION
,
timeout
=
60
,
**
kwargs_from_env
()
)
def
tearDown
(
self
):
def
tearDown
(
self
):
super
(
BaseAPIIntegrationTest
,
self
)
.
tearDown
()
super
(
BaseAPIIntegrationTest
,
self
)
.
tearDown
()
self
.
client
.
close
()
self
.
client
.
close
()
@staticmethod
def
get_client_instance
():
return
docker
.
APIClient
(
version
=
TEST_API_VERSION
,
timeout
=
60
,
**
kwargs_from_env
()
)
@staticmethod
def
_init_swarm
(
client
,
**
kwargs
):
return
client
.
init_swarm
(
'127.0.0.1'
,
listen_addr
=
helpers
.
swarm_listen_addr
(),
**
kwargs
)
def
run_container
(
self
,
*
args
,
**
kwargs
):
def
run_container
(
self
,
*
args
,
**
kwargs
):
container
=
self
.
client
.
create_container
(
*
args
,
**
kwargs
)
container
=
self
.
client
.
create_container
(
*
args
,
**
kwargs
)
self
.
tmp_containers
.
append
(
container
)
self
.
tmp_containers
.
append
(
container
)
...
@@ -116,6 +126,4 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
...
@@ -116,6 +126,4 @@ class BaseAPIIntegrationTest(BaseIntegrationTest):
assert
actual_exit_code
==
exit_code
,
msg
assert
actual_exit_code
==
exit_code
,
msg
def
init_swarm
(
self
,
**
kwargs
):
def
init_swarm
(
self
,
**
kwargs
):
return
self
.
client
.
init_swarm
(
return
self
.
_init_swarm
(
self
.
client
,
**
kwargs
)
'127.0.0.1'
,
listen_addr
=
helpers
.
swarm_listen_addr
(),
**
kwargs
)
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