[cvp-spt] Allow to redefine flavor parameters from environment variables
Additional changes:
* remake calling 'image_name' variable for more pythonic way
* subprocess.call calls with shell=True when creating the image
* fix the deprecation message from yaml.load
Change-Id: Ic057f7b0364eed2ab0693569b1330e8066def757
Related-Prod:#PROD-26971(PROD:26971)
diff --git a/test_set/cvp-spt/README.md b/test_set/cvp-spt/README.md
index 125521f..eb76c1f 100644
--- a/test_set/cvp-spt/README.md
+++ b/test_set/cvp-spt/README.md
@@ -4,9 +4,16 @@
* Set IMAGE_SIZE_MB env variable to have specific image size in cvp-spt/test_glance.py tests
+* [test_vm2vm] allowable next overrides:
+flavor_name='spt-test' to set flavor name
+flavor_ram=1536 to define RAM allocation for specific flavor
+flavor_vcpus=1 to define a count of vCPU for flavor
+flavor_disk=5 to define a count of disks on flavor
+
* *cvp-spt.test_glance* Error may happen while executing images.upload:
```python
CommunicationError: Error finding address for http://os-ctl-vip.<>.local:9292/v2/images/8bce33dd-9837-4646-b747-7f7f5ce01092/file:
Unable to establish connection to http://os-ctl-vip.<>.local:9292/v2/images/8bce33dd-9837-4646-b747-7f7f5ce01092/file: [Errno 32] Broken pipe
```
-This may happen because of low disk space on ctl node or old cryptography package (will be fixed after upgrading to Python3)
\ No newline at end of file
+This may happen because of low disk space on ctl node or old cryptography package (will be fixed after upgrading to Python3)
+
diff --git a/test_set/cvp-spt/fixtures/base.py b/test_set/cvp-spt/fixtures/base.py
index 34a598e..b445e62 100644
--- a/test_set/cvp-spt/fixtures/base.py
+++ b/test_set/cvp-spt/fixtures/base.py
@@ -53,7 +53,11 @@
os_actions = os_client.OSCliActions(openstack_clients)
os_resource = {}
config = utils.get_configuration()
- image_name = config.get('image_name') or ['Ubuntu']
+ image_name = config.get('image_name', 'Ubuntu')
+ flavor_name = config.get('flavor_name', 'spt-test')
+ flavor_ram = config.get('flavor_ram', 1536)
+ flavor_vcpus = config.get('flavor_vcpus', 1)
+ flavor_disk = config.get('flavor_disk', 3)
os_images_list = [image.id for image in openstack_clients.image.images.list(filters={'name': image_name})]
if os_images_list.__len__() == 0:
@@ -61,14 +65,15 @@
os_resource['image_id'] = str(os_images_list[0])
- os_resource['flavor_id'] = [flavor.id for flavor in openstack_clients.compute.flavors.list() if flavor.name == 'spt-test']
+ os_resource['flavor_id'] = [flavor.id for flavor in openstack_clients.compute.flavors.list() if flavor.name == flavor_name]
if not os_resource['flavor_id']:
- os_resource['flavor_id'] = os_actions.create_flavor('spt-test', 1536, 1, 3).id
+ os_resource['flavor_id'] = os_actions.create_flavor(flavor_name, flavor_ram, flavor_vcpus, flavor_disk).id
else:
os_resource['flavor_id'] = str(os_resource['flavor_id'][0])
os_resource['sec_group'] = os_actions.create_sec_group()
- os_resource['keypair'] = openstack_clients.compute.keypairs.create('spt-test-{}'.format(random.randrange(100, 999)))
+ os_resource['keypair'] = openstack_clients.compute.keypairs.create(
+ '{}-{}'.format(flavor_name, random.randrange(100, 999)))
os_resource['net1'] = os_actions.create_network_resources()
os_resource['ext_net'] = os_actions.get_external_network()
adm_tenant = os_actions.get_admin_tenant()
diff --git a/test_set/cvp-spt/global_config.yaml b/test_set/cvp-spt/global_config.yaml
index 9a8e738..d44ff8e 100644
--- a/test_set/cvp-spt/global_config.yaml
+++ b/test_set/cvp-spt/global_config.yaml
@@ -29,3 +29,9 @@
nova_timeout: 30
iperf_prep_string: "sudo /bin/bash -c 'echo \"91.189.88.161 archive.ubuntu.com\" >> /etc/hosts'"
IMAGE_SIZE_MB: 2000
+
+# parameters for vm2vm test
+flavor_name: 'spt-test'
+flavor_ram: 1536
+flavor_vcpus: 1
+flavor_disk: 5
\ No newline at end of file
diff --git a/test_set/cvp-spt/tests/test_glance.py b/test_set/cvp-spt/tests/test_glance.py
index 5514944..87d6e4a 100644
--- a/test_set/cvp-spt/tests/test_glance.py
+++ b/test_set/cvp-spt/tests/test_glance.py
@@ -24,11 +24,11 @@
create_file_cmdline = 'dd if=/dev/zero of=/tmp/image_mk_framework.dd bs=1M count={image_size}'.format(
image_size=image_size_megabytes)
- is_cmd_successful = subprocess.call(create_file_cmdline.split()) == 0
+ is_cmd_successful = subprocess.call(create_file_cmdline, shell=True) == 0
yield is_cmd_successful
# teardown
- subprocess.call('rm -f /tmp/image_mk_framework.dd'.split())
- subprocess.call('rm -f /tmp/image_mk_framework.download'.split())
+ subprocess.call('rm -f /tmp/image_mk_framework.dd', shell=True)
+ subprocess.call('rm -f /tmp/image_mk_framework.download', shell=True)
def test_speed_glance(create_image, openstack_clients, record_property):
diff --git a/test_set/cvp-spt/utils/__init__.py b/test_set/cvp-spt/utils/__init__.py
index 36cf239..a3bd6c2 100644
--- a/test_set/cvp-spt/utils/__init__.py
+++ b/test_set/cvp-spt/utils/__init__.py
@@ -98,7 +98,7 @@
global_config_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../global_config.yaml")
with open(global_config_file, 'r') as file:
- global_config = yaml.load(file)
+ global_config = yaml.load(file, Loader=yaml.SafeLoader)
for param in global_config.keys():
if param in os.environ.keys():
if ',' in os.environ[param]: