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
c1577606
Kaydet (Commit)
c1577606
authored
Eyl 28, 2015
tarafından
Pierre Fersing
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added test for "top" function
Signed-off-by:
Pierre Fersing
<
pierre.fersing@bleemeo.com
>
üst
2d4a71df
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
fake_api.py
tests/fake_api.py
+29
-0
integration_test.py
tests/integration_test.py
+38
-0
test.py
tests/test.py
+20
-0
No files found.
tests/fake_api.py
Dosyayı görüntüle @
c1577606
...
...
@@ -383,6 +383,33 @@ def get_fake_stats():
return
status_code
,
response
def
get_fake_top
():
return
200
,
{
'Processes'
:
[
[
'root'
,
'26501'
,
'6907'
,
'0'
,
'10:32'
,
'pts/55'
,
'00:00:00'
,
'sleep 60'
,
],
],
'Titles'
:
[
'UID'
,
'PID'
,
'PPID'
,
'C'
,
'STIME'
,
'TTY'
,
'TIME'
,
'CMD'
,
],
}
def
get_fake_volume_list
():
status_code
=
200
response
=
{
...
...
@@ -462,6 +489,8 @@ fake_responses = {
'{1}/{0}/containers/3cc2351ab11b/stats'
.
format
(
CURRENT_VERSION
,
prefix
):
get_fake_stats
,
'{1}/{0}/containers/3cc2351ab11b/top'
.
format
(
CURRENT_VERSION
,
prefix
):
get_fake_top
,
'{1}/{0}/containers/3cc2351ab11b/stop'
.
format
(
CURRENT_VERSION
,
prefix
):
post_fake_stop_container
,
'{1}/{0}/containers/3cc2351ab11b/kill'
.
format
(
CURRENT_VERSION
,
prefix
):
...
...
tests/integration_test.py
Dosyayı görüntüle @
c1577606
...
...
@@ -786,6 +786,44 @@ class TestMacAddress(BaseTestCase):
self
.
client
.
kill
(
id
)
class
TestContainerTop
(
BaseTestCase
):
def
runTest
(
self
):
container
=
self
.
client
.
create_container
(
BUSYBOX
,
[
'sleep'
,
'60'
])
id
=
container
[
'Id'
]
self
.
client
.
start
(
container
)
res
=
self
.
client
.
top
(
container
[
'Id'
])
print
(
res
)
self
.
assertEqual
(
res
[
'Titles'
],
[
'UID'
,
'PID'
,
'PPID'
,
'C'
,
'STIME'
,
'TTY'
,
'TIME'
,
'CMD'
]
)
self
.
assertEqual
(
len
(
res
[
'Processes'
]),
1
)
self
.
assertEqual
(
res
[
'Processes'
][
0
][
7
],
'sleep 60'
)
self
.
client
.
kill
(
id
)
class
TestContainerTopWithPsArgs
(
BaseTestCase
):
def
runTest
(
self
):
container
=
self
.
client
.
create_container
(
BUSYBOX
,
[
'sleep'
,
'60'
])
id
=
container
[
'Id'
]
self
.
client
.
start
(
container
)
res
=
self
.
client
.
top
(
container
[
'Id'
],
'waux'
)
self
.
assertEqual
(
res
[
'Titles'
],
[
'USER'
,
'PID'
,
'
%
CPU'
,
'
%
MEM'
,
'VSZ'
,
'RSS'
,
'TTY'
,
'STAT'
,
'START'
,
'TIME'
,
'COMMAND'
],
)
self
.
assertEqual
(
len
(
res
[
'Processes'
]),
1
)
self
.
assertEqual
(
res
[
'Processes'
][
0
][
10
],
'sleep 60'
)
self
.
client
.
kill
(
id
)
class
TestRestart
(
BaseTestCase
):
def
runTest
(
self
):
container
=
self
.
client
.
create_container
(
BUSYBOX
,
[
'sleep'
,
'9999'
])
...
...
tests/test.py
Dosyayı görüntüle @
c1577606
...
...
@@ -1713,6 +1713,26 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
stream
=
True
)
def
test_container_top
(
self
):
self
.
client
.
top
(
fake_api
.
FAKE_CONTAINER_ID
)
fake_request
.
assert_called_with
(
'GET'
,
url_prefix
+
'containers/3cc2351ab11b/top'
,
params
=
{},
timeout
=
DEFAULT_TIMEOUT_SECONDS
)
def
test_container_top_with_psargs
(
self
):
self
.
client
.
top
(
fake_api
.
FAKE_CONTAINER_ID
,
'waux'
)
fake_request
.
assert_called_with
(
'GET'
,
url_prefix
+
'containers/3cc2351ab11b/top'
,
params
=
{
'ps_args'
:
'waux'
},
timeout
=
DEFAULT_TIMEOUT_SECONDS
)
##################
# IMAGES TESTS #
##################
...
...
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