def test_open_url(request, setup_obj, button_group, method): """ Test Open url functionality of custom button. Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Appliance with Infra provider 2. Create ruby method for url functionality 3. Create custom button group with the Object type 4. Create a custom button with open_url option and respective method 5. Navigate to object Detail page 6. Execute custom button 7. Check new tab open or not with respective url """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), open_url=True, display_for="Single entity", system="Request", request=method.name, ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # TODO: Move windows handling functionality to browser initial_count = len(view.browser.selenium.window_handles) main_window = view.browser.selenium.current_window_handle custom_button_group.item_select(button.text) wait_for( lambda: len(view.browser.selenium.window_handles) > initial_count, timeout=120, message="Check for window open", ) open_url_window = set(view.browser.selenium.window_handles) - {main_window} view.browser.selenium.switch_to_window(open_url_window.pop()) @request.addfinalizer def _reset_window(): if view.browser.selenium.current_window_handle != main_window: view.browser.selenium.close() view.browser.selenium.switch_to_window(main_window) assert "example.com" in view.browser.url
def test_custom_button_quotes(appliance, provider, setup_provider, dialog, request): """ Test custom button and group allows quotes or not Polarion: assignee: ndhandre initialEstimate: 1/6h caseimportance: medium caseposneg: positive testtype: nonfunctional startsin: 5.8 casecomponent: CustomButton tags: custom_button setup: Simple TextInput service dialog testSteps: 1. Create custom button group with single quote in name like "Group's" 2. Create a custom button with quote in name like "button's" 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit Check for the flash message related to button execution Bugzilla: 1646905 """ # ToDo: collect test for 5.9; If developer backport BZ-1646905 collection = appliance.collections.button_groups group = collection.create( text="Group's", hover="Group's Hover", type=getattr(collection, "PROVIDER") ) request.addfinalizer(group.delete_if_exists) button = group.buttons.create( text="Button's", hover="Button's Hover", dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) view = navigate_to(provider, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait='60s') dialog_view.service_name.fill("Custom Button Execute") dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted")
def test_custom_button_events_cloud_obj(request, dialog, setup_objs, button_group, btn_dialog): """Test custom button events Polarion: assignee: ndhandre caseimportance: medium initialEstimate: 1/4h caseposneg: positive testtype: functional startsin: 5.10 casecomponent: CustomButton tags: custom_button testSteps: 1. Create a Button Group 2. Create custom button [with dialog/ without dialog] 2. Execute button from respective location 3. Assert event count Bugzilla: 1668023 1702490 1680525 """ group, obj_type = button_group dialog_ = dialog if btn_dialog else None button = group.buttons.create( text="btn_{}".format(fauxfactory.gen_alphanumeric(3)), hover="btn_hover{}".format(fauxfactory.gen_alphanumeric(3)), dialog=dialog_, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: initial_count = len(setup_obj.get_button_events()) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) custom_button_group.item_select(button.text) if btn_dialog: dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") dialog_view.submit.click() view.browser.refresh() current_count = len(setup_obj.get_button_events()) assert current_count == (initial_count + 1)
def test_custom_button_dialog_infra_obj(appliance, dialog, request, setup_obj, button_group): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with service dialog 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit 7. Check for the proper flash message related to button execution Bugzilla: 1635797 1555331 1574403 1640592 1641669 1685555 """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") assert dialog_view.service_name.fill("Custom Button Execute") # start log check request_pattern = "Attributes - Begin" log = LogValidator("/var/www/miq/vmdb/log/automation.log", matched_patterns=[request_pattern]) log.start_monitoring() # Submit order dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( lambda: log.matches[request_pattern] == 1, timeout=180, message="wait for expected match count", delay=5, ) except TimedOutError: assert False, "Expected '1' requests and '{}' requests found in automation log".format( log.matches[request_pattern])
def test_custom_button_automate_infra_obj(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1628224 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj # Note: For VM, custom button not display on `All page` but only `VM page`. if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" # Note: For VM Template, custom button not display on All page but only TemplatesOnly. if obj_type == "TEMPLATE_IMAGE" and destination == "All": destination = "TemplatesOnly" view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination in ["All", "VMsOnly", "TemplatesOnly"]: try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) paginator.check_all() else: entity_count = 1 # start log check request_pattern = "Attributes - Begin" log = LogValidator("/var/www/miq/vmdb/log/automation.log", matched_patterns=[request_pattern]) log.start_monitoring() custom_button_group.item_select(button.text) diff = "executed" if appliance.version < "5.10" else "launched" view.flash.assert_message(f'"{button.text}" was {diff}') # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( lambda: log.matches[request_pattern] == expected_count, timeout=300, message="wait for expected match count", delay=5, ) except TimedOutError: assert False, "Expected '{}' requests and '{}' requests found in automation log".format( expected_count, log.matches[request_pattern])
def test_custom_button_dialog(appliance, dialog, request, setup_objs, button_group): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Simple TextInput service dialog 2. Create custom button group with the Object type 3. Create a custom button with service dialog 4. Navigate to object Details page 5. Check for button group and button 6. Select/execute button from group dropdown for selected entities 7. Fill dialog and submit 8. Check for the proper flash message related to button execution Bugzilla: 1635797, 1555331, 1574403, 1640592 """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) # Submit order request dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
def test_custom_button_dialog_cloud_obj(appliance, dialog, request, setup_objs, button_group): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Simple TextInput service dialog 2. Create custom button group with the Object type 3. Create a custom button with service dialog 4. Navigate to object Details page 5. Check for button group and button 6. Select/execute button from group dropdown for selected entities 7. Fill dialog and submit 8. Check for the proper flash message related to button execution Bugzilla: 1635797 1555331 1574403 1640592 1710350 1732436 """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) # Submit order request dialog_view.submit.click() if not (BZ(1732436, forced_streams=["5.10", "5.11"]).blocks and obj_type == "PROVIDER"): view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
def test_custom_button_automate(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.10 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1628224, 1642939 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": entity_count = min(view.paginator.items_amount, view.paginator.items_per_page) view.paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log') custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=120, message="Check for expected request count", delay=10, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count))
def test_custom_button_automate_service_obj( request, appliance, context, submit, objects, button_group ): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1650066 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav # BZ-1650066: no custom button on All page destinations = ( ["Details"] if context == ViaSSUI and BZ(1650066, forced_streams=["5.11"]).blocks else ["All", "Details"] ) for destination in destinations: obj = objects[obj_type][destination][0] dest_name = objects[obj_type][destination][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) view.entities.paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) # SSUI not support flash messages if context is ViaUI: diff = "executed" if appliance.version < "5.10" else "launched" view.flash.assert_message('"{btn}" was {diff}'.format(btn=button.text, diff=diff)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(expected_count) )
def test_custom_button_with_dynamic_dialog_vm(appliance, provider, request, service_vm, setup_dynamic_dialog): """ Test custom button combination with dynamic dialog for VM entity. Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton testSteps: 1. Create new domain and copy 'Request' class from ManageIQ domain 2. Create class method under new domain with following ruby method ```ruby @vm = $evm.root['vm'] dialog_hash = {} dialog_hash[@vm.id] = @vm.name $evm.object['default_value'] = dialog_hash.first[0] $evm.object['values'] = dialog_hash ``` 3. Create Instance Pointing class method 4. Create Dropdown type Service Dialog (dynamic) with entry point as above method 5. Create Custom button with Service Dialog on VM/Instance Object 6. Execute button on VM with OPS UI and SSUI. expectedResults: 1. 2. 3. 4. Check service dialog created or not 5. 6. Check dialog should take vm/instance name automatically as per method. Check automation log for button execution. Bugzilla: 1687061 1722817 1729594 """ dialog, ele_name = setup_dynamic_dialog # Create button group collection = appliance.collections.button_groups button_gp = collection.create( text=fauxfactory.gen_alphanumeric(start="grp_"), hover=fauxfactory.gen_alphanumeric(15, start="grp_hvr_"), type=getattr(collection, "VM_INSTANCE"), ) request.addfinalizer(button_gp.delete_if_exists) # Create custom button under group button = button_gp.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), dialog=dialog.label, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) # Check service vm on UI and SSUI service, _ = service_vm for context in [ViaUI, ViaSSUI]: with appliance.context.use(context): nav_to = ssui_nav if context is ViaSSUI else ui_nav # Navigate to VM Details page of service view = nav_to(service, "VMDetails") # Select button from custom button group dropdown custom_button_group = Dropdown(view, button_gp.text) assert custom_button_group.is_displayed custom_button_group.item_select(button.text) # Check default selected vm must destination vm view = view.browser.create_view(DropdownDialogView) serv = view.service_name(ele_name) serv.dropdown.wait_displayed() assert serv.dropdown.selected_option == service.vm_name # execute button and check `InspectMe` method by Attributes - Begin` and # `$evm.root['vm']` of dynamic dialog by expected service vm name in automation log log = LogValidator( "/var/www/miq/vmdb/log/automation.log", matched_patterns=[ "Attributes - Begin", 'name = "{}"'.format(service.vm_name) ], ) log.start_monitoring() submit = "submit" if context is ViaUI else "submit_request" getattr(view, submit).click() assert log.validate(wait="120s")
def test_custom_button_dialog_service_obj( appliance, dialog, request, context, objects, button_group ): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with service dialog 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit 7. Check for the proper flash message related to button execution Bugzilla: 1574774 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text="btn_{}".format(fauxfactory.gen_alphanumeric(3)), hover="btn_hover_{}".format(fauxfactory.gen_alphanumeric(3)), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav obj = objects[obj_type]["Details"][0] dest_name = objects[obj_type]["Details"][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) _dialog_view = TextInputDialogView if context is ViaUI else TextInputDialogSSUIView dialog_view = view.browser.create_view(_dialog_view, wait="10s") assert dialog_view.service_name.fill("Custom Button Execute") dialog_view.submit.click() # SSUI not support flash messages if context is ViaUI: view.flash.assert_message("Order Request was Submitted") # check request in log try: wait_for( log_request_check, [appliance, 1], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(1) )
def test_custom_button_automate(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit prerequisites: * Appliance Steps: * Create custom button group with the Object type * Create a custom button with specific submit option and Single and list display * Navigate to object type pages (All and Details) * Check for button group and button * Select/execute button from group dropdown for selected entities * Check for the proper flash message related to button execution * Check automation log requests. Submitted as per selected submit option or not. * Submit all: single request for all entities execution * One by one: separate requests for all entities execution Bugzillas: * 1628224 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": entity_count = view.paginator.items_amount # we are counting entity on same page view.paginator.check_all() else: entity_count = 1 # First collect number of request already available in automation log initial_request_count = check_log_requests_count(appliance) custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, initial_request_count, expected_count], timeout=120, message="Check for expected request count", delay=10, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count) )
def test_custom_button_open_url_evm_obj(request, setup_obj, button_group, method): """ Test Open url functionality of custom button. Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: high caseposneg: positive testtype: functional startsin: 5.11 casecomponent: CustomButton tags: custom_button testSteps: 1. Create ruby method for url functionality 2. Create custom button group with the Object type 3. Create a custom button with open_url option and respective method 4. Navigate to object Detail page 5. Execute custom button expectedResults: 1. 2. 3. 4. 5. New tab should open with respective url Bugzilla: 1550002 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), open_url=True, system="Request", request=method.name, ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) initial_count = len(view.browser.window_handles) main_window = view.browser.current_window_handle custom_button_group.item_select(button.text) wait_for( lambda: len(view.browser.window_handles) > initial_count, timeout=30, message="Check for window open", ) open_url_window = (set(view.browser.window_handles) - {main_window}).pop() view.browser.switch_to_window(open_url_window) @request.addfinalizer def _reset_window(): view.browser.close_window(open_url_window) view.browser.switch_to_window(main_window) assert "example.com" in view.browser.url
def test_dynamic_submit_cancel_button_service(request, appliance, generic_service, import_dialog, import_datastore, import_data): """ Bugzilla: 1611527 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/6h startsin: 5.10 testSteps: 1. Import Datastore and dialog 2. Create button with above dialog 3. Create catalog item 4. Order the service 5. Go to My services 6. Click on created service 7. load the service with a button expectedResults: 1. 2. 3. 4. 5. 6. 7. Submit and Cancel button should be enabled """ service, _ = generic_service sd, ele_label = import_dialog # Create button group collection = appliance.collections.button_groups button_gp = collection.create( text=fauxfactory.gen_alphanumeric(start="grp_"), hover=fauxfactory.gen_alphanumeric(15, start="grp_hvr_"), type=getattr(collection, "SERVICE"), ) request.addfinalizer(button_gp.delete_if_exists) # Create custom button under group button = button_gp.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), dialog=sd.label, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) # Navigate to Details page of service view = navigate_to(service, "Details") # Load service on custom button custom_button_group = Dropdown(view, button_gp.text) assert custom_button_group.is_displayed custom_button_group.item_select(button.text) view = view.browser.create_view(DropdownDialogView, wait="60s") serv = view.service_name(ele_label) serv.dropdown.wait_displayed() wait_for(lambda: not (view.submit.disabled and view.cancel.disabled), timeout=120)
def test_custom_button_dialog_service_archived(request, appliance, provider, setup_provider, service_vm, button_group, dialog): """ From Service OPS check if archive vms"s dialog invocation via custom button. ref: BZ1439883 Polarion: assignee: ndhandre initialEstimate: 1/8h caseimportance: medium caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create a button at the service level with InspectMe method 2. Create a service that contains 1 VM 3. Remove this VM from the provider, resulting in a VM state of 'Archived' 4. Go to the service and try to execute the button Bugzilla: 1439883 """ service, vm = service_vm group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(start="hover_"), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for with_vm in [True, False]: # [vm, archive_vm] if not with_vm: # Make vm archive by deleting vm from provider side vm.mgmt.delete() vm.wait_for_vm_state_change(desired_state="archived", timeout=720, from_details=False, from_any_provider=True) for context in [ViaUI, ViaSSUI]: # check execution with UI and SSUI with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav view = navigate_to(service, "Details") # execute button custom_button_group = Dropdown(view, group.text) custom_button_group.item_select(button.text) _dialog_view = TextInputDialogView if context is ViaUI else TextInputDialogSSUIView dialog_view = view.browser.create_view(_dialog_view, wait="10s") # start log check request_pattern = "Attributes - Begin" log = LogValidator("/var/www/miq/vmdb/log/automation.log", matched_patterns=[request_pattern]) log.start_monitoring() # submit dialog dialog_view.submit.click() # SSUI not support flash messages if context is ViaUI: view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( lambda: log.matches[request_pattern] == 1, timeout=180, message="wait for expected match count", delay=5, ) except TimedOutError: pytest.fail( f"Expected '1' requests; found '{log.matches[request_pattern]}'" )
def test_custom_button_open_url_infra_obj(request, setup_obj, button_group, method): """ Test Open url functionality of custom button. Polarion: assignee: ndhandre initialEstimate: 1/2h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Appliance with Infra provider 2. Create ruby method for url functionality 3. Create custom button group with the Object type 4. Create a custom button with open_url option and respective method 5. Navigate to object Detail page 6. Execute custom button expectedResults: 1. 2. 3. 4. 5. 6. New tab should open with respective url """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(start="grp_"), hover=fauxfactory.gen_alphanumeric(15, start="grp_hvr_"), open_url=True, display_for="Single entity", system="Request", request=method.name, ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # TODO: Move windows handling functionality to browser initial_count = len(view.browser.selenium.window_handles) main_window = view.browser.selenium.current_window_handle custom_button_group.item_select(button.text) wait_for( lambda: len(view.browser.selenium.window_handles) > initial_count, timeout=120, message="Check for window open", ) open_url_window = set(view.browser.selenium.window_handles) - {main_window} view.browser.selenium.switch_to_window(open_url_window.pop()) @request.addfinalizer def _reset_window(): if view.browser.selenium.current_window_handle != main_window: view.browser.selenium.close() view.browser.selenium.switch_to_window(main_window) assert "example.com" in view.browser.url
def test_load_service_with_button(request, appliance, generic_service, import_dialog, import_datastore, import_data): """ Bugzilla: 1737559 Polarion: assignee: nansari casecomponent: Services initialEstimate: 1/6h startsin: 5.10 testSteps: 1. Import Datastore and dialog 2. Create button with above dialog 3. Create catalog item 4. Order the service 5. Go to My services 6. Click on created service 7. load the service with a button expectedResults: 1. 2. 3. 4. 5. 6. 7. Service should load without an error in log """ service, _ = generic_service sd, ele_label = import_dialog # Create button group collection = appliance.collections.button_groups button_gp = collection.create( text=fauxfactory.gen_alphanumeric(start="grp_"), hover=fauxfactory.gen_alphanumeric(15, start="grp_hvr_"), type=getattr(collection, "SERVICE"), ) request.addfinalizer(button_gp.delete_if_exists) # Create custom button under group button = button_gp.buttons.create( text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(15, start="btn_hvr_"), dialog=sd.label, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) # Navigate to Details page of service view = navigate_to(service, "Details") # Start log check with LogValidator("/var/www/miq/vmdb/log/automation.log", failure_patterns=[r".*ERROR.*"]).waiting(timeout=60): # Load service on custom button custom_button_group = Dropdown(view, button_gp.text) assert custom_button_group.is_displayed custom_button_group.item_select(button.text)
def test_custom_button_automate(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit prerequisites: * Appliance with Infra provider Steps: * Create custom button group with the Object type * Create a custom button with specific submit option and Single and list display * Navigate to object type pages (All and Details) * Check for button group and button * Select/execute button from group dropdown for selected entities * Check for the proper flash message related to button execution * Check automation log requests. Submitted as per selected submit option or not. * Submit all: single request for all entities execution * One by one: separate requests for all entities execution Bugzillas: * 1628224 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj # Note: For VM, custom button not display on `All page` but only `VM page`. if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" # Note: For VM Template, custom button not display on All page but only TemplatesOnly. if obj_type == "TEMPLATE_IMAGE" and destination == "All": destination = "TemplatesOnly" view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination in ["All", "VMsOnly", "TemplatesOnly"]: try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log') custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count))
def test_custom_button_ansible_automate_infra_obj( request, appliance, inventory, setup_obj, button_group, ansible_catalog_item_create_empty_file, target_machine, target_machine_ansible_creds, ): """ Test ansible custom button for with specific inventory execution Polarion: assignee: ndhandre initialEstimate: 1/4h startsin: 5.9 casecomponent: CustomButton tags: custom_button setup: 1. Setup Target Machine with pingable hostname 2. Create catalog with ansible catalog item testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific inventory (localhost/ Target Machine/ Specific Host) 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog with proper credentials and hostname 7. Check for the proper flash message 8. Check operation perform on target machine or not (here create test file). """ group, obj_type = button_group if inventory == "Localhost": cred_name = "CFME Default Credential" hostname = appliance.hostname username = credentials["ssh"]["username"] password = credentials["ssh"]["password"] else: cred_name = target_machine_ansible_creds.name hostname = target_machine.hostname username = target_machine.username password = target_machine.password # Create button as per inventory button = group.buttons.create( type="Ansible Playbook", playbook_cat_item=ansible_catalog_item_create_empty_file.name, inventory=inventory, hosts=target_machine.hostname if inventory == "Specific Hosts" else None, text=fauxfactory.gen_alphanumeric(start="btn_"), hover=fauxfactory.gen_alphanumeric(start="hover_"), ) request.addfinalizer(button.delete_if_exists) # For target machine inventory target entity object is created target VM entity = target_machine.vm if inventory == "Target Machine" else setup_obj # Navigate to entity object and execute button view = navigate_to(entity, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(CredsHostsDialogView, wait="20s") dialog_view.fill({"machine_credential": cred_name}) with SSHClient(hostname=hostname, username=username, password=password) as client: # Clean file if already available on host client.remove_file(ANSIBLE_FILE) # execute playbook with button dialog_view.submit.click() view.flash.assert_success_message("Order Request was Submitted") # wait for file touch by playbook try: wait_for(client.is_file_available, func_args=[ANSIBLE_FILE], delay=5, timeout=240, message=f"Waiting for {ANSIBLE_FILE} file") except TimedOutError: pytest.fail( f"Waiting timeout: unable to locate {ANSIBLE_FILE} on host {hostname}" )
def test_custom_button_dialog(appliance, dialog, request, setup_obj, button_group): """ Test custom button with dialog and InspectMe method Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.10 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with service dialog 3. Navigate to object Details page 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Fill dialog and submit 7. Check for the proper flash message related to button execution 8. Check request in automation log """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView, wait="10s") assert dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log') # Submit order dialog_view.submit.click() view.wait_displayed("60s") view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
def test_custom_button_dialog(appliance, dialog, request, setup_objs, button_group): """ Test custom button with dialog and InspectMe method Prerequisites: * Appliance with Infra provider * Simple TextInput service dialog Steps: * Create custom button group with the Object type * Create a custom button with service dialog * Navigate to object Details page * Check for button group and button * Select/execute button from group dropdown for selected entities * Fill dialog and submit * Check for the proper flash message related to button execution Bugzillas: * 1635797, 1555331, 1574403, 1640592 Polarion: assignee: ndhandre caseimportance: high initialEstimate: 1/4h """ group, obj_type = button_group # Note: No need to set display_for dialog only work with Single entity button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: view = navigate_to(setup_obj, "Details") custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) custom_button_group.item_select(button.text) dialog_view = view.browser.create_view(TextInputDialogView) dialog_view.wait_displayed() dialog_view.service_name.fill("Custom Button Execute") # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log') # Submit order request dialog_view.submit.click() view.flash.assert_message("Order Request was Submitted") # Check for request in automation log try: wait_for( log_request_check, [appliance, 1], timeout=300, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected 1 requests not found in automation log"
def test_custom_button_automate(request, appliance, context, submit, objects, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1650066 """ group, obj_type = button_group with appliance.context.use(ViaUI): button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) with appliance.context.use(context): navigate_to = ssui_nav if context is ViaSSUI else ui_nav # BZ-1650066: no custom button on All page destinations = ( ["Details"] if context == ViaSSUI and BZ(1650066, forced_streams=["5.9", "5.10"]).blocks else ["All", "Details"] ) for destination in destinations: obj = objects[obj_type][destination][0] dest_name = objects[obj_type][destination][1] view = navigate_to(obj, dest_name) custom_button_group = Dropdown(view, group.text) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) view.entities.paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) # SSUI not support flash messages if context is ViaUI: view.flash.assert_message('"{button}" was executed'.format(button=button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {count} requests not found in automation log".format( count=str(expected_count) )
def test_custom_button_automate(appliance, request, submit, setup_objs, button_group): """ Test custom button for automate and requests count as per submit prerequisites: * Appliance with Cloud provider Steps: * Create custom button group with the Object type * Create a custom button with specific submit option and Single and list display * Navigate to object type pages (All and Details) * Check for button group and button * Select/execute button from group dropdown for selected entities * Check for the proper flash message related to button execution * Check automation log requests. Submitted as per selected submit option or not. * Submit all: single request for all entities execution * One by one: separate requests for all entities execution Bugzillas: * 1628224, 1642147 Polarion: assignee: ndhandre caseimportance: high initialEstimate: 1/4h """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. # To-Do: remove Manager check as BZ-1642147 fix if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) # Work around for BZ-1642147 try: if "Manager" in setup_obj.name: entity_count = 1 except AttributeError: pass paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > ' "/var/www/miq/vmdb/log/automation.log") custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=300, message="Check for expected request count", delay=10, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count))
def test_custom_button_automate(appliance, request, submit, setup_objs, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9 One by one: separate requests for all entities execution Bugzilla: 1628224, 1642147 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for setup_obj in setup_objs: for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. # To-Do: remove Manager check as BZ-1642147 fix if destination == "All": try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) # Work around for BZ-1642147 try: if "Manager" in setup_obj.name: entity_count = 1 except AttributeError: pass paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > ' "/var/www/miq/vmdb/log/automation.log" ) custom_button_group.item_select(button.text) view.flash.assert_message('"{}" was executed'.format(button.text)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=300, message="Check for expected request count", delay=10, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count) )
def test_custom_button_automate_infra_obj(appliance, request, submit, setup_obj, button_group): """ Test custom button for automate and requests count as per submit Polarion: assignee: ndhandre initialEstimate: 1/4h caseimportance: high caseposneg: positive testtype: functional startsin: 5.9 casecomponent: CustomButton tags: custom_button testSteps: 1. Create custom button group with the Object type 2. Create a custom button with specific submit option and Single and list display 3. Navigate to object type pages (All and Details) 4. Check for button group and button 5. Select/execute button from group dropdown for selected entities 6. Check for the proper flash message related to button execution 7. Check automation log requests. Submitted as per selected submit option or not. 8. Submit all: single request for all entities execution 9. One by one: separate requests for all entities execution Bugzilla: 1628224 """ group, obj_type = button_group button = group.buttons.create( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), display_for="Single and list", submit=submit, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) for destination in ["All", "Details"]: obj = setup_obj.parent if destination == "All" else setup_obj # Note: For VM, custom button not display on `All page` but only `VM page`. if obj_type == "VM_INSTANCE" and destination == "All": destination = "VMsOnly" # Note: For VM Template, custom button not display on All page but only TemplatesOnly. if obj_type == "TEMPLATE_IMAGE" and destination == "All": destination = "TemplatesOnly" view = navigate_to(obj, destination) custom_button_group = Dropdown(view, group.hover) assert custom_button_group.has_item(button.text) # Entity count depends on the destination for `All` available entities and # `Details` means a single entity. if destination in ["All", "VMsOnly", "TemplatesOnly"]: try: paginator = view.paginator except AttributeError: paginator = view.entities.paginator entity_count = min(paginator.items_amount, paginator.items_per_page) paginator.check_all() else: entity_count = 1 # Clear the automation log assert appliance.ssh_client.run_command( 'echo -n "" > /var/www/miq/vmdb/log/automation.log' ) custom_button_group.item_select(button.text) diff = "executed" if appliance.version < "5.10" else "launched" view.flash.assert_message('"{btn}" was {diff}'.format(btn=button.text, diff=diff)) # Submit all: single request for all entity execution # One by one: separate requests for all entity execution expected_count = 1 if submit == "Submit all" else entity_count try: wait_for( log_request_check, [appliance, expected_count], timeout=600, message="Check for expected request count", delay=20, ) except TimedOutError: assert False, "Expected {} requests not found in automation log".format( str(expected_count) )