def domain(appliance): dc = DomainCollection(appliance) d = dc.create(name='test_{}'.format(fauxfactory.gen_alpha()), description='desc_{}'.format(fauxfactory.gen_alpha()), enabled=True) yield d d.delete()
def domain(appliance): dc = DomainCollection(appliance) d = dc.create( name='test_{}'.format(fauxfactory.gen_alpha()), description='desc_{}'.format(fauxfactory.gen_alpha()), enabled=True) yield d d.delete()
def test_domain_cannot_edit_builtin(): domains = DomainCollection() manageiq_domain = domains.instantiate(name='ManageIQ') details_view = navigate_to(manageiq_domain, 'Details') if domains.appliance.version < '5.7': assert details_view.configuration.is_displayed assert not details_view.configuration.item_enabled('Edit this Domain') else: assert not details_view.configuration.is_displayed
def copy_domain(request, appliance): dc = DomainCollection(appliance) domain = dc.create(name=fauxfactory.gen_alphanumeric(), enabled=True) request.addfinalizer(domain.delete_if_exists) dc.instantiate(name='ManageIQ')\ .namespaces.instantiate(name='System')\ .classes.instantiate(name='Request')\ .copy_to(domain) return domain
def test_domain_cannot_delete_builtin(appliance): domains = DomainCollection(appliance) manageiq_domain = domains.instantiate(name='ManageIQ') details_view = navigate_to(manageiq_domain, 'Details') if domains.appliance.version < '5.7': assert details_view.configuration.is_displayed assert 'Remove this Domain' not in details_view.configuration.items else: assert not details_view.configuration.is_displayed
def test_duplicate_domain_disallowed(request): domains = DomainCollection() domain = domains.create(name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete_if_exists) with error.expected("Name has already been taken"): domains.create(name=domain.name, description=domain.description, enabled=domain.enabled)
def qe_ae_data(request, ssh_client, rake): ssh_client.put_file(cli_path.join("QECliTesting.yaml").strpath, "/root/QECliTesting.yaml") rc, stdout = rake( "evm:automate:import DOMAIN=QECliTesting YAML_FILE=/root/QECliTesting.yaml PREVIEW=false " "ENABLED=true SYSTEM=false") assert rc == 0, stdout # Now we have to enable the domain to make it work. qe_cli_testing = DomainCollection().instantiate(name='QECliTesting') request.addfinalizer(qe_cli_testing.delete_if_exists) if not qe_cli_testing.enabled: with update(qe_cli_testing): qe_cli_testing.enabled = True
def test_duplicate_domain_disallowed(request): domains = DomainCollection() domain = domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete_if_exists) with error.expected("Name has already been taken"): domains.create( name=domain.name, description=domain.description, enabled=domain.enabled)
def test_domain_lock_unlock(request): domains = DomainCollection() domain = domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete) ns1 = domain.namespaces.create(name='ns1') ns2 = ns1.namespaces.create(name='ns2') cls = ns2.classes.create(name='class1') cls.schema.add_field(name='myfield', type='Relationship') inst = cls.instances.create(name='inst') meth = cls.methods.create(name='meth', script='$evm') # Lock the domain domain.lock() # Check that nothing is editable # namespaces details = navigate_to(ns1, 'Details') assert not details.configuration.is_displayed details = navigate_to(ns2, 'Details') assert not details.configuration.is_displayed # class details = navigate_to(cls, 'Details') assert details.configuration.items == ['Copy selected Instances'] assert not details.configuration.item_enabled('Copy selected Instances') details.schema.select() assert not details.configuration.is_displayed # instance details = navigate_to(inst, 'Details') assert details.configuration.items == ['Copy this Instance'] # method details = navigate_to(meth, 'Details') assert details.configuration.items == ['Copy this Method'] # Unlock it domain.unlock() # Check that it is editable with update(ns1): ns1.name = 'UpdatedNs1' assert ns1.exists with update(ns2): ns2.name = 'UpdatedNs2' assert ns2.exists with update(cls): cls.name = 'UpdatedClass' assert cls.exists cls.schema.add_field(name='myfield2', type='Relationship') with update(inst): inst.name = 'UpdatedInstance' assert inst.exists with update(meth): meth.name = 'UpdatedMethod' assert meth.exists
def import_domain_from(self, branch=None, tag=None): """Import the domain from git using the Import/Export UI. Args: branch: If you import from a branch, specify the origin/branchname tag: If you import from a tag, specify its name. Returns: Instance of :py:class:`cfme.automate.explorer.domain.Domain` **Important!** ``branch`` and ``tag`` are mutually exclusive. """ imex_page = navigate_to(self.appliance.server, 'AutomateImportExport') assert imex_page.import_git.fill(self.fill_values_repo_add) imex_page.import_git.submit.click() imex_page.browser.plugin.ensure_page_safe(timeout='5m') git_select = self.create_view(GitImportSelectorView) assert git_select.is_displayed git_select.flash.assert_no_error() assert git_select.fill(self.fill_values_branch_select(branch, tag)) git_select.submit.click() git_select.browser.plugin.ensure_page_safe(timeout='5m') imex_page = self.create_view(AutomateImportExportView) assert imex_page.is_displayed imex_page.flash.assert_no_error() # Now find the domain in database namespaces = self.appliance.db.client['miq_ae_namespaces'] git_repositories = self.appliance.db.client['git_repositories'] none = None query = self.appliance.db.client.session\ .query( namespaces.id, namespaces.name, namespaces.description, git_repositories.url, namespaces.ref_type, namespaces.ref)\ .filter(namespaces.parent_id == none, namespaces.source == 'remote')\ .join(git_repositories, namespaces.git_repository_id == git_repositories.id) for id, name, description, url, git_type, git_type_value in query: if url != self.url: continue if not (git_type == 'branch' and branch == git_type_value or git_type == 'tag' and tag == git_type_value): continue # We have the domain from cfme.automate.explorer.domain import DomainCollection dc = DomainCollection(appliance=self.appliance) return dc.instantiate(db_id=id, name=name, description=description, git_checkout_type=git_type, git_checkout_value=git_type_value) else: raise ValueError( 'The domain imported was not found in the database!')
def test_domain_delete_from_table(request): domains = DomainCollection() generated = [] for _ in range(3): domain = domains.create(name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete_if_exists) generated.append(domain) domains.delete(*generated) for domain in generated: assert not domain.exists
def qe_ae_data(request, appliance, rake): appliance.ssh_client.put_file( cli_path.join("QECliTesting.yaml").strpath, "/root/QECliTesting.yaml") result = rake( "evm:automate:import DOMAIN=QECliTesting YAML_FILE=/root/QECliTesting.yaml PREVIEW=false " "ENABLED=true SYSTEM=false") assert result.success, result.output # Now we have to enable the domain to make it work. qe_cli_testing = DomainCollection(appliance).instantiate(name='QECliTesting') request.addfinalizer(qe_cli_testing.delete_if_exists) if not qe_cli_testing.enabled: with update(qe_cli_testing): qe_cli_testing.enabled = True
def test_domain_lock_unlock(request): domains = DomainCollection() domain = domains.create(name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete) ns1 = domain.namespaces.create(name='ns1') ns2 = ns1.namespaces.create(name='ns2') cls = ns2.classes.create(name='class1') cls.schema.add_field(name='myfield', type='Relationship') inst = cls.instances.create(name='inst') meth = cls.methods.create(name='meth', script='$evm') # Lock the domain domain.lock() # Check that nothing is editable # namespaces details = navigate_to(ns1, 'Details') assert not details.configuration.is_displayed details = navigate_to(ns2, 'Details') assert not details.configuration.is_displayed # class details = navigate_to(cls, 'Details') assert details.configuration.items == ['Copy selected Instances'] assert not details.configuration.item_enabled('Copy selected Instances') details.schema.select() assert not details.configuration.is_displayed # instance details = navigate_to(inst, 'Details') assert details.configuration.items == ['Copy this Instance'] # method details = navigate_to(meth, 'Details') assert details.configuration.items == ['Copy this Method'] # Unlock it domain.unlock() # Check that it is editable with update(ns1): ns1.name = 'UpdatedNs1' assert ns1.exists with update(ns2): ns2.name = 'UpdatedNs2' assert ns2.exists with update(cls): cls.name = 'UpdatedClass' assert cls.exists cls.schema.add_field(name='myfield2', type='Relationship') with update(inst): inst.name = 'UpdatedInstance' assert inst.exists with update(meth): meth.name = 'UpdatedMethod' assert meth.exists
def create_domain(request, appliance): """Create new domain and copy instance from ManageIQ to this domain""" dc = DomainCollection(appliance) new_domain = dc.create(name=fauxfactory.gen_alphanumeric(), enabled=True) request.addfinalizer(new_domain.delete_if_exists) instance = (dc.instantiate(name='ManageIQ') .namespaces.instantiate(name='Service') .namespaces.instantiate(name='Provisioning') .namespaces.instantiate(name='StateMachines') .classes.instantiate(name='ServiceProvisionRequestApproval') .instances.instantiate(name='Default')) instance.copy_to(new_domain) return new_domain
def import_domain_from(self, branch=None, tag=None): """Import the domain from git using the Import/Export UI. Args: branch: If you import from a branch, specify the origin/branchname tag: If you import from a tag, specify its name. Returns: Instance of :py:class:`cfme.automate.explorer.domain.Domain` **Important!** ``branch`` and ``tag`` are mutually exclusive. """ imex_page = navigate_to(self.appliance.server, 'AutomateImportExport') assert imex_page.import_git.fill(self.fill_values_repo_add) imex_page.import_git.submit.click() imex_page.browser.plugin.ensure_page_safe(timeout='5m') git_select = self.create_view(GitImportSelectorView) assert git_select.is_displayed git_select.flash.assert_no_error() assert git_select.fill(self.fill_values_branch_select(branch, tag)) git_select.submit.click() git_select.browser.plugin.ensure_page_safe(timeout='5m') imex_page = self.create_view(AutomateImportExportView) assert imex_page.is_displayed imex_page.flash.assert_no_error() # Now find the domain in database namespaces = self.appliance.db.client['miq_ae_namespaces'] git_repositories = self.appliance.db.client['git_repositories'] none = None query = self.appliance.db.client.session\ .query( namespaces.id, namespaces.name, namespaces.description, git_repositories.url, namespaces.ref_type, namespaces.ref)\ .filter(namespaces.parent_id == none, namespaces.source == 'remote')\ .join(git_repositories, namespaces.git_repository_id == git_repositories.id) for id, name, description, url, git_type, git_type_value in query: if url != self.url: continue if not ( git_type == 'branch' and branch == git_type_value or git_type == 'tag' and tag == git_type_value): continue # We have the domain from cfme.automate.explorer.domain import DomainCollection dc = DomainCollection(appliance=self.appliance) return dc.instantiate( db_id=id, name=name, description=description, git_checkout_type=git_type, git_checkout_value=git_type_value) else: raise ValueError('The domain imported was not found in the database!')
def test_domain_delete_from_table(request): domains = DomainCollection() generated = [] for _ in range(3): domain = domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(domain.delete_if_exists) generated.append(domain) domains.delete(*generated) for domain in generated: assert not domain.exists
def test_domain_present(domain_name, soft_assert): """This test verifies presence of domains that are included in the appliance. Prerequisities: * Clean appliance. Steps: * Open the Automate Explorer. * Verify that all of the required domains are present. """ dc = DomainCollection() domain = dc.instantiate(name=domain_name) soft_assert(domain.exists, "Domain {} does not exist!".format(domain_name)) soft_assert(domain.locked, "Domain {} is not locked!".format(domain_name)) soft_assert( dbq.check_domain_enabled(domain_name), "Domain {} is not enabled!".format(domain_name))
def test_domain_present(domain_name, soft_assert, appliance): """This test verifies presence of domains that are included in the appliance. Prerequisities: * Clean appliance. Steps: * Open the Automate Explorer. * Verify that all of the required domains are present. """ dc = DomainCollection() domain = dc.instantiate(name=domain_name) soft_assert(domain.exists, "Domain {} does not exist!".format(domain_name)) soft_assert(domain.locked, "Domain {} is not locked!".format(domain_name)) soft_assert(appliance.check_domain_enabled(domain_name), "Domain {} is not enabled!".format(domain_name))
def copy_instance(request, copy_domain, appliance): miq_domain = DomainCollection(appliance).instantiate(name='ManageIQ') instance = miq_domain\ .namespaces.instantiate(name='System')\ .classes.instantiate(name='Request')\ .instances.instantiate(name='InspectMe') instance.copy_to(copy_domain)
def original_request_class(): return DomainCollection().instantiate(name='ManageIQ')\ .namespaces.instantiate(name='Cloud')\ .namespaces.instantiate(name='VM')\ .namespaces.instantiate(name='Provisioning')\ .namespaces.instantiate(name='StateMachines')\ .classes.instantiate(name='Methods')
def test_domain_crud(request, enabled): domains = DomainCollection() domain = domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=enabled) request.addfinalizer(domain.delete_if_exists) assert domain.exists # TODO: Verify details updated_description = "editdescription{}".format(fauxfactory.gen_alpha()) with update(domain): domain.description = updated_description assert domain.exists domain.delete(cancel=True) assert domain.exists domain.delete() assert not domain.exists
def test_create_snapshot_via_ae(appliance, request, domain, small_test_vm): """This test checks whether the vm.create_snapshot works in AE. Prerequisities: * A VMware provider * A VM that has been discovered by CFME Steps: * Clone the Request class inside the System namespace into a new domain * Add a method named ``snapshot`` and insert the provided code there. * Add an instance named ``snapshot`` and set the methd from previous step as ``meth5`` * Run the simulation of the method against the VM, preferably setting ``snap_name`` to something that can be checked * Wait until snapshot with such name appears. """ # PREPARE file = data_path.join("ui").join("automate").join( "test_create_snapshot_via_ae.rb") with file.open("r") as f: method_contents = f.read() miq_domain = DomainCollection(appliance).instantiate(name='ManageIQ') miq_class = miq_domain.namespaces.instantiate( name='System').classes.instantiate(name='Request') miq_class.copy_to(domain) request_cls = domain.namespaces.instantiate( name='System').classes.instantiate(name='Request') request.addfinalizer(request_cls.delete) method = request_cls.methods.create(name="snapshot", location='inline', script=method_contents) request.addfinalizer(method.delete) instance = request_cls.instances.create( name="snapshot", fields={"meth5": { 'value': "snapshot" }}) request.addfinalizer(instance.delete) # SIMULATE snap_name = fauxfactory.gen_alpha() snapshot = InfraVm.Snapshot(name=snap_name, parent_vm=small_test_vm) simulate(appliance=appliance, instance="Request", request="snapshot", target_type='VM and Instance', target_object=small_test_vm.name, execute_methods=True, attributes_values={"snap_name": snap_name}) wait_for(lambda: snapshot.exists, timeout="2m", delay=10, fail_func=small_test_vm.provider.browser.refresh, handle_exception=True, message="Waiting for snapshot create") # Clean up if it appeared snapshot.delete()
def test_domain_crud(request, enabled): domains = DomainCollection() domain = domains.create(name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=enabled) request.addfinalizer(domain.delete_if_exists) assert domain.exists view = navigate_to(domain, 'Details') if enabled: assert 'Disabled' not in view.title.text else: assert 'Disabled' in view.title.text updated_description = "editdescription{}".format(fauxfactory.gen_alpha()) with update(domain): domain.description = updated_description view = navigate_to(domain, 'Edit') assert view.description.value == updated_description assert domain.exists domain.delete(cancel=True) assert domain.exists domain.delete() assert not domain.exists
def test_domain_crud(request, enabled): domains = DomainCollection() domain = domains.create( name=fauxfactory.gen_alpha(), description=fauxfactory.gen_alpha(), enabled=enabled) request.addfinalizer(domain.delete_if_exists) assert domain.exists view = navigate_to(domain, 'Details') if enabled: assert 'Disabled' not in view.title.text else: assert 'Disabled' in view.title.text updated_description = "editdescription{}".format(fauxfactory.gen_alpha()) with update(domain): domain.description = updated_description view = navigate_to(domain, 'Edit') assert view.description.value == updated_description assert domain.exists domain.delete(cancel=True) assert domain.exists domain.delete() assert not domain.exists
def test_domain_present(domain_name, soft_assert, appliance): """This test verifies presence of domains that are included in the appliance. Prerequisities: * Clean appliance. Steps: * Open the Automate Explorer. * Verify that all of the required domains are present. Polarion: assignee: dmisharo casecomponent: Automate caseimportance: critical initialEstimate: 1/60h testtype: functional """ dc = DomainCollection(appliance) domain = dc.instantiate(name=domain_name) soft_assert(domain.exists, "Domain {} does not exist!".format(domain_name)) soft_assert(domain.locked, "Domain {} is not locked!".format(domain_name)) soft_assert( appliance.check_domain_enabled( domain_name), "Domain {} is not enabled!".format(domain_name))
def test_domain_present(domain_name, soft_assert, appliance): """This test verifies presence of domains that are included in the appliance. Prerequisities: * Clean appliance. Steps: * Open the Automate Explorer. * Verify that all of the required domains are present. Polarion: assignee: dmisharo casecomponent: automate caseimportance: critical initialEstimate: 1/60h testtype: functional """ dc = DomainCollection(appliance) domain = dc.instantiate(name=domain_name) soft_assert(domain.exists, "Domain {} does not exist!".format(domain_name)) soft_assert(domain.locked, "Domain {} is not locked!".format(domain_name)) soft_assert( appliance.check_domain_enabled( domain_name), "Domain {} is not enabled!".format(domain_name))
def test_domain_name_wrong(): domains = DomainCollection() with error.expected('Name may contain only'): domains.create(name='with space')
def domain_collection(appliance): return DomainCollection(appliance)
def domain(request): domain = DomainCollection().create(name=fauxfactory.gen_alphanumeric(), enabled=True) request.addfinalizer(domain.delete_if_exists) return domain
def domain_collection(): return DomainCollection()
def copy_domain(request, appliance): domain = DomainCollection(appliance).create(name="new_domain", enabled=True) request.addfinalizer(domain.delete_if_exists) return domain
def domain(request, appliance): dom = DomainCollection(appliance).create(name=fauxfactory.gen_alpha(), enabled=True) request.addfinalizer(dom.delete_if_exists) return dom