Skip to content

Commit

Permalink
Migration without conversion host (ManageIQ#9437)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshveta authored and spusateri committed Jan 27, 2020
1 parent a5831f9 commit 46cfff1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cfme/fixtures/v2v_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ def set_conversion_host_api(
message="Waiting for conversion configuration task to be finished")


@pytest.fixture(scope="function")
def delete_conversion_hosts(appliance):
# Delete existing conversion host entries from CFME
delete_hosts = appliance.ssh_client.run_rails_command(
"'MiqTask.delete_all; ConversionHost.delete_all'")
if not delete_hosts.success:
pytest.skip(
"Failed to delete all conversion hosts: {}".format(delete_hosts.output))


def __configure_conversion_host_ui(appliance, target_provider, hostname, default, # noqa
conv_host_key, transformation_method,
vmware_ssh_key, osp_cert_switch=None, osp_ca_cert=None):
Expand Down
33 changes: 33 additions & 0 deletions cfme/tests/v2v/test_v2v_migrations_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from cfme.cloud.provider.openstack import OpenStackProvider
from cfme.fixtures.provider import rhel7_minimal
from cfme.fixtures.v2v_fixtures import infra_mapping_default_data
from cfme.fixtures.v2v_fixtures import set_conversion_host_api
from cfme.infrastructure.provider.rhevm import RHEVMProvider
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.markers.env_markers.provider import ONE_PER_TYPE
Expand Down Expand Up @@ -533,3 +534,35 @@ def test_duplicate_mapping_name(appliance, mapping_data_vm_obj_mini):
view.general.description.fill("description")
view.general.flash.assert_message(f"Infrastructure mapping {name} already exists")
view.general.cancel_btn.click()


def test_migration_with_no_conversion(appliance, delete_conversion_hosts, source_provider,
request, provider, mapping_data_vm_obj_mini):
"""
Test Migration plan without setting conversion hosts
Polarion:
assignee: sshveta
initialEstimate: 1/2h
caseimportance: high
caseposneg: negative
testtype: functional
startsin: 5.10
casecomponent: V2V
"""
migration_plan_collection = appliance.collections.v2v_migration_plans
migration_plan = migration_plan_collection.create(
name="plan_{}".format(fauxfactory.gen_alphanumeric()),
description="desc_{}".format(fauxfactory.gen_alphanumeric()),
infra_map=mapping_data_vm_obj_mini.infra_mapping_data.get("name"),
target_provider=provider,
vm_list=mapping_data_vm_obj_mini.vm_list,
)

@request.addfinalizer
def _cleanup():
migration_plan.delete_completed_plan()
set_conversion_host_api(appliance, "vddk", source_provider, provider)

view = navigate_to(migration_plan, "InProgress")
assert not view.progress_card.is_plan_started(migration_plan.name)
assert "no conversion host" in view.progress_card.get_error_text(migration_plan.name)
5 changes: 5 additions & 0 deletions cfme/v2v/migration_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ def wait_for_state(self, state):
except TimedOutError:
logger.info("Wait for state :%s timed out", state)

def delete_completed_plan(self):
""" Find migration plan and delete."""
view = navigate_to(self, "Complete")
return view.plans_completed_list.delete_plan(self.name)


@attr.s
class MigrationPlanCollection(BaseCollection):
Expand Down
10 changes: 10 additions & 0 deletions widgetastic_manageiq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5353,6 +5353,7 @@ class MigrationProgressBar(Widget):
VMS_LOCATOR = './/strong[contains(@id,"vms-migrated")]'
SPINNER_LOCATOR = './/div[contains(@class,"spinner")]'
ERROR_LOCATOR = './/div/span[contains(@class,"pficon-error-circle-o")]'
ERROR_TXT = './/p[contains(@class, "blank-slate-pf-info")]'
PROGRESS_BARS = './/div[@class="progress-bar"]'
PROGRESS_DESCRIPTION = './/div[contains(@class,"progress-description")]'

Expand Down Expand Up @@ -5419,6 +5420,15 @@ def is_plan_started(self, plan_name):
return True
return False

def get_error_text(self, plan_name):
"""Returns error text for debugging failure"""
el = self._get_card_element(plan_name)
error_displayed = self.browser.is_displayed(self.ERROR_LOCATOR, parent=el)
if error_displayed:
error_text = self.browser.text(self.ERROR_TXT, parent=el)
self.browser.click(".//button[contains(text(), 'Cancel Migration')]", parent=el)
return error_text

def is_plan_visible(self, plan_name):
"""Returns true if migration plan card is shown in-progress section, else False"""
try:
Expand Down

0 comments on commit 46cfff1

Please sign in to comment.