Skip to content

Commit 5cfd2da

Browse files
committed
Add test for streaming stats
Also, fix typo in non-streaming stats. Signed-off-by: Antonis Kalipetis <[email protected]>
1 parent 192391a commit 5cfd2da

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/integration/container_test.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ def test_pause_unpause(self):
991991
self.assertEqual(state['Paused'], False)
992992

993993

994-
class GetContainerStatsTest(BaseTestCase):
994+
class GetContainerStatsTest(api_test.BaseTestCase):
995995
@requires_api_version('1.19')
996996
def test_get_container_stats_no_stream(self):
997997
container = self.client.create_container(
@@ -1002,7 +1002,21 @@ def test_get_container_stats_no_stream(self):
10021002
response = self.client.stats(container, stream=0)
10031003
self.client.kill(container)
10041004

1005-
self.assertEquals(type(response), dict)
1005+
self.assertEqual(type(response), dict)
10061006
for key in ['read', 'network', 'precpu_stats', 'cpu_stats',
10071007
'memory_stats', 'blkio_stats']:
10081008
self.assertIn(key, response)
1009+
1010+
@requires_api_version('1.17')
1011+
def test_get_container_stats_stream(self):
1012+
container = self.client.create_container(
1013+
BUSYBOX, ['sleep', '60'],
1014+
)
1015+
self.tmp_containers.append(container)
1016+
self.client.start(container)
1017+
stream = self.client.stats(container)
1018+
for chunk in stream:
1019+
self.assertEqual(type(chunk), dict)
1020+
for key in ['read', 'network', 'precpu_stats', 'cpu_stats',
1021+
'memory_stats', 'blkio_stats']:
1022+
self.assertIn(key, chunk)

0 commit comments

Comments
 (0)