def test_superadmin_tenant_crud(request): """Test suppose to verify CRUD operations for CFME tenants Prerequisities: * This test is not depending on any other test and can be executed against fresh appliance. Steps: * Create tenant * Update description of tenant * Update name of tenat * Delete tenant """ tenant = ac.Tenant( name='tenant1' + fauxfactory.gen_alphanumeric(), description='tenant1 description') @request.addfinalizer def _delete_tenant(): if tenant.exists: tenant.delete() tenant.create() with update(tenant): tenant.description = tenant.description + "edited" with update(tenant): tenant.name = tenant.name + "edited" tenant.delete()
def test_repository_crud(soft_assert, random_string, request): repo_name = 'Test Repo {}'.format(random_string) repo = repositories.Repository(repo_name, '//testhost/share/path') request.addfinalizer(repo.delete) # create repo.create() # read assert repo.exists # update with update(repo): repo.name = 'Updated {}'.format(repo_name) with soft_assert.catch_assert(): assert repo.exists, 'Repository rename failed' # Only change the name back if renaming succeeded with update(repo): repo.name = repo_name # delete repo.delete() try: wait_for(lambda: not repo.exists) except TimedOutError: raise AssertionError('failed to delete repository')
def test_hawkular_crud(provider): """Test provider add with good credentials. """ with sel.ajax_timeout(120): provider.create(cancel=False, validate_credentials=True) # UI validation, checks whether data provided from Hawkular provider matches data in UI provider.validate_stats(ui=True) # DB validation, checks whether data provided from Hawkular provider matches data in DB provider.validate_stats() # validates Properties section of provider's summary page provider.validate_properties() # validates that provider is refreshed in DB and in UI assert provider.is_refreshed(method='ui'), "Provider is not refreshed in UI" assert provider.is_refreshed(method='db'), "Provider is not refreshed in DB" old_name = provider.name with update(provider): provider.name = str(uuid.uuid4()) # random uuid with update(provider): provider.name = old_name # old name provider.delete(cancel=False) provider.wait_for_delete()
def test_superadmin_tenant_project_crud(request): """Test suppose to verify CRUD operations for CFME projects Prerequisities: * This test is not depending on any other test and can be executed against fresh appliance. Steps: * Create tenant * Create project as child to tenant * Update description of project * Update name of project * Delete project * Delete tenant """ tenant = Tenant(name="tenant1" + fauxfactory.gen_alphanumeric(), description="tenant1 description") project = Project( name="project1" + fauxfactory.gen_alphanumeric(), description="project1 description", parent_tenant=tenant ) @request.addfinalizer def _delete_tenant_and_project(): for item in [project, tenant]: if item.exists: item.delete() tenant.create() project.create() with update(project): project.description = project.description + "edited" with update(project): project.name = project.name + "edited" project.delete() tenant.delete()
def test_vm_analysis_profile_crud(): """CRUD for VM analysis profiles.""" p = VMAnalysisProfile(generate_random_string(), generate_random_string(), files=["asdf", "dfg"]) p.create() with update(p): p.files = ["qwer"] with update(p): p.categories = ["check_system"] p.delete()
def test_vm_analysis_profile_crud(): """CRUD for VM analysis profiles.""" p = VMAnalysisProfile(fauxfactory.gen_alphanumeric(), fauxfactory.gen_alphanumeric(), files=["asdf", "dfg"]) p.create() with update(p): p.files = ["qwer"] with update(p): p.categories = ["check_system"] p.delete()
def test_namespace_crud(namespace): namespace.create() old_name = namespace.name with update(namespace): namespace.name = fauxfactory.gen_alphanumeric(8) with update(namespace): namespace.name = old_name namespace.delete() assert not namespace.exists()
def test_display_name_unset_from_ui(request, a_class): a_class.create() request.addfinalizer(a_class.delete) with update(a_class): a_class.display_name = generate_random_string() assert a_class.exists with update(a_class): a_class.display_name = "" assert a_class.exists
def test_display_name_unset_from_ui(request, an_instance): an_instance.create() request.addfinalizer(an_instance.delete) with update(an_instance): an_instance.display_name = generate_random_string() assert an_instance.exists with update(an_instance): an_instance.display_name = "" assert an_instance.exists
def test_class_crud(a_class): a_class.create() orig = a_class.description with update(a_class): a_class.description = 'edited' with update(a_class): a_class.description = orig a_class.delete() assert not a_class.exists()
def test_namespace_crud(namespace): namespace.create() old_name = namespace.name with update(namespace): namespace.name = generate_random_string(8) with update(namespace): namespace.name = old_name namespace.delete() assert not namespace.exists()
def test_display_name_unset_from_ui(request, an_instance): an_instance.create() request.addfinalizer(an_instance.delete) with update(an_instance): an_instance.display_name = fauxfactory.gen_alphanumeric() assert an_instance.exists with update(an_instance): an_instance.display_name = "" assert an_instance.exists
def test_method_crud(a_method): a_method.create() origname = a_method.name with update(a_method): a_method.name = generate_random_string(8) a_method.data = "bar" with update(a_method): a_method.name = origname a_method.delete() assert not a_method.exists()
def test_instance_display_name_unset_from_ui(request, klass): instance = klass.instances.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric()) with update(instance): instance.display_name = fauxfactory.gen_alphanumeric() assert instance.exists with update(instance): instance.display_name = "" assert instance.exists
def test_method_crud(a_method): a_method.create() origname = a_method.name with update(a_method): a_method.name = fauxfactory.gen_alphanumeric(8) a_method.data = "bar" with update(a_method): a_method.name = origname a_method.delete() assert not a_method.exists()
def test_instance_crud(an_instance): an_instance.create() origname = an_instance.name with update(an_instance): an_instance.name = generate_random_string(8) an_instance.description = "updated" with update(an_instance): an_instance.name = origname an_instance.delete() assert not an_instance.exists()
def test_instance_crud(an_instance): an_instance.create() origname = an_instance.name with update(an_instance): an_instance.name = fauxfactory.gen_alphanumeric(8) an_instance.description = "updated" with update(an_instance): an_instance.name = origname an_instance.delete() assert not an_instance.exists()
def test_vm_analysis_profile_crud(): """CRUD for VM analysis profiles.""" p = AnalysisProfile(name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric(), profile_type='VM', files=["asdf", "dfg"]) p.create() with update(p): p.files = ["qwer"] with update(p): p.categories = ["check_system"] p.delete()
def test_provider_edit(provider_crud): """ Tests that editing a management system shows the proper detail after an edit.""" provider_crud.create() old_name = provider_crud.name with update(provider_crud) as provider_crud: provider_crud.name = str(uuid.uuid4()) # random uuid flash.assert_message_match('Cloud Provider "%s" was saved' % provider_crud.name) with update(provider_crud) as provider_crud: provider_crud.name = old_name # old name flash.assert_message_match('Cloud Provider "%s" was saved' % provider_crud.name)
def test_class_display_name_unset_from_ui(request, namespace): a_class = namespace.classes.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) with update(a_class): a_class.display_name = fauxfactory.gen_alphanumeric() assert a_class.exists with update(a_class): a_class.display_name = "" assert a_class.exists
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 test_instance_crud(klass): instance = klass.instances.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) orig = instance.description with update(instance): instance.description = 'edited' with update(instance): instance.description = orig instance.delete() assert not instance.exists
def test_class_crud(namespace): a_class = namespace.classes.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), description=fauxfactory.gen_alphanumeric() ) orig = a_class.description with update(a_class): a_class.description = 'edited' with update(a_class): a_class.description = orig a_class.delete() assert not a_class.exists
def test_provider_crud(provider_crud): """ Tests that a provider can be added """ provider_crud.create() provider_crud.validate() old_name = provider_crud.name with update(provider_crud): provider_crud.name = str(uuid.uuid4()) # random uuid with update(provider_crud): provider_crud.name = old_name # old name provider_crud.delete(cancel=False) provider.wait_for_provider_delete(provider_crud)
def test_tenant_crud(tenant): """ Tests tenant create and delete Metadata: test_flag: tenant """ tenant.create(cancel=True) assert not tenant.exists tenant.create(wait=True) assert tenant.exists with update(tenant): tenant.name = fauxfactory.gen_alphanumeric(8) tenant.wait_for_appear() assert tenant.exists tenant.delete(from_details=False, cancel=True) assert tenant.exists # BZ#1411112 Delete/update cloud tenant # not reflected in UI in cloud tenant list tenant.delete(from_details=True, cancel=False, wait=True) assert not tenant.exists
def test_check_package_presence(request, fleecing_vm, ssh_client, analysis_profile): """This test checks compliance by presence of a certain cfme-appliance package which is expected to be present on an appliance.""" # TODO: If we step out from provisioning a full appliance for fleecing, this might need revisit condition = VMCondition( "Compliance testing condition {}".format(fauxfactory.gen_alphanumeric(8)), expression=("fill_find(field=VM and Instance.Guest Applications : Name, " "skey=STARTS WITH, value=cfme-appliance, check=Check Count, ckey= = , cvalue=1)") ) request.addfinalizer(lambda: diaper(condition.delete)) policy = VMCompliancePolicy("Compliance {}".format(fauxfactory.gen_alphanumeric(8))) request.addfinalizer(lambda: diaper(policy.delete)) policy.create() policy.assign_conditions(condition) profile = PolicyProfile( "Compliance PP {}".format(fauxfactory.gen_alphanumeric(8)), policies=[policy] ) request.addfinalizer(lambda: diaper(profile.delete)) profile.create() fleecing_vm.assign_policy_profiles(profile.description) request.addfinalizer(lambda: fleecing_vm.unassign_policy_profiles(profile.description)) with update(analysis_profile): analysis_profile.categories = [ "check_services", "check_accounts", "check_software", "check_vmconfig", "check_system"] do_scan(fleecing_vm) assert fleecing_vm.check_compliance_and_wait()
def test_check_files(request, fleecing_vm, ssh_client, analysis_profile): """This test checks presence and contents of a certain file. Due to caching, an existing file is checked. """ check_file_name = "/etc/sudo.conf" check_file_contents = "sudoers_policy" # The file contains: `Plugin sudoers_policy sudoers.so` condition = VMCondition( "Compliance testing condition {}".format(fauxfactory.gen_alphanumeric(8)), expression=("fill_find(VM and Instance.Files : Name, " "=, {}, Check Any, Contents, INCLUDES, {})".format( check_file_name, check_file_contents)) ) request.addfinalizer(lambda: diaper(condition.delete)) policy = VMCompliancePolicy("Compliance {}".format(fauxfactory.gen_alphanumeric(8))) request.addfinalizer(lambda: diaper(policy.delete)) policy.create() policy.assign_conditions(condition) profile = PolicyProfile( "Compliance PP {}".format(fauxfactory.gen_alphanumeric(8)), policies=[policy] ) request.addfinalizer(lambda: diaper(profile.delete)) profile.create() fleecing_vm.assign_policy_profiles(profile.description) request.addfinalizer(lambda: fleecing_vm.unassign_policy_profiles(profile.description)) with update(analysis_profile): analysis_profile.files = [(check_file_name, True)] analysis_profile.categories = [ "check_services", "check_accounts", "check_software", "check_vmconfig", "check_system"] do_scan(fleecing_vm, ("Configuration", "Files")) assert fleecing_vm.check_compliance_and_wait()
def test_dashboard_crud(): d = Dashboard( generate_random_string(), "EvmGroup-administrator", generate_random_string(), locked=False, widgets=["Top CPU Consumers (weekly)", "Vendor and Guest OS Chart"] ) d.create() with update(d): d.locked = True with update(d): d.locked = False with update(d): d.widgets = "Top Storage Consumers" d.delete()
def test_user_change_password(request): user = ac.User( name="user {}".format(fauxfactory.gen_alphanumeric()), credential=Credential( principal="user_principal_{}".format(fauxfactory.gen_alphanumeric()), secret="very_secret", verify_secret="very_secret" ), email="*****@*****.**", group=usergrp, ) user.create() request.addfinalizer(user.delete) request.addfinalizer(login.login_admin) login.logout() assert not login.logged_in() login.login(user.credential.principal, user.credential.secret) assert login.current_full_name() == user.name login.login_admin() with update(user): user.credential = Credential( principal=user.credential.principal, secret="another_very_secret", verify_secret="another_very_secret", ) login.logout() assert not login.logged_in() login.login(user.credential.principal, user.credential.secret) assert login.current_full_name() == user.name
def test_embedded_ansible_credential_crud(request, wait_for_ansible, credential_type, credentials): credentials_collection = CredentialsCollection() credential = credentials_collection.create( "{}_credential_{}".format(credential_type, fauxfactory.gen_alpha()), credential_type, **credentials ) updated_value = "edited_{}".format(fauxfactory.gen_alpha()) with update(credential): if credential.credential_type != "Amazon": credential.username = updated_value else: credential.access_key = updated_value view = navigate_to(credential, "Details") def wait_for_changes(field_name): wait_for( lambda: view.credential_options.get_text_of(field_name) == updated_value, fail_func=view.browser.selenium.refresh, delay=10, timeout=60 ) if credential.credential_type == "Amazon": wait_for_changes("Access Key") else: wait_for_changes("Username") credential.delete()
def test_custom_report_crud(custom_report): custom_report.create() with update(custom_report): custom_report.title += fauxfactory.gen_alphanumeric() custom_report.queue(wait_for_finish=True) for report in custom_report.get_saved_reports(): report.data # touch the results custom_report.delete()
def test_edit_storage_chargeback(chargeback_storage_rate): chargeback_storage_rate.create() with update(chargeback_storage_rate): chargeback_storage_rate.description = chargeback_storage_rate.description + "-edited" chargeback_storage_rate.fields = { 'Fixed Storage Cost 1': with_random_per_time(fixed_rate='500'), 'Allocated Disk Storage': with_random_per_time(fixed_rate='100'), }
def test_pxe_server_crud(pxe_name, pxe_server_crud): """ Basic Add test for PXE server including refresh. """ pxe_server_crud.create(refresh_timeout=300) with update(pxe_server_crud): pxe_server_crud.name = pxe_server_crud.name + "_update" pxe_server_crud.delete(cancel=False)
def test_user_crud(): user = new_user() user.create() with update(user): user.name = user.name + "edited" copied_user = user.copy() copied_user.delete() user.delete()
def test_custom_report_crud(custom_report): custom_report.create() with update(custom_report): custom_report.title += fauxfactory.gen_alphanumeric() custom_report.queue(wait_for_finish=True) for report in custom_report.get_saved_reports(): assert hasattr(report, 'data') custom_report.delete()
def test_timeprofile_crud(): timeprofile = new_timeprofile() timeprofile.create() with update(timeprofile): timeprofile.scope = 'All Users' copied_timeprofile = timeprofile.copy() copied_timeprofile.delete() timeprofile.delete()
def test_category_crud(): cg = Category(name=generate_lowercase_random_string(size=8), description=generate_random_string(size=32), display_name=generate_random_string(size=32)) cg.create() with update(cg): cg.description = generate_random_string(size=32) cg.delete(cancel=False)
def test_role_crud(): role = new_role() role.create() with update(role): role.name = role.name + "edited" copied_role = role.copy() copied_role.delete() role.delete()
def test_config_manager_edit(request, config_manager): new_name = fauxfactory.gen_alpha(8) old_name = config_manager.name with update(config_manager): config_manager.name = new_name request.addfinalizer(lambda: config_manager.update(updates={'name': old_name})) assert (config_manager.name == new_name and config_manager.exists, "Failed to update configuration manager's name")
def test_tag_crud(category): tag = Tag(name=generate_lowercase_random_string(size=8), display_name=generate_random_string(size=32), category=category) tag.create() with update(tag): tag.display_name = generate_random_string(size=32) tag.delete(cancel=False)
def test_category_crud(): cg = Category(name=fauxfactory.gen_alphanumeric(8).lower(), description=fauxfactory.gen_alphanumeric(32), display_name=fauxfactory.gen_alphanumeric(32)) cg.create() with update(cg): cg.description = fauxfactory.gen_alphanumeric(32) cg.delete(cancel=False)
def test_condition_crud(condition): # CR condition.create() # U with update(condition): condition.notes = "Modified!" # D condition.delete()
def test_edit_compute_chargeback(chargeback_compute_rate): chargeback_compute_rate.create() with update(chargeback_compute_rate): chargeback_compute_rate.description = chargeback_compute_rate.description + "-edited" chargeback_compute_rate.fields = { 'Fixed Compute Cost 1': with_random_per_time(fixed_rate='500'), 'Allocated CPU Count': with_random_per_time(fixed_rate='100'), }
def test_tag_crud(category): tag = Tag(name=fauxfactory.gen_alphanumeric(8).lower(), display_name=fauxfactory.gen_alphanumeric(32), category=category) tag.create() with update(tag): tag.display_name = fauxfactory.gen_alphanumeric(32) tag.delete(cancel=False)
def test_update_service_dialog(): dialog = ServiceDialog(label=rand.generate_random_string(), description="my dialog", submit=True, cancel=True) dialog.create() with update(dialog): dialog.description = "my edited description"
def test_provision_from_template_with_attached_disks( request, setup_provider, provider, vm_name, provisioning, disks, soft_assert, domain, modified_request_class, copy_domains): """ Tests provisioning from a template and attaching disks Metadata: test_flag: provision """ image = provisioning['image']['name'] note = ('Testing provisioning from image {} to vm {} on provider {}'.format( image, vm_name, provider.key)) DEVICE_NAME = "/dev/sd{}" device_mapping = [] with provider.mgmt.with_volumes(1, n=disks) as volumes: for i, volume in enumerate(volumes): device_mapping.append((volume, DEVICE_NAME.format(chr(ord("b") + i)))) # Set up automate method = modified_request_class.methods.instantiate(name="openstack_PreProvision") with update(method): disk_mapping = [] for mapping in device_mapping: disk_mapping.append(ONE_FIELD.format(*mapping)) method.script = VOLUME_METHOD.format(", ".join(disk_mapping)) def _finish_method(): with update(method): method.script = """prov = $evm.root["miq_provision"]""" request.addfinalizer(_finish_method) instance = Instance.factory(vm_name, provider, image) request.addfinalizer(instance.delete_from_provider) inst_args = { 'email': '*****@*****.**', 'first_name': 'Image', 'last_name': 'Provisioner', 'notes': note, 'instance_type': provisioning['instance_type'], "availability_zone": provisioning["availability_zone"] if provider.type != "azure" else provisioning["av_set"], 'security_groups': [provisioning['security_group']], 'guest_keypair': provisioning['guest_keypair'] } if isinstance(provider, OpenStackProvider): inst_args['cloud_network'] = provisioning['cloud_network'] instance.create(**inst_args) for volume_id in volumes: soft_assert(vm_name in provider.mgmt.volume_attachments(volume_id)) for volume, device in device_mapping: soft_assert(provider.mgmt.volume_attachments(volume)[vm_name] == device) instance.delete_from_provider() # To make it possible to delete the volume wait_for(lambda: not instance.does_vm_exist_on_provider(), num_sec=180, delay=5)
def test_provision_with_boot_volume(request, setup_provider, provider, vm_name, soft_assert, domain, copy_domains, provisioning, modified_request_class): """ Tests provisioning from a template and attaching one booting volume. Metadata: test_flag: provision, volumes """ image = provisioning['image']['name'] note = ('Testing provisioning from image {} to vm {} on provider {}'.format( image, vm_name, provider.key)) with provider.mgmt.with_volume(1, imageRef=provider.mgmt.get_template_id(image)) as volume: # Set up automate method = modified_request_class.methods.instantiate(name="openstack_CustomizeRequest") with update(method): method.script = dedent('''\ $evm.root["miq_provision"].set_option( :clone_options, {{ :image_ref => nil, :block_device_mapping_v2 => [{{ :boot_index => 0, :uuid => "{}", :device_name => "vda", :source_type => "volume", :destination_type => "volume", :delete_on_termination => false }}] }} ) '''.format(volume)) @request.addfinalizer def _finish_method(): with update(method): method.script = """prov = $evm.root["miq_provision"]""" instance = Instance.factory(vm_name, provider, image) request.addfinalizer(instance.delete_from_provider) inst_args = { 'email': '*****@*****.**', 'first_name': 'Image', 'last_name': 'Provisioner', 'notes': note, 'instance_type': provisioning['instance_type'], "availability_zone": provisioning["availability_zone"], 'security_groups': [provisioning['security_group']], 'guest_keypair': provisioning['guest_keypair'] } if isinstance(provider, OpenStackProvider): inst_args['cloud_network'] = provisioning['cloud_network'] instance.create(**inst_args) soft_assert(vm_name in provider.mgmt.volume_attachments(volume)) soft_assert(provider.mgmt.volume_attachments(volume)[vm_name] == "vda") instance.delete_from_provider() # To make it possible to delete the volume wait_for(lambda: not instance.does_vm_exist_on_provider(), num_sec=180, delay=5)
def test_host_analysis_profile_crud(): """CRUD for Host analysis profiles.""" p = HostAnalysisProfile(fauxfactory.gen_alphanumeric(), fauxfactory.gen_alphanumeric(), files=["asdf", "dfg"]) p.create() with update(p): p.files = ["qwer"] p.delete()
def test_provider_crud(provider): """ Tests provider add with good credentials Metadata: test_flag: crud """ provider.create() provider.validate_stats(ui=True) old_name = provider.name with update(provider): provider.name = str(uuid.uuid4()) # random uuid with update(provider): provider.name = old_name # old name provider.delete(cancel=False) provider.wait_for_delete()
def test_orchestration_template_crud(provisioning): template_type = provisioning['stack_provisioning']['template_type'] template = OrchestrationTemplate(template_type=template_type, template_name=fauxfactory.gen_alphanumeric(), description="my template") template.create(METHOD_TORSO) with update(template): template.description = "my edited description" template.delete()
def test_method_crud(request, klass): method = klass.methods.create( name=fauxfactory.gen_alphanumeric(), display_name=fauxfactory.gen_alphanumeric(), location='inline', script='$evm.log(:info, ":P")', ) assert method.exists origname = method.name with update(method): method.name = fauxfactory.gen_alphanumeric(8) method.script = "bar" assert method.exists with update(method): method.name = origname assert method.exists method.delete() assert not method.exists
def test_policy_crud(policy_class): policy = policy_class(fauxfactory.gen_alphanumeric()) # CR policy.create() # U with update(policy): policy.notes = "Modified!" # D policy.delete()
def test_edit_storage_chargeback(): scb = new_storage_rate() scb.create() with update(scb): scb.description = scb.description + "-edited" scb.storage_fixed_2 = (2000, cb.MONTHLY) scb.storage_alloc = (3000, cb.WEEKLY) scb.storage_used = (6000, cb.MONTHLY) flash.assert_message_match('Chargeback Rate "%s" was saved' % scb.description)
def test_policy_profile_crud(random_vm_control_policy, random_host_control_policy): profile = policy_profiles.PolicyProfile( fauxfactory.gen_alphanumeric(), policies=[random_vm_control_policy, random_host_control_policy]) profile.create() with update(profile): profile.notes = "Modified!" profile.delete()
def test_edit_storage_chargeback(): scb = new_storage_rate() scb.create() with update(scb): scb.description = scb.description + "-edited" scb.fields = {'Fixed Storage Cost 1': {'per_time': random.choice(per_time), 'fixed_rate': '500'}, 'Allocated Disk Storage': {'per_time': random.choice(per_time), 'fixed_rate': '100'}}
def test_edit_compute_chargeback(): ccb = new_compute_rate() ccb.create() with update(ccb): ccb.description = ccb.description + "-edited" ccb.fields = {'Fixed Compute Cost 1': {'per_time': random.choice(per_time), 'fixed_rate': '500'}, 'Allocated CPU Count': {'per_time': random.choice(per_time), 'fixed_rate': '100'}}
def test_provision_with_additional_volume(request, testing_instance, provider, soft_assert, copy_domains, domain, modified_request_class): """ Tests provisioning with setting specific image from AE and then also making it create and attach an additional 3G volume. Metadata: test_flag: provision, volumes """ instance, inst_args, image = testing_instance # Set up automate method = modified_request_class.methods.instantiate(name="openstack_CustomizeRequest") try: image_id = provider.mgmt.get_template_id(provider.data["small_template"]) except KeyError: pytest.skip("No small_template in provider adta!") with update(method): method.script = dedent('''\ $evm.root["miq_provision"].set_option( :clone_options, {{ :image_ref => nil, :block_device_mapping_v2 => [{{ :boot_index => 0, :uuid => "{}", :device_name => "vda", :source_type => "image", :destination_type => "volume", :volume_size => 3, :delete_on_termination => false }}] }} ) '''.format(image_id)) def _finish_method(): with update(method): method.script = """prov = $evm.root["miq_provision"]""" request.addfinalizer(_finish_method) instance.create(**inst_args) prov_instance = provider.mgmt._find_instance_by_name(vm_name) try: assert hasattr(prov_instance, 'os-extended-volumes:volumes_attached') volumes_attached = getattr(prov_instance, 'os-extended-volumes:volumes_attached') assert len(volumes_attached) == 1 volume_id = volumes_attached[0]["id"] assert provider.mgmt.volume_exists(volume_id) volume = provider.mgmt.get_volume(volume_id) assert volume.size == 3 finally: instance.delete_from_provider() wait_for(lambda: not instance.does_vm_exist_on_provider(), num_sec=180, delay=5) if "volume_id" in locals(): # To handle the case of 1st or 2nd assert if provider.mgmt.volume_exists(volume_id): provider.mgmt.delete_volume(volume_id)
def modify_instance(create_domain): """Modify the instance in new domain to change it to manual approval instead of auto""" instance = create_domain.namespaces.instantiate(name='Service')\ .namespaces.instantiate(name='Provisioning')\ .namespaces.instantiate(name='StateMachines')\ .classes.instantiate(name='ServiceProvisionRequestApproval')\ .instances.instantiate(name='Default') with update(instance): instance.fields = {"approval_type ": {"value": "manual"}}
def test_provider_crud(provider): """Tests provider add with good credentials Metadata: test_flag: crud """ provider.create() # Fails on upstream, all provider types - BZ1087476 provider.validate(db=False) old_name = provider.name with update(provider): provider.name = str(uuid.uuid4()) # random uuid with update(provider): provider.name = old_name # old name provider.delete(cancel=False) provider.wait_for_delete()
def test_button_group_crud(request): buttongroup = ButtonGroup(text=fauxfactory.gen_alphanumeric(), hover="btn_hvr", type=ButtonGroup.SERVICE) request.addfinalizer(buttongroup.delete_if_exists) buttongroup.create() with update(buttongroup): buttongroup.hover = "edit_desc_{}".format( fauxfactory.gen_alphanumeric()) buttongroup.delete()