From fa0a614c8ea3e757440c82380707e0221079e32a Mon Sep 17 00:00:00 2001 From: Linda Wang Date: Mon, 4 Dec 2017 06:36:06 +0000 Subject: Fix the yamllint errors in functest/ci And also, remove the params "tempest_use_custom_images" and "unique_names" of vping, rally and tempest. Change-Id: Ic4243ef2f5e965910e5befa87db8d585cad34fa2 Signed-off-by: Linda Wang --- functest/ci/config_aarch64_patch.yaml | 62 ++++++++------- functest/ci/config_functest.yaml | 89 +++++++++++----------- functest/ci/config_patch.yaml | 9 ++- functest/opnfv_tests/openstack/rally/rally.py | 4 +- .../openstack/snaps/snaps_test_runner.py | 6 +- .../opnfv_tests/openstack/tempest/conf_utils.py | 10 +-- functest/opnfv_tests/openstack/tempest/tempest.py | 34 ++++----- functest/opnfv_tests/openstack/vping/vping_base.py | 6 +- .../unit/openstack/tempest/test_conf_utils.py | 25 ++---- tox.ini | 3 + 10 files changed, 119 insertions(+), 129 deletions(-) diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml index a7b77374a..a3f029a08 100644 --- a/functest/ci/config_aarch64_patch.yaml +++ b/functest/ci/config_aarch64_patch.yaml @@ -1,44 +1,48 @@ +--- os: general: openstack: image_name: TestVM - image_file_name: cirros-d161201-aarch64-disk.img - image_password: gocubsgo + image_file_name: cirros-d161201-aarch64-disk.img + image_password: gocubsgo extra_properties: - hw_firmware_type: 'uefi' - hw_video_model: 'vga' - short_id: 'ubuntu16.04' + hw_firmware_type: 'uefi' + hw_video_model: 'vga' + short_id: 'ubuntu16.04' snaps: images: - glance_tests: - disk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img - extra_properties: - hw_firmware_type: 'uefi' - short_id: 'ubuntu16.04' - hw_video_model: 'vga' - cirros: - disk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img - extra_properties: - hw_firmware_type: 'uefi' - short_id: 'ubuntu16.04' - hw_video_model: 'vga' - ubuntu: - disk_file: /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-arm64-uefi1.img - extra_properties: - hw_firmware_type: 'uefi' - hw_video_model: 'vga' - centos: - disk_file: /home/opnfv/functest/images/CentOS-7-aarch64-GenericCloud.qcow2 - extra_properties: - hw_firmware_type: 'uefi' - hw_video_model: 'vga' + glance_tests: + disk_file: / + home/opnfv/functest/images/cirros-d161201-aarch64-disk.img + extra_properties: + hw_firmware_type: 'uefi' + short_id: 'ubuntu16.04' + hw_video_model: 'vga' + cirros: + disk_file: + /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img + extra_properties: + hw_firmware_type: 'uefi' + short_id: 'ubuntu16.04' + hw_video_model: 'vga' + ubuntu: + disk_file: + /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-arm64-uefi1.img + extra_properties: + hw_firmware_type: 'uefi' + hw_video_model: 'vga' + centos: + disk_file: + /home/opnfv/functest/images/CentOS-7-aarch64-GenericCloud.qcow2 + extra_properties: + hw_firmware_type: 'uefi' + hw_video_model: 'vga' vping: image_name: TestVM tempest: - use_custom_images: True - use_custom_flavors: True + use_custom_flavors: 'True' odl_sfc: image_base_url: "http://artifacts.opnfv.org/sfc/demo" diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index e2746cf31..d636ec2e1 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -1,23 +1,24 @@ +--- general: dir: - home: /home/opnfv - repos: /home/opnfv/repos - dir_repo_rally: /home/opnfv/repos/rally - repo_tempest: /src/tempest - dir_repo_releng: /home/opnfv/repos/releng - repo_vims_test: /src/vims-test - repo_barometer: /home/opnfv/repos/barometer - repo_odl_test: /src/odl_test - repo_fds: /src/fds - repo_securityscan: /home/opnfv/repos/securityscanning - functest: /home/opnfv/functest - results: /home/opnfv/functest/results - functest_conf: /home/opnfv/functest/conf - functest_data: /home/opnfv/functest/data - ims_data: /home/opnfv/functest/data/ims/ - router_data: /home/opnfv/functest/data/router/ - functest_images: /home/opnfv/functest/images - rally_inst: /root/.rally + home: /home/opnfv + repos: /home/opnfv/repos + dir_repo_rally: /home/opnfv/repos/rally + repo_tempest: /src/tempest + dir_repo_releng: /home/opnfv/repos/releng + repo_vims_test: /src/vims-test + repo_barometer: /home/opnfv/repos/barometer + repo_odl_test: /src/odl_test + repo_fds: /src/fds + repo_securityscan: /home/opnfv/repos/securityscanning + functest: /home/opnfv/functest + results: /home/opnfv/functest/results + functest_conf: /home/opnfv/functest/conf + functest_data: /home/opnfv/functest/data + ims_data: /home/opnfv/functest/data/ims/ + router_data: /home/opnfv/functest/data/router/ + functest_images: /home/opnfv/functest/images + rally_inst: /root/.rally openstack: creds: /home/opnfv/functest/conf/openstack.creds @@ -25,12 +26,13 @@ general: image_name: Cirros-0.3.5 image_name_alt: Cirros-0.3.5-1 - image_file_name: cirros-0.3.5-x86_64-disk.img - image_url: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img + image_file_name: cirros-0.3.5-x86_64-disk.img + image_url: + http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img image_user: cirros - image_disk_format: qcow2 - image_username: cirros - image_password: cubswin:) + image_disk_format: qcow2 + image_username: cirros + image_password: cubswin:) flavor_name: opnfv_flavor flavor_name_alt: opnfv_flavor_1 @@ -48,19 +50,21 @@ general: neutron_router_name: functest-router snaps: - use_keystone: True - use_floating_ips: True + use_keystone: 'True' + use_floating_ips: 'True' images: - glance_tests: - disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img - cirros: - disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img - ubuntu: - disk_file: /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img - centos: - disk_file: /home/opnfv/functest/images/CentOS-7-x86_64-GenericCloud.qcow2 - # All of these values are optional and will override the values retrieved - # by the RC file + glance_tests: + disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img + cirros: + disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img + ubuntu: + disk_file: + /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img + centos: + disk_file: + /home/opnfv/functest/images/CentOS-7-x86_64-GenericCloud.qcow2 +# All of these values are optional and will override the values retrieved +# by the RC file # os_creds_override: # username: {user} # password: {password} @@ -80,8 +84,8 @@ snaps: # ssh_proxy_cmd: {OpenSSH -o ProxyCommand value} vping: - ping_timeout: 200 - vm_flavor: m1.tiny # adapt to your environment + ping_timeout: 200 + vm_flavor: m1.tiny # adapt to your environment vm_name_1: opnfv-vping-1 vm_name_2: opnfv-vping-2 image_name: functest-vping @@ -100,8 +104,7 @@ vping: vm_boot_timeout: 180 vm_delete_timeout: 100 vm_ssh_connect_timeout: 60 - cleanup_objects: True - unique_names: True + cleanup_objects: 'True' odl_sfc: image_base_url: "http://artifacts.opnfv.org/sfc/images" @@ -110,7 +113,6 @@ odl_sfc: image_format: qcow2 tempest: - unique_names: True verifier_name: opnfv-tempest identity: tenant_name: tempest @@ -125,12 +127,10 @@ tempest: private_subnet_name: tempest-subnet private_subnet_cidr: 192.168.150.0/24 router_name: tempest-router - use_custom_images: True - use_custom_flavors: False + use_custom_flavors: 'False' volume_device_name: vdc rally: - unique_names: True deployment_name: opnfv-rally network_name: rally-net subnet_name: rally-subnet @@ -192,7 +192,8 @@ example: sg_desc: Example Security group results: - # you can also set a file (e.g. /home/opnfv/functest/results/dump.txt) to dump results + # you can also set a file (e.g. /home/opnfv/functest/results/dump.txt) + # to dump results # test_db_url: file:///home/opnfv/functest/results/dump.txt test_db_url: http://testresults.opnfv.org/test/api/v1/results diff --git a/functest/ci/config_patch.yaml b/functest/ci/config_patch.yaml index 865a564e6..f54c2d7cb 100644 --- a/functest/ci/config_patch.yaml +++ b/functest/ci/config_patch.yaml @@ -1,9 +1,10 @@ +--- lxd: general: openstack: image_name: Cirros-0.3.5 - image_file_name: cirros-0.3.5-x86_64-lxc.tar.gz - image_disk_format: raw + image_file_name: cirros-0.3.5-x86_64-lxc.tar.gz + image_disk_format: raw healthcheck: disk_image: /home/opnfv/functest/data/cirros-0.3.5-x86_64-lxc.tar.gz @@ -13,10 +14,10 @@ fdio: flavor_extra_specs: {'hw:mem_page_size':'large'} image_properties: {'hw_mem_page_size':'large'} tempest: - use_custom_flavors: True + use_custom_flavors: 'True' ovs: general: flavor_extra_specs: {'hw:mem_page_size':'large'} image_properties: {'hw_mem_page_size':'large'} tempest: - use_custom_flavors: True + use_custom_flavors: 'True' diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 0c657688e..a808d0360 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -99,9 +99,7 @@ class RallyBase(testcase.TestCase): os_env_file=CONST.__getattribute__('openstack_creds'), overrides=creds_override) - self.guid = '' - if CONST.__getattribute__('rally_unique_names'): - self.guid = '-' + str(uuid.uuid4()) + self.guid = '-' + str(uuid.uuid4()) self.creators = [] self.mode = '' diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py index bfdcd8626..023f1bbd0 100644 --- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py +++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py @@ -41,8 +41,10 @@ class SnapsTestRunner(unit.Suite): else: self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds) - self.use_fip = CONST.__getattribute__('snaps_use_floating_ips') - self.use_keystone = CONST.__getattribute__('snaps_use_keystone') + self.use_fip = ( + CONST.__getattribute__('snaps_use_floating_ips') == 'True') + self.use_keystone = ( + CONST.__getattribute__('snaps_use_keystone') == 'True') scenario = CONST.__getattribute__('DEPLOY_SCENARIO') self.flavor_metadata = None diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index b4026def3..fff99a320 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -257,11 +257,11 @@ def configure_tempest_update_params(tempest_conf_file, image_id=None, CONST.__getattribute__('tempest_private_net_name')) config.set('compute', 'volume_device_name', CONST.__getattribute__('tempest_volume_device_name')) - if CONST.__getattribute__('tempest_use_custom_images'): - if image_id is not None: - config.set('compute', 'image_ref', image_id) - if IMAGE_ID_ALT is not None: - config.set('compute', 'image_ref_alt', IMAGE_ID_ALT) + + if image_id is not None: + config.set('compute', 'image_ref', image_id) + if IMAGE_ID_ALT is not None: + config.set('compute', 'image_ref_alt', IMAGE_ID_ALT) if CONST.__getattribute__('tempest_use_custom_flavors'): if flavor_id is not None: config.set('compute', 'flavor_ref', flavor_id) diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py index bede02fbb..979e992f2 100644 --- a/functest/opnfv_tests/openstack/tempest/tempest.py +++ b/functest/opnfv_tests/openstack/tempest/tempest.py @@ -318,9 +318,7 @@ class TempestResourcesManager(object): self.os_creds = openstack_tests.get_credentials( os_env_file=CONST.__getattribute__('openstack_creds')) - self.guid = '' - if CONST.__getattribute__('tempest_unique_names'): - self.guid = '-' + str(uuid.uuid4()) + self.guid = '-' + str(uuid.uuid4()) self.creators = list() @@ -384,21 +382,19 @@ class TempestResourcesManager(object): flavor_id = None flavor_id_alt = None - if (CONST.__getattribute__('tempest_use_custom_images') or - use_custom_images): - logger.debug("Creating image for Tempest suite") - image_base_name = CONST.__getattribute__( - 'openstack_image_name') + self.guid - os_image_settings = openstack_tests.cirros_image_settings( - image_base_name, public=True, - image_metadata=self.cirros_image_config) - logger.debug("Creating image for Tempest suite") - image_creator = deploy_utils.create_image( - self.os_creds, os_image_settings) - if image_creator is None: - raise Exception('Failed to create image') - self.creators.append(image_creator) - image_id = image_creator.get_image().id + logger.debug("Creating image for Tempest suite") + image_base_name = CONST.__getattribute__( + 'openstack_image_name') + self.guid + os_image_settings = openstack_tests.cirros_image_settings( + image_base_name, public=True, + image_metadata=self.cirros_image_config) + logger.debug("Creating image for Tempest suite") + image_creator = deploy_utils.create_image( + self.os_creds, os_image_settings) + if image_creator is None: + raise Exception('Failed to create image') + self.creators.append(image_creator) + image_id = image_creator.get_image().id if use_custom_images: logger.debug("Creating 2nd image for Tempest suite") @@ -415,7 +411,7 @@ class TempestResourcesManager(object): self.creators.append(image_creator_alt) image_id_alt = image_creator_alt.get_image().id - if (CONST.__getattribute__('tempest_use_custom_flavors') or + if (CONST.__getattribute__('tempest_use_custom_flavors') == 'True' or use_custom_flavors): logger.info("Creating flavor for Tempest suite") scenario = CONST.__getattribute__('DEPLOY_SCENARIO') diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py index 318e9c45f..f3d4d50f5 100644 --- a/functest/opnfv_tests/openstack/vping/vping_base.py +++ b/functest/opnfv_tests/openstack/vping/vping_base.py @@ -60,9 +60,7 @@ class VPingBase(testcase.TestCase): self.router_creator = None # Shared metadata - self.guid = '' - if CONST.__getattribute__('vping_unique_names'): - self.guid = '-' + str(uuid.uuid4()) + self.guid = '-' + str(uuid.uuid4()) self.router_name = CONST.__getattribute__( 'vping_router_name') + self.guid @@ -197,7 +195,7 @@ class VPingBase(testcase.TestCase): Cleanup all OpenStack objects. Should be called on completion :return: """ - if CONST.__getattribute__('vping_cleanup_objects'): + if CONST.__getattribute__('vping_cleanup_objects') == 'True': for creator in reversed(self.creators): try: creator.clean() diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 6edbbf5d6..7eeffdd67 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -48,18 +48,11 @@ class OSTempestConfUtilsTesting(unittest.TestCase): def test_create_tempest_resources_missing_image(self, *mock_args): tempest_resources = tempest.TempestResourcesManager(os_creds={}) - CONST.__setattr__('tempest_use_custom_imagess', True) with self.assertRaises(Exception) as context: tempest_resources.create() msg = 'Failed to create image' self.assertTrue(msg in context.exception, msg=str(context.exception)) - CONST.__setattr__('tempest_use_custom_imagess', False) - with self.assertRaises(Exception) as context: - tempest_resources.create(use_custom_images=True) - msg = 'Failed to create image' - self.assertTrue(msg in context.exception, msg=str(context.exception)) - @mock.patch('snaps.openstack.utils.deploy_utils.create_project', return_value=mock.Mock()) @mock.patch('snaps.openstack.utils.deploy_utils.create_user', @@ -74,15 +67,13 @@ class OSTempestConfUtilsTesting(unittest.TestCase): tempest_resources = tempest.TempestResourcesManager( os_creds=self.os_creds) - CONST.__setattr__('tempest_use_custom_images', True) - CONST.__setattr__('tempest_use_custom_flavors', True) + CONST.__setattr__('tempest_use_custom_flavors', 'True') with self.assertRaises(Exception) as context: tempest_resources.create() msg = 'Failed to create flavor' self.assertTrue(msg in context.exception, msg=str(context.exception)) - CONST.__setattr__('tempest_use_custom_images', True) - CONST.__setattr__('tempest_use_custom_flavors', False) + CONST.__setattr__('tempest_use_custom_flavors', 'False') with self.assertRaises(Exception) as context: tempest_resources.create(use_custom_flavors=True) msg = 'Failed to create flavor' @@ -290,34 +281,30 @@ class OSTempestConfUtilsTesting(unittest.TestCase): mock.patch('functest.utils.functest_utils.yaml.safe_load', return_value={'validation': {'ssh_timeout': 300}}): CONST.__setattr__('OS_ENDPOINT_TYPE', None) - conf_utils.\ - configure_tempest_update_params('test_conf_file', - image_id=image_id, - flavor_id=flavor_id) + conf_utils.configure_tempest_update_params( + 'test_conf_file', image_id=image_id, flavor_id=flavor_id) mset.assert_any_call(params[0], params[1], params[2]) self.assertTrue(mread.called) self.assertTrue(mwrite.called) def test_configure_tempest_update_params_missing_image_id(self): - CONST.__setattr__('tempest_use_custom_images', True) self._test_missing_param(('compute', 'image_ref', 'test_image_id'), 'test_image_id', None) def test_configure_tempest_update_params_missing_image_id_alt(self): - CONST.__setattr__('tempest_use_custom_images', True) conf_utils.IMAGE_ID_ALT = 'test_image_id_alt' self._test_missing_param(('compute', 'image_ref_alt', 'test_image_id_alt'), None, None) def test_configure_tempest_update_params_missing_flavor_id(self): - CONST.__setattr__('tempest_use_custom_flavors', True) + CONST.__setattr__('tempest_use_custom_flavors', 'True') self._test_missing_param(('compute', 'flavor_ref', 'test_flavor_id'), None, 'test_flavor_id') def test_configure_tempest_update_params_missing_flavor_id_alt(self): - CONST.__setattr__('tempest_use_custom_flavors', True) + CONST.__setattr__('tempest_use_custom_flavors', 'True') conf_utils.FLAVOR_ID_ALT = 'test_flavor_id_alt' self._test_missing_param(('compute', 'flavor_ref_alt', 'test_flavor_id_alt'), None, diff --git a/tox.ini b/tox.ini index 7299a1d33..9746954e1 100644 --- a/tox.ini +++ b/tox.ini @@ -51,6 +51,9 @@ files = docker/parser/testcases.yaml docker/features/testcases.yaml docker/vnf/testcases.yaml + functest/ci/config_aarch64_patch.yaml + functest/ci/config_functest.yaml + functest/ci/config_patch.yaml functest/ci/testcases.yaml commands = yamllint {[testenv:yamllint]files} -- cgit 1.2.3-korg