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
12aad176
Kaydet (Commit)
12aad176
authored
Ara 17, 2014
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Re-added start with hostconfig tests
üst
f07524f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
241 additions
and
1 deletion
+241
-1
test.py
tests/test.py
+241
-1
No files found.
tests/test.py
Dosyayı görüntüle @
12aad176
...
...
@@ -707,7 +707,7 @@ class DockerClientTest(Cleanup, unittest.TestCase):
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_
start
_container_with_port_binds
(
self
):
def
test_
create
_container_with_port_binds
(
self
):
self
.
maxDiff
=
None
try
:
self
.
client
.
create_container
(
...
...
@@ -861,6 +861,246 @@ class DockerClientTest(Cleanup, unittest.TestCase):
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_lxc_conf
(
self
):
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
lxc_conf
=
{
'lxc.conf.k'
:
'lxc.conf.value'
}
)
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"LxcConf"
:
[{
"Value"
:
"lxc.conf.value"
,
"Key"
:
"lxc.conf.k"
}]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_lxc_conf_compat
(
self
):
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
lxc_conf
=
[{
'Key'
:
'lxc.conf.k'
,
'Value'
:
'lxc.conf.value'
}]
)
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"LxcConf"
:
[{
"Key"
:
"lxc.conf.k"
,
"Value"
:
"lxc.conf.value"
}]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_binds_ro
(
self
):
try
:
mount_dest
=
'/mnt'
mount_origin
=
'/tmp'
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
binds
=
{
mount_origin
:
{
"bind"
:
mount_dest
,
"ro"
:
True
}})
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Binds"
:
[
"/tmp:/mnt:ro"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_binds_rw
(
self
):
try
:
mount_dest
=
'/mnt'
mount_origin
=
'/tmp'
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
binds
=
{
mount_origin
:
{
"bind"
:
mount_dest
,
"ro"
:
False
}})
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Binds"
:
[
"/tmp:/mnt:rw"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_port_binds
(
self
):
self
.
maxDiff
=
None
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
port_bindings
=
{
1111
:
None
,
2222
:
2222
,
'3333/udp'
:
(
3333
,),
4444
:
(
'127.0.0.1'
,),
5555
:
(
'127.0.0.1'
,
5555
),
6666
:
[(
'127.0.0.1'
,),
(
'192.168.0.1'
,)]
})
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
data
=
json
.
loads
(
args
[
1
][
'data'
])
self
.
assertTrue
(
'1111/tcp'
in
data
[
'PortBindings'
])
self
.
assertTrue
(
'2222/tcp'
in
data
[
'PortBindings'
])
self
.
assertTrue
(
'3333/udp'
in
data
[
'PortBindings'
])
self
.
assertTrue
(
'4444/tcp'
in
data
[
'PortBindings'
])
self
.
assertTrue
(
'5555/tcp'
in
data
[
'PortBindings'
])
self
.
assertTrue
(
'6666/tcp'
in
data
[
'PortBindings'
])
self
.
assertEqual
(
[{
"HostPort"
:
""
,
"HostIp"
:
""
}],
data
[
'PortBindings'
][
'1111/tcp'
]
)
self
.
assertEqual
(
[{
"HostPort"
:
"2222"
,
"HostIp"
:
""
}],
data
[
'PortBindings'
][
'2222/tcp'
]
)
self
.
assertEqual
(
[{
"HostPort"
:
"3333"
,
"HostIp"
:
""
}],
data
[
'PortBindings'
][
'3333/udp'
]
)
self
.
assertEqual
(
[{
"HostPort"
:
""
,
"HostIp"
:
"127.0.0.1"
}],
data
[
'PortBindings'
][
'4444/tcp'
]
)
self
.
assertEqual
(
[{
"HostPort"
:
"5555"
,
"HostIp"
:
"127.0.0.1"
}],
data
[
'PortBindings'
][
'5555/tcp'
]
)
self
.
assertEqual
(
len
(
data
[
'PortBindings'
][
'6666/tcp'
]),
2
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_links
(
self
):
# one link
try
:
link_path
=
'path'
alias
=
'alias'
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
links
=
{
link_path
:
alias
})
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Links"
:
[
"path:alias"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
def
test_start_container_with_multiple_links
(
self
):
try
:
link_path
=
'path'
alias
=
'alias'
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
links
=
{
link_path
+
'1'
:
alias
+
'1'
,
link_path
+
'2'
:
alias
+
'2'
}
)
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Links"
:
[
"path1:alias1"
,
"path2:alias2"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
def
test_start_container_with_links_as_list_of_tuples
(
self
):
# one link
try
:
link_path
=
'path'
alias
=
'alias'
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
links
=
[(
link_path
,
alias
)])
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Links"
:
[
"path:alias"
]}
)
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
}
)
def
test_start_container_privileged
(
self
):
try
:
self
.
client
.
start
(
fake_api
.
FAKE_CONTAINER_ID
,
privileged
=
True
)
except
Exception
as
e
:
self
.
fail
(
'Command should not raise exception: {0}'
.
format
(
e
))
args
=
fake_request
.
call_args
self
.
assertEqual
(
args
[
0
][
0
],
url_prefix
+
'containers/3cc2351ab11b/start'
)
self
.
assertEqual
(
json
.
loads
(
args
[
1
][
'data'
]),
{
"Privileged"
:
True
})
self
.
assertEqual
(
args
[
1
][
'headers'
],
{
'Content-Type'
:
'application/json'
})
self
.
assertEqual
(
args
[
1
][
'timeout'
],
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_start_container_with_dict_instead_of_id
(
self
):
try
:
self
.
client
.
start
({
'Id'
:
fake_api
.
FAKE_CONTAINER_ID
})
...
...
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