def test_vmware_vimapi_hotadd_disk( request, testing_group, provider, testing_vm, domain, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located in ``/Integration/VMware/VimApi`` Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button. * The test waits until the capacity of disks is raised. Metadata: test_flag: hotdisk, provision """ meth = cls.methods.create( name='load_value_{}'.format(fauxfactory.gen_alpha()), script=dedent('''\ # Sets the capacity of the new disk. $evm.root['size'] = 1 # GB exit MIQ_OK ''')) request.addfinalizer(meth.delete_if_exists) # Instance that calls the method and is accessible from the button instance = cls.instances.create( name="VMware_HotAdd_Disk_{}".format(fauxfactory.gen_alpha()), fields={ "meth4": {'value': meth.name}, # To get the value "rel5": {'value': "/Integration/VMware/VimApi/VMware_HotAdd_Disk"}, }, ) request.addfinalizer(instance.delete_if_exists) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, system="Request", request=instance.name) request.addfinalizer(button.delete_if_exists) button.create() def _get_disk_capacity(): testing_vm.summary.reload() return testing_vm.summary.datastore_allocation_summary.total_allocation.value original_disk_capacity = _get_disk_capacity() logger.info('Initial disk allocation: %s', original_disk_capacity) toolbar.select(testing_group.text, button.text) flash.assert_no_errors() try: wait_for( lambda: _get_disk_capacity() > original_disk_capacity, num_sec=180, delay=5) finally: logger.info('End disk capacity: %s', _get_disk_capacity())
def test_button_on_host(appliance, request, provider, setup_provider): buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format(fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.HOST request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() host = appliance.collections.hosts.all(provider)[0] host.execute_button(buttongroup.hover, button.text, handle_alert=None)
def test_button_avp_displayed(dialog, request): """This test checks whether the Attribute/Values pairs are displayed in the dialog. automates 1229348 Steps: * Open a dialog to create a button. * Locate the section with attribute/value pairs. """ # This is optional, our nav tree does not have unassigned button buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric()), type=ButtonGroup.VM_INSTANCE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") navigate_to(button, 'Add') section_loc = "//*[(self::h3 or self::p) and normalize-space(text())='Attribute/Value Pairs']" assert sel.is_displayed(section_loc),\ "The Attribute/Value Pairs part of the form is not displayed" for i in range(1, 6): assert sel.is_displayed('#attribute_{}'.format(i)) assert sel.is_displayed('#value_{}'.format(i))
def test_button_on_host(appliance, request, provider, setup_provider): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.HOST request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() host = appliance.collections.hosts.all(provider)[0] host.execute_button(buttongroup.hover, button.text, handle_alert=None)
def retire_extend_button(request): grp_name = "grp_{}".format(fauxfactory.gen_alphanumeric()) grp = ButtonGroup(text=grp_name, hover=grp_name, type=ButtonGroup.VM_INSTANCE) request.addfinalizer(lambda: grp.delete_if_exists()) grp.create() btn_name = "btn_{}".format(fauxfactory.gen_alphanumeric()) button = Button(group=grp, text=btn_name, hover=btn_name, system="Request", request="vm_retire_extend") request.addfinalizer(lambda: button.delete_if_exists()) button.create() return lambda: toolbar.select(grp.text, button.text)
def test_button_on_host(dialog, request): buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format(fauxfactory.gen_alphanumeric()), type=ButtonGroup.HOST) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() myhost = host.get_from_config('esx') if not myhost.exists: myhost.create() myhost.execute_button(buttongroup.hover, button.text)
def custom_service_button(ansible_catalog_item): buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format(fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.SERVICE buttongroup.create() button = Button( group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=ansible_catalog_item.provisioning["provisioning_dialog_name"], system="Request", request="Order_Ansible_Playbook" ) button.create() yield button button.delete_if_exists() buttongroup.delete_if_exists()
def test_button_on_host(dialog, request): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.HOST request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() myhost = host.get_from_config('esx') if not myhost.exists: myhost.create() myhost.execute_button(buttongroup.hover, button.text)
def retire_extend_button(request): grp_name = "grp_{}".format(fauxfactory.gen_alphanumeric()) grp = ButtonGroup( text=grp_name, hover=grp_name, type=ButtonGroup.VM_INSTANCE ) request.addfinalizer(lambda: grp.delete_if_exists()) grp.create() btn_name = "btn_{}".format(fauxfactory.gen_alphanumeric()) button = Button( group=grp, text=btn_name, hover=btn_name, system="Request", request="vm_retire_extend" ) request.addfinalizer(lambda: button.delete_if_exists()) button.create() return lambda: toolbar.select(grp.text, button.text)
def custom_vm_button(ansible_catalog_item): buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format(fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.VM_INSTANCE buttongroup.create() button = Button( group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=ansible_catalog_item.provisioning["provisioning_dialog_name"], system="Request", request="Order_Ansible_Playbook", attributes=[ {"key": "hosts", "value": "localhost"}, {"key": "service_template_name", "value": ansible_catalog_item.name} ] ) button.create() yield button button.delete_if_exists() buttongroup.delete_if_exists()
def test_button_crud(dialog, request): """Test Creating a Button Prerequisities: * An Button Group Steps: * Create a Button with random button text and button hover text, and random request * Assert that the button exists * Assert that the entered values correspond with what is displayed on the details page * Change the hover text, ensure the text is changed on details page * Delete the button * Assert that the button no longer exists. """ buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), type=ButtonGroup.SERVICE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() assert button.exists view = navigate_to(button, 'Details') assert view.text.text == button.text assert view.hover.text == button.hover edited_hover = "edited {}".format(fauxfactory.gen_alphanumeric()) with update(button): button.hover = edited_hover assert button.exists view = navigate_to(button, 'Details') assert view.hover.text == edited_hover button.delete(cancel=True) assert button.exists button.delete() assert not button.exists
def test_button_crud(dialog, request): """Test Creating a Button Prerequisities: * An Button Group Steps: * Create a Button with random button text and button hover text, and random request * Assert that the button exists * Assert that the entered values correspond with what is displayed on the details page * Change the hover text, ensure the text is changed on details page * Delete the button * Assert that the button no longer exists. """ buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), type=ButtonGroup.SERVICE ) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button( group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover=fauxfactory.gen_alphanumeric(), dialog=dialog, system="Request", request="InspectMe", ) request.addfinalizer(button.delete_if_exists) button.create() assert button.exists view = navigate_to(button, "Details") assert view.text.text == button.text assert view.hover.text == button.hover edited_hover = "edited {}".format(fauxfactory.gen_alphanumeric()) with update(button): button.hover = edited_hover assert button.exists view = navigate_to(button, "Details") assert view.hover.text == edited_hover button.delete(cancel=True) assert button.exists button.delete() assert not button.exists
def test_button_crud(dialog, request): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric()), type=ButtonGroup.SERVICE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() with update(button): button.hover = "edit_desc_{}".format(fauxfactory.gen_alphanumeric()) button.delete()
def test_button_crud(dialog, request): buttongroup = ButtonGroup( text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format(fauxfactory.gen_alphanumeric()), type=ButtonGroup.SERVICE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") request.addfinalizer(button.delete_if_exists) button.create() with update(button): button.hover = "edit_desc_{}".format(fauxfactory.gen_alphanumeric()) button.delete()
def custom_service_button(ansible_catalog_item): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.SERVICE buttongroup.create() button = Button( group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=ansible_catalog_item.provisioning["provisioning_dialog_name"], system="Request", request="Order_Ansible_Playbook") button.create() yield button button.delete_if_exists() buttongroup.delete_if_exists()
def test_button_avp_displayed(dialog, request): """This test checks whether the Attribute/Values pairs are displayed in the dialog. automates 1229348 Steps: * Open a dialog to create a button. * Locate the section with attribute/value pairs. """ # This is optional, our nav tree does not have unassigned button buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric()), type=ButtonGroup.VM_INSTANCE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() button = Button(group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=dialog, system="Request", request="InspectMe") view = navigate_to(button, 'Add') assert view.advanced.attribute_1.is_displayed assert view.advanced.value_1.is_displayed
def custom_vm_button(ansible_catalog_item): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_desc_{}".format( fauxfactory.gen_alphanumeric())) buttongroup.type = buttongroup.VM_INSTANCE buttongroup.create() button = Button( group=buttongroup, text=fauxfactory.gen_alphanumeric(), hover="btn_hvr_{}".format(fauxfactory.gen_alphanumeric()), dialog=ansible_catalog_item.provisioning["provisioning_dialog_name"], system="Request", request="Order_Ansible_Playbook", attributes=[{ "key": "hosts", "value": "localhost" }, { "key": "service_template_name", "value": ansible_catalog_item.name }]) button.create() yield button button.delete_if_exists() buttongroup.delete_if_exists()
def test_vm_retire_extend(appliance, request, testing_vm, soft_assert): """ Tests extending a retirement using an AE method. Prerequisities: * A running VM on any provider. Steps: * It creates a button pointing to ``Request/vm_retire_extend`` instance. The button should live in the VM and Instance button group. * Then it sets a retirement date for the VM * Then it waits until the retirement date is set * Then it clicks the button that was created and it waits for the retirement date to extend. Metadata: test_flag: retire, provision """ num_days = 5 soft_assert(testing_vm.retirement_date == 'Never', "The retirement date is not 'Never'!") retirement_date = generate_retirement_date(delta=num_days) testing_vm.set_retirement_date(retirement_date) wait_for(lambda: testing_vm.retirement_date != 'Never', message="retirement date set") set_date = testing_vm.retirement_date vm_retire_date_fmt = VM.RETIRE_DATE_FMT.pick(appliance.version) if not BZ(1419150, forced_streams='5.6').blocks: soft_assert( set_date == retirement_date.strftime(vm_retire_date_fmt), "The retirement date '{}' did not match expected date '{}'".format( set_date, retirement_date.strftime(vm_retire_date_fmt))) # Create the vm_retire_extend button and click on it grp_name = "grp_{}".format(fauxfactory.gen_alphanumeric()) grp = ButtonGroup(text=grp_name, hover=grp_name, type=ButtonGroup.VM_INSTANCE) request.addfinalizer(lambda: grp.delete_if_exists()) grp.create() btn_name = "btn_{}".format(fauxfactory.gen_alphanumeric()) button = Button(group=grp, text=btn_name, hover=btn_name, system="Request", request="vm_retire_extend") request.addfinalizer(lambda: button.delete_if_exists()) button.create() navigate_to(testing_vm, 'Details') class TestDropdownView(InfraVmSummaryView): group = Dropdown(grp.text) view = appliance.browser.create_view(TestDropdownView) view.group.item_select(button.text) # CFME automate vm_retire_extend method defaults to extending the date by 14 days extend_duration_days = 14 extended_retirement_date = retirement_date + timedelta( days=extend_duration_days) # Check that the WebUI updates with the correct date wait_for( lambda: testing_vm.retirement_date >= extended_retirement_date. strftime(vm_retire_date_fmt), num_sec=60, message="Check for extension of the VM retirement date by {} days". format(extend_duration_days))
def test_vmware_vimapi_hotadd_disk( request, testing_group, provider, testing_vm, domain, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located in ``/Integration/VMware/VimApi`` Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ meth = Method( name='parse_dialog_value_{}'.format(fauxfactory.gen_alpha()), data=dedent('''\ # Transfers the dialog value to the root so the VMware method can use it. $evm.root['size'] = $evm.object['dialog_size'] exit MIQ_OK '''), cls=cls) @request.addfinalizer def _remove_method(): if meth.exists(): meth.delete() meth.create() # Instance that calls the method and is accessible from the button instance = Instance( name="VMware_HotAdd_Disk_{}".format(fauxfactory.gen_alpha()), values={ "meth4": {'on_entry': meth.name}, # To preparse the value "rel5": "/Integration/VMware/VimApi/VMware_HotAdd_Disk", }, cls=cls ) @request.addfinalizer def _remove_instance(): if instance.exists(): instance.delete() instance.create() # Dialog to put the disk capacity element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(dialog.delete) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request=instance.name) request.addfinalizer(button.delete_if_exists) button.create() def _get_disk_count(): return int(testing_vm.get_detail( properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() logger.info('Initial disk count: %s', original_disk_count) toolbar.select(testing_group.text, button.text) fill(Input("size"), '1') pytest.sel.click(submit) flash.assert_no_errors() try: wait_for( lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5) finally: logger.info('End disk count: %s', _get_disk_count())
def test_vmware_vimapi_hotadd_disk( request, testing_group, provider, testing_vm, domain, namespace, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located either in ``/Integration/VimApi/`` (<5.3) or ``/Integration/VMware/VimApi`` (5.3 and up). Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ # Instance that calls the method and is accessible from the button if current_version() < "5.3": rel = "/Integration/VimApi/VMware_HotAdd_Disk" else: rel = "/Integration/VMware/VimApi/VMware_HotAdd_Disk" instance = Instance( name="VMware_HotAdd_Disk", values={ "rel5": rel, }, cls=cls ) if not instance.exists(): request.addfinalizer(lambda: instance.delete() if instance.exists() else None) instance.create() # Dialog to put the disk capacity return element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(lambda: dialog.delete()) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request="VMware_HotAdd_Disk") request.addfinalizer(button.delete_if_exists) button.create() # Now do the funny stuff def _get_disk_count(): return int(testing_vm.get_detail( properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() toolbar.select(testing_group.text, button.text) fill(Input("size"), "1") pytest.sel.click(submit) flash.assert_no_errors() wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5)
def test_vmware_vimapi_hotadd_disk( request, testing_group, provider_crud, provider_mgmt, testing_vm, domain, namespace, cls): """ Tests hot adding a disk to vmware vm Metadata: test_flag: hotdisk, provision """ # Instance that calls the method and is accessible from the button if current_version() < "5.3": rel = "/Integration/VimApi/VMware_HotAdd_Disk" else: rel = "/Integration/VMware/VimApi/VMware_HotAdd_Disk" instance = Instance( name="VMware_HotAdd_Disk", values={ "rel5": rel, }, cls=cls ) if not instance.exists(): request.addfinalizer(lambda: instance.delete() if instance.exists() else None) instance.create() # Dialog to put the disk capacity return element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(lambda: dialog.delete()) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request="VMware_HotAdd_Disk") request.addfinalizer(button.delete_if_exists) button.create() # Now do the funny stuff def _get_disk_count(): return int(testing_vm.get_detail( properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() toolbar.select(testing_group.text, button.text) fill(Input("size"), "1") pytest.sel.click(submit) flash.assert_no_errors() wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5)
def test_vmware_vimapi_hotadd_disk(request, testing_group, provider, testing_vm, domain, namespace, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located either in ``/Integration/VimApi/`` (<5.3) or ``/Integration/VMware/VimApi`` (5.3 and up). Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ # Instance that calls the method and is accessible from the button if current_version() < "5.3": rel = "/Integration/VimApi/VMware_HotAdd_Disk" else: rel = "/Integration/VMware/VimApi/VMware_HotAdd_Disk" instance = Instance(name="VMware_HotAdd_Disk", values={ "rel5": rel, }, cls=cls) if not instance.exists(): request.addfinalizer(lambda: instance.delete() if instance.exists() else None) instance.create() # Dialog to put the disk capacity return element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(lambda: dialog.delete()) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request="VMware_HotAdd_Disk") request.addfinalizer(button.delete_if_exists) button.create() # Now do the funny stuff def _get_disk_count(): return int( testing_vm.get_detail(properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() toolbar.select(testing_group.text, button.text) fill(Input("size"), "1") pytest.sel.click(submit) flash.assert_no_errors() wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5)
def test_vm_retire_extend(appliance, request, testing_vm, soft_assert): """ Tests extending a retirement using an AE method. Prerequisities: * A running VM on any provider. Steps: * It creates a button pointing to ``Request/vm_retire_extend`` instance. The button should live in the VM and Instance button group. * Then it sets a retirement date for the VM * Then it waits until the retirement date is set * Then it clicks the button that was created and it waits for the retirement date to extend. Metadata: test_flag: retire, provision """ num_days = 5 soft_assert(testing_vm.retirement_date == 'Never', "The retirement date is not 'Never'!") retirement_date = generate_retirement_date(delta=num_days) testing_vm.set_retirement_date(retirement_date) wait_for(lambda: testing_vm.retirement_date != 'Never', message="retirement date set") set_date = testing_vm.retirement_date vm_retire_date_fmt = VM.RETIRE_DATE_FMT.pick(appliance.version) if not BZ(1419150, forced_streams='5.6').blocks: soft_assert(set_date == retirement_date.strftime(vm_retire_date_fmt), "The retirement date '{}' did not match expected date '{}'" .format(set_date, retirement_date.strftime(vm_retire_date_fmt))) # Create the vm_retire_extend button and click on it grp_name = "grp_{}".format(fauxfactory.gen_alphanumeric()) grp = ButtonGroup( text=grp_name, hover=grp_name, type=ButtonGroup.VM_INSTANCE ) request.addfinalizer(lambda: grp.delete_if_exists()) grp.create() btn_name = "btn_{}".format(fauxfactory.gen_alphanumeric()) button = Button( group=grp, text=btn_name, hover=btn_name, system="Request", request="vm_retire_extend" ) request.addfinalizer(lambda: button.delete_if_exists()) button.create() navigate_to(testing_vm, 'Details') class TestDropdownView(InfraVmSummaryView): group = Dropdown(grp.text) view = appliance.browser.create_view(TestDropdownView) view.group.item_select(button.text) # CFME automate vm_retire_extend method defaults to extending the date by 14 days extend_duration_days = 14 extended_retirement_date = retirement_date + timedelta(days=extend_duration_days) # Check that the WebUI updates with the correct date wait_for( lambda: testing_vm.retirement_date >= extended_retirement_date.strftime(vm_retire_date_fmt), num_sec=60, message="Check for extension of the VM retirement date by {} days".format( extend_duration_days) )
def test_vmware_vimapi_hotadd_disk(request, testing_group, provider, testing_vm, domain, cls): """ Tests hot adding a disk to vmware vm. This test exercises the ``VMware_HotAdd_Disk`` method, located in ``/Integration/VMware/VimApi`` Steps: * It creates an instance in ``System/Request`` that can be accessible from eg. a button. * Then it creates a service dialog that contains a field with the desired disk size, the text field name should be ``size`` * Then it creates a button, that refers to the ``VMware_HotAdd_Disk`` in ``Request``. The button shall belong in the VM and instance button group. * After the button is created, it goes to a VM's summary page, clicks the button, enters the size of the disk and submits the dialog. * The test waits until the number of disks is raised. Metadata: test_flag: hotdisk, provision """ meth = Method(name='parse_dialog_value_{}'.format(fauxfactory.gen_alpha()), data=dedent('''\ # Transfers the dialog value to the root so the VMware method can use it. $evm.root['size'] = $evm.object['dialog_size'] exit MIQ_OK '''), cls=cls) @request.addfinalizer def _remove_method(): if meth.exists(): meth.delete() meth.create() # Instance that calls the method and is accessible from the button instance = Instance( name="VMware_HotAdd_Disk_{}".format(fauxfactory.gen_alpha()), values={ "meth4": { 'on_entry': meth.name }, # To preparse the value "rel5": "/Integration/VMware/VimApi/VMware_HotAdd_Disk", }, cls=cls) @request.addfinalizer def _remove_instance(): if instance.exists(): instance.delete() instance.create() # Dialog to put the disk capacity element_data = { 'ele_label': "Disk size", 'ele_name': "size", 'ele_desc': "Disk size", 'choose_type': "Text Box", 'default_text_box': "Default text" } dialog = ServiceDialog( label=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), submit=True, tab_label=fauxfactory.gen_alphanumeric(), tab_desc=fauxfactory.gen_alphanumeric(), box_label=fauxfactory.gen_alphanumeric(), box_desc=fauxfactory.gen_alphanumeric(), ) dialog.create(element_data) request.addfinalizer(dialog.delete) # Button that will invoke the dialog and action button_name = fauxfactory.gen_alphanumeric() button = Button(group=testing_group, text=button_name, hover=button_name, dialog=dialog, system="Request", request=instance.name) request.addfinalizer(button.delete_if_exists) button.create() def _get_disk_count(): return int( testing_vm.get_detail(properties=("Datastore Allocation Summary", "Number of Disks")).strip()) original_disk_count = _get_disk_count() logger.info('Initial disk count: {}'.format(original_disk_count)) toolbar.select(testing_group.text, button.text) fill(Input("size"), '1') pytest.sel.click(submit) flash.assert_no_errors() try: wait_for(lambda: original_disk_count + 1 == _get_disk_count(), num_sec=180, delay=5) finally: logger.info('End disk count: {}'.format(_get_disk_count()))