blob: ab4fe644e783e6bbecd457015bfa87d13ee3910b [file] [log] [blame]
Hanna Arhipova55cc1292019-01-08 14:22:18 +02001import pytest
2import time
3import subprocess
Hanna Arhipova16e93fb2019-01-23 19:03:01 +02004import utils
Hanna Arhipova55cc1292019-01-08 14:22:18 +02005
6
7@pytest.fixture
8def create_image():
9 line = 'echo "Executing dd on $(hostname -f)"; ' \
10 'dd if=/dev/zero of=/tmp/image_mk_framework.dd bs=1M count=9000 ;' \
11 'echo "Free space :" ; ' \
12 'df -H / '
13
14 subprocess.call(line.split())
15 yield
16 # teardown
17 subprocess.call('rm /tmp/image_mk_framework.dd'.split())
18 subprocess.call('rm /tmp/image_mk_framework.download'.split())
19
20
21def test_speed_glance(create_image, openstack_clients, record_property):
22 """
23 Simplified Performance Tests Download / upload lance
24 1. Step download image
25 2. Step upload image
26 """
27 image = openstack_clients.image.images.create(
28 name="test_image",
29 disk_format='iso',
30 container_format='bare')
31
32 start_time = time.time()
33 openstack_clients.image.images.upload(
34 image.id,
35 image_data=open("/tmp/image_mk_framework.dd", 'rb'))
36 end_time = time.time()
37
38 speed_upload = 9000 / (end_time - start_time)
39
40 start_time = time.time()
41 with open("/tmp/image_mk_framework.download", 'wb') as image_file:
42 for item in openstack_clients.image.images.data(image.id):
43 image_file.write(item)
44 end_time = time.time()
45
46 speed_download = 9000 / (end_time - start_time)
47
48 openstack_clients.image.images.delete(image.id)
49 record_property("Upload", speed_upload)
50 record_property("Download", speed_download)
51
52 print "++++++++++++++++++++++++++++++++++++++++"
53 print 'upload - {} Mb/s'.format(speed_upload)
54 print 'download - {} Mb/s'.format(speed_download)