diff --git a/.gitreview b/.gitreview index 4a559fa..8053605 100644 --- a/.gitreview +++ b/.gitreview @@ -2,4 +2,4 @@ host=review.opendev.org port=29418 project=starlingx/test.git -defaultbranch=r/stx.4.0 +defaultbranch=devel diff --git a/automated-pytest-suite/testcases/functional/nova/conftest.py b/automated-pytest-suite/testcases/functional/nova/conftest.py index 157d7f8..56a3ed9 100755 --- a/automated-pytest-suite/testcases/functional/nova/conftest.py +++ b/automated-pytest-suite/testcases/functional/nova/conftest.py @@ -1,3 +1,27 @@ +from pytest import fixture, skip + from testfixtures.resource_mgmt import * -from testfixtures.resource_create import * -from testfixtures.config_host import * +from keywords import system_helper, network_helper +from utils.tis_log import LOG + +NETWORK_NAME = "network" +SUBNET_NAME = "subnet" +SUBNET_RANGE = "192.168.0.0/24" +IP_VERSION = 4 + + +@fixture(scope='session') +def no_aio_system(): + LOG.fixture_step("(Session) Skip if AIO system") + if system_helper.is_aio_system(): + skip('skip if AIO system') + + +# Creating network +@fixture(scope="session") +def create_network(): + net_id = network_helper.create_network(name=NETWORK_NAME, cleanup="session")[1] + subnet_id = network_helper.create_subnet(name=SUBNET_NAME, network=NETWORK_NAME, + subnet_range=SUBNET_RANGE, dhcp=True, + ip_version=IP_VERSION, cleanup="session")[1] + return net_id, subnet_id diff --git a/automated-pytest-suite/testcases/functional/nova/test_boot_from_glance.py b/automated-pytest-suite/testcases/functional/nova/test_boot_from_glance.py new file mode 100644 index 0000000..3544f11 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_boot_from_glance.py @@ -0,0 +1,86 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Boot from glance (image bakcing), volume attach and try to lock hosts. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.auth import Tenant +from consts.stx import GuestImages, VMStatus +from keywords import nova_helper, vm_helper, glance_helper +from utils import cli +from utils.clients import ssh + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "flavor.small", + "flavor_vcpus": 1, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2", +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "dedicated"}) + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + return vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + + +@mark.nova +def test_boot_from_glance(launch_instance, no_aio_system): + """ + 277-Boot-From-Glance.robot + Args: + launch_instance: + no_aio_system: + + Returns: + + """ + con_ssh = ssh.ControllerClient.get_active_controller() + before_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + cli.openstack('server migrate --shared-migration ', launch_instance, ssh_client=con_ssh, fail_ok=False, + auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.VERIFY_RESIZE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + cli.openstack('server resize ', "{} --confirm".format(launch_instance), ssh_client=con_ssh, + fail_ok=False, auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.ACTIVE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + after_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + assert before_host != after_host, "server migrate failed" diff --git a/automated-pytest-suite/testcases/functional/nova/test_check_nova_diagnostics.py b/automated-pytest-suite/testcases/functional/nova/test_check_nova_diagnostics.py new file mode 100644 index 0000000..47495d5 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_check_nova_diagnostics.py @@ -0,0 +1,94 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to create an instance and perform actions on it,that will be logged in nova diagnostics. +# Then, instance is locked to confirm the previous output does not change. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.auth import Tenant +from consts.stx import GuestImages, VMStatus +from keywords import nova_helper, vm_helper, glance_helper +from utils import cli +from utils.clients import ssh + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "diagnostics-flavor", + "flavor_vcpus": 1, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "diagnostics-image", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + return vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + + +@mark.nova +def test_check_nova_diagnostics(no_simplex, launch_instance): + """ + 90-Check-Nova-Diagnostics.robot + Args: + no_simplex: + launch_instance: + + Returns: + + """ + disk = nova_helper.get_flavors(name="diagnostics-flavor", field="disk")[0] + vcpus = nova_helper.get_flavors(name="diagnostics-flavor", field="vcpus")[0] + con_ssh = ssh.ControllerClient.get_active_controller() + before_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + cli.openstack('server migrate ', launch_instance, ssh_client=con_ssh, fail_ok=False, + auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.VERIFY_RESIZE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + cli.openstack('server resize ', "{} --confirm".format(launch_instance), ssh_client=con_ssh, + fail_ok=False, auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.ACTIVE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + after_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + assert before_host != after_host, "server migrate failed" + cli.openstack(cmd='server lock', positional_args=launch_instance) + disk_1 = nova_helper.get_flavors(name="diagnostics-flavor", field="disk")[0] + vcpus_1 = nova_helper.get_flavors(name="diagnostics-flavor", field="vcpus")[0] + assert disk_1 == disk + assert vcpus_1 == vcpus + cli.openstack(cmd='server unlock', positional_args=launch_instance) diff --git a/automated-pytest-suite/testcases/functional/nova/test_cli_set_cpu_policy_extra_spec.py b/automated-pytest-suite/testcases/functional/nova/test_cli_set_cpu_policy_extra_spec.py new file mode 100644 index 0000000..50c4054 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_cli_set_cpu_policy_extra_spec.py @@ -0,0 +1,67 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to check cpu policy changes correctly. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import mark + +from consts.stx import GuestImages +from keywords import nova_helper, glance_helper, vm_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "flavor.small", + "flavor_name_1": "flavor.small1", + "flavor_vcpus": 2, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +@mark.nova +def test_cli_set_cpu_policy_extra_spec(create_network): + """ + 77-CLI-Set-CPU-Policy-Extra-Spec.robot + Args: + create_network: + + Returns: + + """ + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + fl_id_1 = nova_helper.create_flavor(name=cirros_params['flavor_name_1'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "dedicated"}) + nova_helper.set_flavor(fl_id_1, **{"hw:cpu_policy": "dedicated"}) + net_id_list = [{"net-id": create_network[0]}] + vm_helper.boot_vm(flavor=fl_id, nics=net_id_list, + source="image", source_id=im_id, + cleanup="module") + vm_helper.boot_vm(flavor=fl_id_1, nics=net_id_list, + source="image", source_id=im_id, + cleanup="module") diff --git a/automated-pytest-suite/testcases/functional/nova/test_cpu_policy_from_cli_horizon_cpu_policy_extra_spec.py b/automated-pytest-suite/testcases/functional/nova/test_cpu_policy_from_cli_horizon_cpu_policy_extra_spec.py new file mode 100644 index 0000000..483c7ec --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_cpu_policy_from_cli_horizon_cpu_policy_extra_spec.py @@ -0,0 +1,52 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# From both Horizon and cli. verify setting CPU Policy in the extra spec to a valid value. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark +from selenium.webdriver.support.select import Select + +from testfixtures.horizon import * +from keywords import nova_helper +from utils import exceptions +from utils.horizon.pages.admin.compute import flavorspage +from utils.tis_log import LOG + + +@mark.nova +def test_cpu_policy_from_cli_horizon_cpu_policy_extra_spec(admin_home_pg_container): + """ + 134-CPUPolicy-From-CLI-Horizon-CPU-Policy-Extra-Spec.robot + Args: + admin_home_pg_container: + + Returns: + + """ + flavor_id = nova_helper.create_flavor(name="flavor_134", vcpus=1, ram=2048, + root_disk=20, is_public=True, + add_default_specs=False, cleanup="function")[1] + nova_helper.set_flavor(flavor_id, **{"hw:cpu_policy": "dedicated"}) + LOG.info(nova_helper.get_flavor_properties("flavor_134")) + LOG.fixture_step('Go to Admin > Compute > Flavors') + flavors_pg = flavorspage.FlavorsPage( + admin_home_pg_container.driver, port=admin_home_pg_container.port) + flavors_pg.go_to_target_page() + row = flavors_pg._get_row_by_flavor_name("flavor_134") + update_metadata_form = flavors_pg.flavors_table.update_metadata(row) + element = update_metadata_form.driver.find_element_by_name("property") + LOG.info("Set the extra spec for cpu policy by Horizon") + Select(element).select_by_value("string:shared") + update_metadata_form.submit() + for k, v in nova_helper.get_flavor_properties("flavor_134").items(): + if k == 'hw:cpu_policy': + assert v == 'shared' + break + exceptions.NoMatchFoundError("Flavor property set failed") diff --git a/automated-pytest-suite/testcases/functional/nova/test_cpu_scaling_verify_error_attempt_set_minimum_cpu_value_below_valid_range.py b/automated-pytest-suite/testcases/functional/nova/test_cpu_scaling_verify_error_attempt_set_minimum_cpu_value_below_valid_range.py new file mode 100644 index 0000000..e4a74c2 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_cpu_scaling_verify_error_attempt_set_minimum_cpu_value_below_valid_range.py @@ -0,0 +1,34 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to verify error when attempting to create a flavor with CPU value below minimum valid range. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from consts.auth import Tenant +from keywords import nova_helper +from utils import cli +from utils.clients.ssh import ControllerClient + + +@mark.nova +def test_cpu_scaling_verify_error_attempt_set_minimum_cpu_value_below_valid_range(): + """ + 131-CPUScaling-Verify-Error-Attempt-Set-Minimum-CPU-Value-Below-Valid-Range.robot + Returns: + + """ + con_ssh = ControllerClient.get_active_controller() + nova_helper.create_flavor(name="flavor", vcpus=1, ram=1024, root_disk=4, is_public=True, + add_default_specs=False, cleanup="module") + args = "--ram 2048 --disk 4 --vcpus -1 --public --id auto flavor" + exit_code, output = cli.openstack('flavor create ', args, ssh_client=con_ssh, + fail_ok=True, auth_info=Tenant.get('admin')) + assert "is less than the minimum of" in output diff --git a/automated-pytest-suite/testcases/functional/nova/test_evacuate_migrate_vm.py b/automated-pytest-suite/testcases/functional/nova/test_evacuate_migrate_vm.py new file mode 100644 index 0000000..394d157 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_evacuate_migrate_vm.py @@ -0,0 +1,88 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Migrates an instance and checks for migration success. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.auth import Tenant +from consts.stx import GuestImages, VMStatus +from keywords import nova_helper, glance_helper, vm_helper +from utils import cli +from utils.clients import ssh +from utils.tis_log import LOG + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "flavor.small", + "flavor_vcpus": 2, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + vm_id = vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + return vm_id + + +@mark.nova +def test_evacuate_migrate_vm(no_aio_system, launch_instance): + """ + 73-Evacuate-Migrate-VM + Args: + no_aio_system: + launch_instance: + + Returns: + + """ + con_ssh = ssh.ControllerClient.get_active_controller() + before_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + cli.openstack('server migrate ', launch_instance, ssh_client=con_ssh, fail_ok=False, + auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.VERIFY_RESIZE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + cli.openstack('server resize ', "{} --confirm".format(launch_instance), ssh_client=con_ssh, + fail_ok=False, auth_info=Tenant.get('admin'), timeout=600) + vm_helper.wait_for_vm_status(vm_id=launch_instance, status=VMStatus.ACTIVE, timeout=300, + fail_ok=False, con_ssh=con_ssh) + after_host = vm_helper.get_vm_host(launch_instance, con_ssh=con_ssh) + LOG.info("before and after host is {} {}".format(before_host, after_host)) + assert before_host != after_host, "server migrate failed" diff --git a/automated-pytest-suite/testcases/functional/nova/test_flavor_adding_access_to_the_flavor.py b/automated-pytest-suite/testcases/functional/nova/test_flavor_adding_access_to_the_flavor.py new file mode 100644 index 0000000..948d7ec --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_flavor_adding_access_to_the_flavor.py @@ -0,0 +1,33 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# This test add access to the flavor. +# Test To Create Flavor And Remove Access. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from keywords import nova_helper +from keywords import keystone_helper + + +@mark.nova +def test_flavor_adding_access_to_the_flavor(): + """ + 33-Flavor-Adding-Access-To-The-Flavor.robot + 54-Create-Flavor-Remove-Access.robot + Returns: + + """ + flavor_id = nova_helper.create_flavor(name='flavor_name', add_default_specs=False, + root_disk=10, is_public=False, cleanup="module")[1] + project_id = keystone_helper.get_projects(**{"Name": "admin"})[0] + nova_helper.set_flavor(flavor_id, project=project_id) + flavor = nova_helper.get_flavor_values(flavor_id, "access_project_ids") + assert flavor[0] == project_id, "flavor create failed" diff --git a/automated-pytest-suite/testcases/functional/nova/test_flavor_use_cannot_be_modified.py b/automated-pytest-suite/testcases/functional/nova/test_flavor_use_cannot_be_modified.py new file mode 100644 index 0000000..a519d9f --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_flavor_use_cannot_be_modified.py @@ -0,0 +1,78 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Flavor - Flavor in use can not be modified (or deleted) +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.stx import GuestImages +from keywords import nova_helper, vm_helper, glance_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "vm-0-flavor", + "flavor_vcpus": 1, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "vm-0-image", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, source="image", + source_id=create_flavor_and_image["image"], cleanup="module") + + +@mark.nova +def test_flavor_use_cannot_be_modified(launch_instance, create_flavor_and_image): + """ + 66-Flavor-Use-Cannot-Be-Modified.robot + refer bug: https://bugs.launchpad.net/starlingx/+bug/1832371 + Args: + launch_instance: + create_flavor_and_image: + + Returns: + + """ + flavor_id = create_flavor_and_image["flavor"] + exit_code = nova_helper.set_flavor(flavor_id, fail_ok=True, + **{"quota:disk_write_bytes_sec": "10485760"})[0] + assert exit_code == 1, "The mpdification of a flavor should " \ + "be rejected if in use by the instance" + exit_code = nova_helper.delete_flavors(flavor_id, fail_ok=True)[0] + assert exit_code == 1, "The deletion of a flavor should " \ + "be rejected if in use by the instance" diff --git a/automated-pytest-suite/testcases/functional/nova/test_flavor_with_extra_migration_spec.py b/automated-pytest-suite/testcases/functional/nova/test_flavor_with_extra_migration_spec.py new file mode 100644 index 0000000..e846b2a --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_flavor_with_extra_migration_spec.py @@ -0,0 +1,32 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# MigrationTime - Create Flavor extra spec live migration max +# downtime within valid range for live migration max downtime. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from keywords import nova_helper + + +@mark.nova +def test_flavor_with_extra_migration_spec(): + """ + 108-Flavor-With-Extra-Migration-Spec.robot + Returns: + + """ + fl_id = nova_helper.create_flavor(name="flavor.small", vcpus=2, ram=2048, root_disk=4, + is_public=True, add_default_specs=False, cleanup="module")[1] + nova_helper.set_flavor(fl_id, **{"hw:wrs:live_m_timeout": "120"}) + nova_helper.set_flavor(fl_id, **{"hw:wrs:live_migration_max_downtime": "501"}) + result = nova_helper.get_flavor_values(fields="properties", flavor="flavor.small") + assert '120' in result[0]["hw:wrs:live_m_timeout"] and '501' \ + in result[0]["hw:wrs:live_migration_max_downtime"] diff --git a/automated-pytest-suite/testcases/functional/nova/test_local_storage_delete_volume_snapshot_instance_launched.py b/automated-pytest-suite/testcases/functional/nova/test_local_storage_delete_volume_snapshot_instance_launched.py new file mode 100644 index 0000000..3257316 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_local_storage_delete_volume_snapshot_instance_launched.py @@ -0,0 +1,99 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to validate that volume and snapshot from where an instance has been lunched, can be deleted. +# Launches an instance from a volume snapshot with Local_CoW Image Backed storage. +# Test to check that a snapshot of a volume is created. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.stx import GuestImages +from keywords import vm_helper, glance_helper, nova_helper, cinder_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "x1.tiny", + "flavor_vcpus": 1, + "flavor_ram": 512, + "flavor_disk": 10, + "volume_size": 20, + "volume_name": "cirror_vol", + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2", + "snapshot_name": "cirros-snapshot" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Volume For Instances +@fixture(scope="module") +def create_volume(create_flavor_and_image): + return cinder_helper.create_volume(name=cirros_params['volume_name'], source_type='image', + source_id=create_flavor_and_image["image"], + size=cirros_params['volume_size'], cleanup="module")[1] + + +@fixture(scope="module") +def snapshot_from_instance(create_flavor_and_image, create_volume): + return cinder_helper.create_volume_snapshot(name=cirros_params['snapshot_name'], + volume=create_volume, cleanup="module")[1] + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image, snapshot_from_instance): + net_id_list = [{"net-id": create_network[0]}] + vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="snapshot", source_id=snapshot_from_instance, + cleanup="module") + + +@mark.nova +def test_local_storage_delete_volume_snapshot_instance_launched(launch_instance, + create_flavor_and_image, + create_volume, + snapshot_from_instance): + """ + 67-Local-Storage-Delete-VolumeSnapshot-Instance-Launched.robot + 118-Volume-Snapshot-Instance.robot + 121-Check-Snapshot-Volume.robot + Args: + launch_instance: + create_flavor_and_image: + create_volume: + snapshot_from_instance: + + Returns: + + """ + assert create_flavor_and_image["image"] + assert create_volume + assert snapshot_from_instance diff --git a/automated-pytest-suite/testcases/functional/nova/test_nova_error_instance_delete.py b/automated-pytest-suite/testcases/functional/nova/test_nova_error_instance_delete.py new file mode 100644 index 0000000..e17d07b --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_nova_error_instance_delete.py @@ -0,0 +1,59 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Creates instance that launches in error, catches error, and deletes instance with error. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import mark + +from consts.stx import GuestImages +from keywords import nova_helper, vm_helper, glance_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "vm-flavor", + "flavor_vcpus": 1, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "vm-image", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +@mark.nova +def test_nova_error_instance_delete(no_aio_system, create_network): + """ + 76-Nova-Error-Instance-Delete.robot + Args: + no_aio_system: + create_network: + + Returns: + + """ + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + net_id_list = [{"net-id": create_network[0]}] + nova_helper.set_flavor(fl_id, **{"hw:cpu_model": "Skylake-Server"}) + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "dedicated"}) + vm_id = vm_helper.boot_vm(flavor=fl_id, nics=net_id_list, source="image", + source_id=im_id)[1] + vm_helper.set_vm_state(vm_id) + vm_helper.delete_vms(vm_id) diff --git a/automated-pytest-suite/testcases/functional/nova/test_recovery_heartbeat_to_valid_values.py b/automated-pytest-suite/testcases/functional/nova/test_recovery_heartbeat_to_valid_values.py new file mode 100644 index 0000000..951cdee --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_recovery_heartbeat_to_valid_values.py @@ -0,0 +1,30 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# RecoveryHeartBeat - Using cli set flavor extra sw:wrs:guest:heartbeat to valid values. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from keywords import nova_helper + + +@mark.nova +def test_recovery_heartbeat_to_valid_values(): + """ + 150-Recovery-HeartBeat-To-Valid-Values.robot + Returns: + + """ + fl_id = nova_helper.create_flavor(name='flavor', ram=2048, vcpus=2, root_disk=4, is_public=True, + add_default_specs=False, cleanup="module")[1] + nova_helper.set_flavor(fl_id, **{"sw:wrs:guest:heartbeat": "TRUE"}) + nova_helper.set_flavor(fl_id, **{"sw:wrs:guest:heartbeat": "False"}) + nova_helper.set_flavor(fl_id, **{"sw:wrs:guest:heartbeat": "true"}) + nova_helper.set_flavor(fl_id, **{"sw:wrs:guest:heartbeat": "FALSE"}) diff --git a/automated-pytest-suite/testcases/functional/nova/test_sharedcpu.py b/automated-pytest-suite/testcases/functional/nova/test_sharedcpu.py new file mode 100644 index 0000000..4cf4291 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_sharedcpu.py @@ -0,0 +1,96 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# SharedCPU - Instance with hw:wrs:shared_vcpu respected on resize. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.stx import GuestImages +from keywords import nova_helper, glance_helper, host_helper, system_helper, vm_helper +from utils import table_parser, cli + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "flavor.small", + "flavor_name_1": "flavor.small_1", + "flavor_vcpus": 2, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + fl_id_1 = nova_helper.create_flavor(name=cirros_params['flavor_name_1'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "flavor_1": fl_id_1, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + vm_id = vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + return vm_id + + +@mark.nova +def test_sharedcpu(no_aio_system, create_flavor_and_image, launch_instance): + """ + 72-SharedCPU.robot + Args: + no_aio_system: + create_flavor_and_image: + launch_instance: + + Returns: + + """ + computes = system_helper.get_computes() + table_ = table_parser.table(cli.system('host-cpu-list', computes[0])[1]) + functions = table_parser.get_values(table_=table_, + target_header='assigned_function') + if "Shared" not in functions: + host_helper.lock_host(computes[0]) + host_helper.modify_host_cpu(computes[0], "shared", **{"p0": "1"}) + host_helper.unlock_host(computes[0]) + nova_helper.set_flavor(create_flavor_and_image["flavor_1"], **{"hw:cpu_policy": "dedicated"}) + nova_helper.set_flavor(create_flavor_and_image["flavor_1"], **{"hw:wrs:shared_vcpu": "1"}) + vm_helper.resize_vm(launch_instance, create_flavor_and_image["flavor_1"]) + cli.system('cpuprofile-add profile-test ', computes[1]) + host_helper.lock_host(computes[0]) + host_helper.apply_host_cpu_profile(computes[0], "profile-test") + host_helper.unlock_host(computes[0]) diff --git a/automated-pytest-suite/testcases/functional/nova/test_sharedcpu_flavor_dedicated_shared_vcpu.py b/automated-pytest-suite/testcases/functional/nova/test_sharedcpu_flavor_dedicated_shared_vcpu.py new file mode 100644 index 0000000..2d530c6 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_sharedcpu_flavor_dedicated_shared_vcpu.py @@ -0,0 +1,28 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to create a flavor and modify metadata. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from keywords import nova_helper + + +@mark.nova +def test_sharedcpu_flavor_dedicated_shared_vcpu(): + """ + 82-SharedCPU-Flavor-Dedicated-Shared-VCPU.robot + Returns: + + """ + fl_id = nova_helper.create_flavor(name='m3.tiny', ram=512, vcpus=2, root_disk=4, is_public=True, + add_default_specs=False, cleanup="module")[1] + nova_helper.set_flavor(fl_id, **{"hw:wrs:share_vcpu": "1"}) + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "dedicated"}) diff --git a/automated-pytest-suite/testcases/functional/nova/test_snapshot_show_and_delete_image.py b/automated-pytest-suite/testcases/functional/nova/test_snapshot_show_and_delete_image.py new file mode 100644 index 0000000..08e171a --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_snapshot_show_and_delete_image.py @@ -0,0 +1,71 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# ImageSnapshot - snapshot a running server, show snapshot and delete image. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.stx import GuestImages +from keywords import nova_helper, vm_helper, glance_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "diagnostics-flavor", + "flavor_vcpus": 1, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "diagnostics-image", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + return vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + + +@mark.nova +def test_snapshot_show_and_delete_image(launch_instance): + """ + 89-Snapshot-Show-And-Delete-Image.robot + Args: + launch_instance: + + Returns: + + """ + img_id = glance_helper.create_image(name="launch_instance", cleanup="module")[1] + glance_helper.delete_images(img_id) diff --git a/automated-pytest-suite/testcases/functional/nova/test_update_aggregate_add_host.py b/automated-pytest-suite/testcases/functional/nova/test_update_aggregate_add_host.py new file mode 100644 index 0000000..75145b4 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_update_aggregate_add_host.py @@ -0,0 +1,42 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test To Update Aggregate And Add Host. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from consts.auth import Tenant +from keywords import nova_helper, system_helper +from utils import cli +from utils.clients.ssh import ControllerClient + + +@mark.nova +def test_update_aggregate_add_host(no_aio_system): + """ + 68-Update-Aggregate-Add-Host.robot + Args: + no_aio_system: + + Returns: + + """ + host = system_helper.get_computes()[0] + con_ssh = ControllerClient.get_active_controller() + nova_helper.create_aggregate(name="local_storage_image_hosts") + nova_helper.set_aggregate("local_storage_image_hosts", zone="nova") + code, output = cli.openstack("aggregate add host", "local_storage_image_hosts {}".format(host), + ssh_client=con_ssh, fail_ok=False, auth_info=Tenant.get('admin')) + assert code == 0, output + code, output = cli.openstack("aggregate remove host", "local_storage_image_hosts {}" + .format(host), ssh_client=con_ssh, fail_ok=False, + auth_info=Tenant.get('admin')) + assert code == 0, output + nova_helper.delete_aggregates("local_storage_image_hosts") diff --git a/automated-pytest-suite/testcases/functional/nova/test_update_metadata_volume_snapshot.py b/automated-pytest-suite/testcases/functional/nova/test_update_metadata_volume_snapshot.py new file mode 100644 index 0000000..f5a3a44 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_update_metadata_volume_snapshot.py @@ -0,0 +1,35 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Local Storage - Update metadata in volume and snapshot. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark + +from consts.auth import Tenant +from keywords import cinder_helper +from utils import cli +from utils.clients.ssh import ControllerClient + + +@mark.nova +def test_update_metadata_volume_snapshot(): + """ + 173-Update-Metadata-Volume-Snapshot.robot + Returns: + + """ + con_ssh = ControllerClient.get_active_controller() + vol_id = cinder_helper.create_volume(name="cirror_vol_test", size=1, cleanup="module")[1] + cli.openstack('volume set ', '--property {} {}'.format("hw_cpu_maxcores='7'", vol_id), + ssh_client=con_ssh, auth_info=Tenant.get('admin')) + snapshot = cinder_helper.create_volume_snapshot("cirror_vol_test")[1] + cli.openstack('volume snapshot set ', '--property {} {}'.format("hw_cpu_maxcores='7'", snapshot), + ssh_client=con_ssh, auth_info=Tenant.get('admin')) + cinder_helper.delete_volume_snapshots(snapshot) diff --git a/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_cpu_policy.py b/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_cpu_policy.py new file mode 100644 index 0000000..dcbff11 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_cpu_policy.py @@ -0,0 +1,51 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to Verify CPU Policy Options in GUI. +# CPUPolicy - Test case sensitive entries for the value of the hw:cpu_policy. +# Validate Partition Modify operations. +# +# Author(s): Yong.Fu +# +### + +from pytest import mark +from selenium.webdriver.support.select import Select + +from keywords import nova_helper +from testfixtures.horizon import * +from utils.horizon.pages.admin.compute import flavorspage +from utils.tis_log import LOG + + +@mark.nova +def test_verify_values_for_cpu_policy(admin_home_pg_container): + """ + 80-Verify-Values-For-Cpu-Policy.robot + 103-Sensitive-Entries-For-Hwcpu.robot + 137-CPUPolicy-Invalid-Or-Empty-Values.robot + Returns: + + """ + fl_id = nova_helper.create_flavor(name='nova_new', ram=2048, root_disk=10, is_public=True, + add_default_specs=False, cleanup="module")[1] + LOG.fixture_step('Go to Admin > Compute > Flavors') + flavors_pg = flavorspage.FlavorsPage( + admin_home_pg_container.driver, port=admin_home_pg_container.port) + flavors_pg.go_to_target_page() + row = flavors_pg._get_row_by_flavor_name("nova_new") + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "shared"}) + update_metadata_form = flavors_pg.flavors_table.update_metadata(row) + element = update_metadata_form.driver.find_element_by_name("property") + assert Select(element).first_selected_option.text == "shared" + update_metadata_form.cancel() + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "dedicated"}) + update_metadata_form_1 = flavors_pg.flavors_table.update_metadata(row) + element_1 = update_metadata_form_1.driver.find_element_by_name("property") + assert Select(element_1).first_selected_option.text == "dedicated" + update_metadata_form_1.cancel() + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": "bogus"}) + nova_helper.set_flavor(fl_id, **{"hw:cpu_policy": ""}) diff --git a/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_mem_page_size.py b/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_mem_page_size.py new file mode 100644 index 0000000..cca056a --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_verify_values_for_mem_page_size.py @@ -0,0 +1,75 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Test to check vm response to reboot of the active compute. +# +# Author(s): Yong.Fu +# +### + +import os + +from pytest import fixture, mark + +from consts.stx import GuestImages +from keywords import nova_helper, glance_helper, vm_helper, host_helper + +# Flavor, Image, Volume info +cirros_params = { + "flavor_name": "flavor.small", + "flavor_vcpus": 2, + "flavor_ram": 2048, + "flavor_disk": 4, + "image_name": "cirros", + "image_file": os.path.join(GuestImages.DEFAULT["image_dir"], "cirros-0.4.0-x86_64-disk.img"), + "disk_format": "qcow2" +} + + +# Creating Flavor For Image +@fixture(scope="module") +def create_flavor_and_image(): + fl_id = nova_helper.create_flavor(name=cirros_params['flavor_name'], + vcpus=cirros_params['flavor_vcpus'], + ram=cirros_params['flavor_ram'], + root_disk=cirros_params['flavor_disk'], + is_public=True, add_default_specs=False, + cleanup="module")[1] + im_id = glance_helper.create_image(name=cirros_params['image_name'], + source_image_file=cirros_params['image_file'], + disk_format=cirros_params['disk_format'], + cleanup="module")[1] + return { + "flavor": fl_id, + "image": im_id + } + + +# Creating Instance +@fixture(scope='module') +def launch_instance(create_network, create_flavor_and_image): + net_id_list = [{"net-id": create_network[0]}] + vm_id = vm_helper.boot_vm(flavor=create_flavor_and_image["flavor"], nics=net_id_list, + source="image", source_id=create_flavor_and_image["image"], + cleanup="module")[1] + return vm_id + + +@mark.nova +def test_verify_values_for_mem_page_size(no_aio_system, launch_instance): + """ + 78-Verify-Values-For-Mem-Page-Size.robot + Args: + no_aio_system: + launch_instance: + + Returns: + + """ + host = vm_helper.get_vm_host(launch_instance) + host_helper.reboot_hosts(host) + after_host = vm_helper.get_vm_host(launch_instance) + assert after_host != host, "vm auto migrate failed" diff --git a/automated-pytest-suite/testcases/functional/nova/test_volume_snapshot_instance_horizon.py b/automated-pytest-suite/testcases/functional/nova/test_volume_snapshot_instance_horizon.py new file mode 100644 index 0000000..7f4d9d9 --- /dev/null +++ b/automated-pytest-suite/testcases/functional/nova/test_volume_snapshot_instance_horizon.py @@ -0,0 +1,67 @@ +### +# +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +# Local Storage - Launch instance from volume snapshote with Local_CoW Image Backed storage. +# +# Author(s): Yong.Fu +# +### + +import time +import os + +from pytest import mark + +from consts.stx import GuestImages, VMStatus +from keywords import glance_helper, nova_helper, cinder_helper, vm_helper +from testfixtures.fixture_resources import ResourceCleanup +from testfixtures.horizon import * +from utils.tis_log import LOG +from utils.horizon.pages.project.compute import instancespage +from utils.horizon.pages.project.volumes import volumespage + + +@mark.nova +def test_volume_snapshot_instance_horizon(tenant_home_pg_container, create_network): + """ + 200-Volume-Snapshot-Instance-Horizon.robot + Args: + tenant_home_pg_container: + create_network: + + Returns: + + """ + nova_helper.create_flavor(name="flavor", vcpus=1, ram=2048, root_disk=4, is_public=True, + add_default_specs=False, cleanup="function") + glance_helper.create_image(name="cirros", disk_format="qcow2", cleanup="function", + source_image_file=os.path.join(GuestImages.DEFAULT["image_dir"], + "cirros-0.4.0-x86_64-disk.img")) + LOG.fixture_step('Go to Project > Volumes > Volumes') + volumes_pg = volumespage.VolumesPage( + tenant_home_pg_container.driver, port=tenant_home_pg_container.port) + volumes_pg.go_to_target_page() + volumes_pg.create_volume("volume_test", volume_source_type="Image", source_name="cirros") + volume_id = cinder_helper.get_volumes(full_name="volume_test")[0] + + cinder_helper.wait_for_volume_status(volume=volume_id, status='available') + volumes_pg.create_volume_snapshot("volume_test", "snapshot_200") + snapshot_id = cinder_helper.get_volume_snapshot_values("snapshot_200", fields="ID")[0] + + cinder_helper.wait_for_vol_snapshot_status(snapshot_id, status='available') + instances_pg = instancespage.InstancesPage( + tenant_home_pg_container.driver, port=tenant_home_pg_container.port) + instances_pg.go_to_target_page() + LOG.fixture_step("Start create instance") + instances_pg.create_instance("cirros-snap-vm", boot_source_type="Volume Snapshot", + source_name="snapshot_200", flavor_name="flavor", + network_names="network") + time.sleep(30) + vm_id = vm_helper.get_vms(**{"Name": "cirros-snap-vm"})[0] + vm_helper.wait_for_vm_status(vm_id=vm_id, status=VMStatus.ACTIVE) + ResourceCleanup.add('vm', vm_id, scope="function", del_vm_vols=False) + ResourceCleanup.add('vol_snapshot', snapshot_id, scope="function") + ResourceCleanup.add('volume', volume_id, scope="function") diff --git a/automated-pytest-suite/utils/horizon/pages/project/compute/instancespage.py b/automated-pytest-suite/utils/horizon/pages/project/compute/instancespage.py index 050ecaa..9895536 100644 --- a/automated-pytest-suite/utils/horizon/pages/project/compute/instancespage.py +++ b/automated-pytest-suite/utils/horizon/pages/project/compute/instancespage.py @@ -10,7 +10,6 @@ from utils.horizon.regions import tables from utils.horizon.regions import menus from consts.stx import Networks - class LaunchInstanceForm(forms.TabbedFormRegion): _submit_locator = (by.By.XPATH, '//button[@class="btn btn-primary finish"]') _fields_locator = (by.By.XPATH, "//div[starts-with(@class,'step ng-scope')]") @@ -237,16 +236,17 @@ class InstancesPage(basepage.BasePage): instance_form.fields['boot-source-type'].text = boot_source_type time.sleep(1) instance_form._init_tab_fields(1) - if create_new_volume is True: - instance_form.fields['Create New Volume'].click_yes() - if delete_volume_on_instance_delete is True: - instance_form.fields['Delete Volume on Instance Delete'].click_yes() - if delete_volume_on_instance_delete is False: - instance_form.fields['Delete Volume on Instance Delete'].click_no() - if create_new_volume is False: - instance_form.fields['Create New Volume'].click_no() - if volume_size is not None: - instance_form.fields['volume-size'].value = volume_size + if boot_source_type == "Image" or boot_source_type == "Instance Snapshot": + if create_new_volume is True: + instance_form.fields['Create New Volume'].click_yes() + if delete_volume_on_instance_delete is True: + instance_form.fields['Delete Volume on Instance Delete'].click_yes() + if delete_volume_on_instance_delete is False: + instance_form.fields['Delete Volume on Instance Delete'].click_no() + if create_new_volume is False: + instance_form.fields['Create New Volume'].click_no() + if volume_size is not None: + instance_form.fields['volume-size'].value = volume_size instance_form.addelement('Name', source_name) instance_form.switch_to(2) instance_form.addelement('Name', flavor_name)