def vm_module_streams(repos_collection_for_module_streams): """Virtual machine registered in satellite without katello-agent installed""" with VirtualMachine(distro=repos_collection_for_module_streams.distro ) as vm_module_streams: repos_collection_for_module_streams.setup_virtual_machine( vm_module_streams, install_katello_agent=False) add_remote_execution_ssh_key(vm_module_streams.ip_addr) yield vm_module_streams
def test_positive_view_vdc_subscription_products(session): """Ensure that Virtual Datacenters subscription provided products is not empty and that a consumed product exist in content products. :id: cc4593f0-66ab-4bf6-87d1-d4bd9c89eba5 :customerscenario: true :steps: 1. Upload a manifest with Virtual Datacenters subscription 2. Enable a products provided by Virtual Datacenters subscription, and synchronize the auto created repository 3. Create content view with the product repository, and publish it 4. Create a lifecycle environment and promote the content view to it. 5. Create an activation key with the content view and lifecycle environment 6. Subscribe a host to the activation key 7. Goto Hosts -> Content hosts and select the created content host 8. Attach VDC subscription to content host 9. Goto Content -> Red Hat Subscription 10. Select Virtual Datacenters subscription :expectedresults: 1. assert that the provided products is not empty 2. assert that the enabled product is in subscription Product Content :BZ: 1366327 :CaseLevel: System """ org = entities.Organization().create() lce = entities.LifecycleEnvironment(organization=org).create() repos_collection = RepositoryCollection( distro=DISTRO_RHEL7, repositories=[RHELAnsibleEngineRepository(cdn=True)] ) product_name = repos_collection.rh_repos[0].data['product'] repos_collection.setup_content( org.id, lce.id, upload_manifest=True, rh_subscriptions=[DEFAULT_SUBSCRIPTION_NAME] ) with VirtualMachine() as vm: setup_virtual_machine( vm, org.label, activation_key=repos_collection.setup_content_data['activation_key']['name'], install_katello_agent=False, ) with session: session.organization.select(org.name) session.contenthost.add_subscription(vm.hostname, VDC_SUBSCRIPTION_NAME) provided_products = session.subscription.provided_products(VDC_SUBSCRIPTION_NAME) # ensure that subscription provided products list is not empty and that the product is # in the provided products. assert provided_products and product_name in provided_products content_products = session.subscription.content_products(VDC_SUBSCRIPTION_NAME) # ensure that subscription enabled products list is not empty and that product is in # content products. assert content_products and product_name in content_products
def test_positive_chost_previous_env(self): """Check if the applicable errata are available from the content host's previous environment @id: 78110ba8-3942-46dd-8c14-bffa1dbd5195 @Setup: 1. Make sure multiple environments are present. 2. Content host's previous environments have additional errata. @Steps: 1. Go to Content Hosts -> Select content host -> Errata Tab -> Select Previous environments. @Assert: The errata from previous environments are displayed. @CaseLevel: System """ with VirtualMachine(distro='rhel71') as client: client.install_katello_ca() result = client.register_contenthost( self.session_org.label, self.activation_key.name, ) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) last_env_id = max(lce.id for lce in entities.LifecycleEnvironment( organization=self.session_org).search()) new_env = entities.LifecycleEnvironment( organization=self.session_org, prior=last_env_id, ).create() cvv = ContentView.info({'id': self.content_view.id})['versions'][-1] ContentView.version_promote({ 'id': cvv['id'], 'organization-id': self.session_org.id, 'to-lifecycle-environment-id': new_env.id, }) Host.update({ 'name': client.hostname, 'lifecycle-environment-id': new_env.id, 'organization-id': self.session_org.id, }) with Session(self.browser): self.assertIsNotNone( self.contenthost.errata_search( client.hostname, CUSTOM_REPO_ERRATA_ID, environment_name=self.env.name, ))
def test_positive_generate_entitlements_report_multiple_formats(self): """Generate an report using the Subscription - Entitlement Report template in html, yaml, and csv format. :id: f2b74916-1298-4d20-9c24-a2c2b3a3e9a9 :setup: Installed Satellite with Organization, Activation key, Content View, Content Host, and Subscriptions. :steps: 1. hammer report-template generate --organization '' --id '' --report-format '' :expectedresults: report is generated containing all the expected information regarding entitlements. :CaseImportance: High :BZ: 1830289 """ with VirtualMachine(distro=DISTRO_RHEL7) as vm: vm.install_katello_ca() vm.register_contenthost(self.setup_org['label'], self.setup_new_ak['name']) assert vm.subscribed result_html = ReportTemplate.generate( { 'organization': self.setup_org['name'], 'name': 'Subscription - Entitlement Report', 'report-format': 'html', 'inputs': 'Days from Now=no limit', } ) assert vm.hostname in result_html[2] assert self.setup_subs_id[0]['name'] in result_html[2] result_yaml = ReportTemplate.generate( { 'organization': self.setup_org['name'], 'name': 'Subscription - Entitlement Report', 'report-format': 'yaml', 'inputs': 'Days from Now=no limit', } ) for entry in result_yaml: if '-Name:' in entry: assert vm.hostname in entry elif 'Subscription Name:' in entry: assert self.setup_subs_id[0]['name'] in entry result_csv = ReportTemplate.generate( { 'organization': self.setup_org['name'], 'name': 'Subscription - Entitlement Report', 'report-format': 'csv', 'inputs': 'Days from Now=no limit', } ) assert vm.hostname in result_csv[1] assert self.setup_subs_id[0]['name'] in result_csv[1] # BZ 1830289 assert 'Subscription Quantity' in result_csv[0]
def test_pre_scenario_remoteexecution_satellite(self): """Run REX job on client registered with Satellite :id: preupgrade-3f338475-fa69-43ef-ac86-f00f4d324b33 :steps: 1. Create Subnet. 2. Create Content host. 3. Install katello-ca package and register to Satellite host. 4. Add rex ssh_key of Satellite on content host. 5. Run the REX job on client vm. :expectedresults: 1. It should create with pre-required details. 2. REX job should run on it. """ try: sn = entities.Subnet( domain=self.vm_domain, gateway=self.gateway, ipam='DHCP', location=[DEFAULT_LOC_ID], mask=self.netmask, network=self.subnet, organization=[self.org.id], remote_execution_proxy=[entities.SmartProxy(id=1)], ).create() client = VirtualMachine(distro=DISTRO_RHEL7, provisioning_server=self.libvirt_vm, bridge=self.bridge) client.create() client.install_katello_ca() client.register_contenthost(org=self.org.label, lce='Library') add_remote_execution_ssh_key(hostname=client.ip_addr) host = entities.Host().search( query={'search': 'name="{}"'.format(client.hostname)}) host[0].subnet = sn host[0].update(['subnet']) job = entities.JobInvocation().run( data={ 'job_template_id': 89, 'inputs': { 'command': "ls" }, 'targeting_type': 'static_query', 'search_query': "name = {0}".format(client.hostname) }) self.assertEqual(job['output']['success_count'], 1) global_dict = { self.__class__.__name__: { 'client_name': client.hostname } } create_dict(global_dict) except Exception as exp: if client._created: self._vm_cleanup(hostname=client.hostname) raise Exception(exp)
def test_positive_add_multiple_aks_to_system(session, module_org): """Check if multiple Activation keys can be attached to a system :id: 4d6b6b69-9d63-4180-af2e-a5d908f8adb7 :expectedresults: Multiple Activation keys are attached to a system :CaseLevel: System """ key_1_name = gen_string('alpha') key_2_name = gen_string('alpha') cv_1_name = gen_string('alpha') cv_2_name = gen_string('alpha') env_1_name = gen_string('alpha') env_2_name = gen_string('alpha') product_1_name = gen_string('alpha') product_2_name = gen_string('alpha') repo_1_id = create_sync_custom_repo( org_id=module_org.id, product_name=product_1_name) cv_publish_promote(cv_1_name, env_1_name, repo_1_id, module_org.id) repo_2_id = create_sync_custom_repo( org_id=module_org.id, product_name=product_2_name, repo_url=FAKE_2_YUM_REPO, ) cv_publish_promote(cv_2_name, env_2_name, repo_2_id, module_org.id) with session: # Create 2 activation keys for key_name, env_name, cv_name, product_name in ( (key_1_name, env_1_name, cv_1_name, product_1_name), (key_2_name, env_2_name, cv_2_name, product_2_name)): session.activationkey.create({ 'name': key_name, 'lce': {env_name: True}, 'content_view': cv_name }) assert session.activationkey.search(key_name) == key_name session.activationkey.add_subscription(key_name, product_name) ak = session.activationkey.read(key_name) subscriptions = [ subscription['Repository Name'] for subscription in ak['subscriptions']['resources']['assigned'] ] assert product_name in subscriptions # Create VM with VirtualMachine(distro=DISTRO_RHEL6) as vm: vm.install_katello_ca() vm.register_contenthost( module_org.label, '{0},{1}'.format(key_1_name, key_2_name), ) assert vm.subscribed # Assert the content-host association with activation keys for key_name in [key_1_name, key_2_name]: ak = session.activationkey.read(key_name) assert len(ak['content_hosts']) == 1 assert ak['content_hosts'][0]['Name'] == vm.hostname
def test_positive_run_job_template_multiple_hosts_by_ip( session, module_org, module_loc): """Run a job template against multiple hosts by ip :id: c4439ec0-bb80-47f6-bc31-fa7193bfbeeb :Setup: Create a working job template. :Steps: 1. Set remote_execution_connect_by_ip on hosts to true 2. Navigate to the hosts page and select at least two hosts 3. Click the "Select Action" 4. Select the job and appropriate template 5. Run the job :expectedresults: Verify the job was successfully ran against the hosts :CaseLevel: System """ with VirtualMachine(distro=DISTRO_DEFAULT) as client_1, VirtualMachine( distro=DISTRO_DEFAULT) as client_2: vm_clients = [client_1, client_2] host_names = [client.hostname for client in vm_clients] for client in vm_clients: _setup_vm_client_host(client, module_org.label) update_vm_host_location(client, location_id=module_loc.id) with session: hosts = session.host.search(' or '.join( ['name="{0}"'.format(hostname) for hostname in host_names])) assert set(host['Name'] for host in hosts) == set(host_names) job_status = session.host.schedule_remote_job( host_names, { 'job_category': 'Commands', 'job_template': 'Run Command - SSH Default', 'template_content.command': 'ls', 'schedule': 'Execute now', }, ) assert job_status['overview']['job_status'] == 'Success' assert set(host_job['Host'] for host_job in job_status['overview'] ['hosts_table']) == set(host_names) assert all(host_job['Status'] == 'success' for host_job in job_status['overview']['hosts_table'])
def test_positive_content_host_subscription_status(self): """Check if the Content Host Subscription Status is working in the Dashboard UI :id: ce0d7b0c-ae6a-4361-8173-e50f6381194a :Steps: 1. Register Content Host and subscribe it 2. Navigate Monitor -> Dashboard 3. Review the Content Host Subscription Status 4. Click each link: a. Invalid Subscriptions b. Partial Subscriptions c. Valid Subscriptions :expectedresults: The widget is updated with all details for Valid, Invalid and Partial Subscriptions :CaseLevel: Integration """ org = entities.Organization().create() env = entities.LifecycleEnvironment(organization=org).create() content_view = entities.ContentView(organization=org).create() activation_key = entities.ActivationKey( environment=env, organization=org, ).create() setup_org_for_a_rh_repo({ 'product': PRDS['rhel'], 'repository-set': REPOSET['rhst7'], 'repository': REPOS['rhst7']['name'], 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) with VirtualMachine(distro=DISTRO_RHEL7) as client: client.install_katello_ca() result = client.register_contenthost( org.label, activation_key.name) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() with Session(self.browser) as session: set_context(session, org=org.name) self.assertTrue(self.dashboard.validate_chss_navigation( 'Invalid', u'subscription_status=invalid')) self.assertIsNotNone(self.dashboard.wait_until_element( common_locators['kt_search_no_results'])) self.assertTrue(self.dashboard.validate_chss_navigation( 'Partial', u'subscription_status=partial')) self.assertIsNotNone(self.dashboard.wait_until_element( common_locators['kt_search_no_results'])) self.assertTrue(self.dashboard.validate_chss_navigation( 'Valid', u'subscription_status=valid', client.hostname))
def test_host_unreachable(self, exception_type): """Look for VirtualMachineError if the host is unreachable""" with patch('robottelo.ssh.command') as ssh_mock: ssh_mock.side_effect = exception_type({('127.0.0.1', 22): None}) with pytest.raises( VirtualMachineError, match=f'Exception connecting via ssh to get host os version' ): VirtualMachine()
def test_provisioning_server_not_configured(self, vm_settings_patch, host_os_version_patch): """Check if an exception is raised if missing provisioning_server Mocking allowed_distros because config is empty on travis when running unit tests This means we can't hit the provisioning server line, because distro_mapping has Nones """ with pytest.raises(VirtualMachineError, match=r'A provisioning server must be provided.*'): VirtualMachine(distro=DISTRO_RHEL6)
def test_positive_run_custom_job_template(self): """Run a job template against a single host :id: 89b75feb-afff-44f2-a2bd-2ffe74b63ec7 :Setup: Create a working job template. :Steps: 1. Navigate to an individual host and click Run Job 2. Select the job and appropriate template 3. Run the job :expectedresults: Verify the job was successfully ran against the host :CaseLevel: System """ jobs_template_name = gen_string('alpha') with VirtualMachine(distro=DISTRO_RHEL7, bridge=settings.vlan_networking.bridge) as client: client.install_katello_ca() client.register_contenthost(self.organization.label, lce='Library') self.assertTrue(client.subscribed) add_remote_execution_ssh_key(client.ip_addr) Host.update({ u'name': client.hostname, u'subnet-id': self.new_sub['id'], }) with Session(self) as session: set_context(session, org=self.organization.name) make_job_template( session, name=jobs_template_name, template_type='input', template_content='<%= input("command") %>', provider_type='SSH', ) self.assertIsNotNone( self.jobtemplate.search(jobs_template_name)) self.jobtemplate.add_input(jobs_template_name, 'command', required=True) self.hosts.click(self.hosts.search(client.hostname)) status = self.job.run(job_category='Miscellaneous', job_template=jobs_template_name, options_list=[{ 'name': 'command', 'value': 'ls' }]) # get job invocation id from the current url invocation_id = self.browser.current_url.rsplit('/', 1)[-1] self.assertTrue( status, 'host output: {0}'.format(' '.join( JobInvocation.get_output({ 'id': invocation_id, 'host': client.hostname }))))
def test_positive_run_default_job_template_by_ip(session, module_org, module_subnet): """Run a job template on a host connected by ip :id: 9a90aa9a-00b4-460e-b7e6-250360ee8e4d :Setup: Use pre-defined job template. :Steps: 1. Set remote_execution_connect_by_ip on host to true 2. Navigate to an individual host and click Run Job 3. Select the job and appropriate template 4. Run the job :expectedresults: Verify the job was successfully ran against the host :CaseLevel: System """ with VirtualMachine( distro=DISTRO_RHEL6, provisioning_server=settings.compute_resources.libvirt_hostname, bridge=settings.vlan_networking.bridge, ) as client: client.install_katello_ca() client.register_contenthost(module_org.label, lce='Library') assert client.subscribed add_remote_execution_ssh_key(client.ip_addr) Host.update({ 'name': client.hostname, 'subnet-id': module_subnet.id, }) # connect to host by ip Host.set_parameter({ 'host': client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) hostname = client.hostname with session: session.organization.select(module_org.name) assert session.host.search(hostname)[0]['Name'] == hostname session.jobinvocation.run({ 'job_category': 'Commands', 'job_template': 'Run Command - SSH Default', 'search_query': 'name ^ {}'.format(hostname), 'template_content.command': 'ls', }) session.jobinvocation.wait_job_invocation_state( entity_name='Run ls', host_name=hostname) status = session.jobinvocation.read(entity_name='Run ls', host_name=hostname) assert status['overview']['hosts_table'][0]['Status'] == 'success'
def test_positive_run_default_job_template_by_ip(self): """Run a job template on a host connected by ip :id: 9a90aa9a-00b4-460e-b7e6-250360ee8e4d :Setup: Use pre-defined job template. :Steps: 1. Set remote_execution_connect_by_ip on host to true 2. Navigate to an individual host and click Run Job 3. Select the job and appropriate template 4. Run the job :expectedresults: Verify the job was successfully ran against the host :CaseLevel: Integration """ with VirtualMachine( distro=DISTRO_RHEL7, provisioning_server=settings.compute_resources.libvirt_hostname, bridge=settings.vlan_networking.bridge, ) as client: client.install_katello_ca() client.register_contenthost(self.organization.label, lce='Library') self.assertTrue(client.subscribed) add_remote_execution_ssh_key(client.ip_addr) Host.update({ 'name': client.hostname, 'subnet-id': self.new_sub.id, }) # connect to host by ip Host.set_parameter({ 'host': client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) with Session(self) as session: set_context(session, org=self.organization.name) self.hosts.click(self.hosts.search(client.hostname)) status = self.job.run( job_category='Commands', job_template='Run Command - SSH Default', options_list=[{'name': 'command', 'value': 'ls'}] ) # get job invocation id from the current url invocation_id = self.browser.current_url.rsplit('/', 1)[-1] try: self.assertTrue(status) except AssertionError: result = 'host output: {0}'.format( ' '.join(JobInvocation.get_output({ 'id': invocation_id, 'host': client.hostname}) ) ) raise AssertionError(result)
def vm_content_hosts(request, module_repos_collection): clients = [] for _ in range(2): client = VirtualMachine(distro=module_repos_collection.distro) clients.append(client) request.addfinalizer(client.destroy) client.create() module_repos_collection.setup_virtual_machine(client) return clients
def test_positive_usage_limit(self): """Test that Usage limit actually limits usage :id: 00ded856-e939-4140-ac84-91b6a8643623 :Steps: 1. Create Activation key 2. Update Usage Limit to a finite number 3. Register Content hosts to match the Usage Limit 4. Attempt to register an other Content host after reaching the Usage Limit :expectedresults: Content host Registration fails. Appropriate error shown :CaseLevel: System """ env = make_lifecycle_environment({u'organization-id': self.org['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ContentView.publish({u'id': new_cv['id']}) cvv = ContentView.info({u'id': new_cv['id']})['versions'][0] ContentView.version_promote({ u'id': cvv['id'], u'to-lifecycle-environment-id': env['id'], }) new_ak = make_activation_key({ u'lifecycle-environment-id': env['id'], u'content-view': new_cv['name'], u'organization-id': self.org['id'], u'max-hosts': '1', }) with VirtualMachine(distro=DISTRO_RHEL6) as vm1: with VirtualMachine(distro=DISTRO_RHEL6) as vm2: vm1.install_katello_ca() result = vm1.register_contenthost( self.org['label'], new_ak['name']) self.assertTrue(vm1.subscribed) vm2.install_katello_ca() result = vm2.register_contenthost( self.org['label'], new_ak['name']) self.assertFalse(vm2.subscribed) self.assertEqual(result.return_code, 70) self.assertGreater(len(result.stderr), 0)
def test_positive_virt_who_hypervisor_subscription_status(session): """Check that virt-who hypervisor shows the right subscription status without and with attached subscription. :id: 8b2cc5d6-ac85-463f-a973-f4818c55fb37 :customerscenario: true :expectedresults: 1. With subscription not attached, Subscription status is "Unsubscribed hypervisor" and represented by a yellow icon in content hosts list. 2. With attached subscription, Subscription status is "Fully entitled" and represented by a green icon in content hosts list. :BZ: 1336924 :CaseLevel: System """ org = entities.Organization().create() lce = entities.LifecycleEnvironment(organization=org).create() provisioning_server = settings.compute_resources.libvirt_hostname # Create a new virt-who config virt_who_config = make_virt_who_config({ 'organization-id': org.id, 'hypervisor-type': VIRT_WHO_HYPERVISOR_TYPES['libvirt'], 'hypervisor-server': 'qemu+ssh://{0}/system'.format(provisioning_server), 'hypervisor-username': '******', }) # create a virtual machine to host virt-who service with VirtualMachine() as virt_who_vm: # configure virtual machine and setup virt-who service # do not supply subscription to attach to virt_who hypervisor virt_who_data = virt_who_hypervisor_config( virt_who_config['general-information']['id'], virt_who_vm, org_id=org.id, lce_id=lce.id, hypervisor_hostname=provisioning_server, configure_ssh=True, ) virt_who_hypervisor_host = virt_who_data[ 'virt_who_hypervisor_host'] with session: session.organization.select(org.name) assert session.contenthost.search( virt_who_hypervisor_host['name'])[0]['Subscription Status'] == 'yellow' chost = session.contenthost.read(virt_who_hypervisor_host['name']) assert chost['details']['subscription_status'] == 'Unsubscribed hypervisor' session.contenthost.add_subscription( virt_who_hypervisor_host['name'], VDC_SUBSCRIPTION_NAME) assert session.contenthost.search( virt_who_hypervisor_host['name'])[0]['Subscription Status'] == 'green' chost = session.contenthost.read(virt_who_hypervisor_host['name']) assert chost['details']['subscription_status'] == 'Fully entitled'
def test_positive_host_associations(session): """Register few hosts with different activation keys and ensure proper data is reflected under Associations > Content Hosts tab :id: 111aa2af-caf4-4940-8e4b-5b071d488876 :expectedresults: Only hosts, registered by specific AK are shown under Associations > Content Hosts tab :BZ: 1344033, 1372826, 1394388 :CaseLevel: System """ org = entities.Organization().create() org_entities = setup_org_for_a_custom_repo({ 'url': FAKE_1_YUM_REPO, 'organization-id': org.id, }) ak1 = entities.ActivationKey( id=org_entities['activationkey-id']).read() ak2 = entities.ActivationKey( content_view=org_entities['content-view-id'], environment=org_entities['lifecycle-environment-id'], organization=org.id, ).create() with VirtualMachine(distro=DISTRO_RHEL7) as vm1, VirtualMachine( distro=DISTRO_RHEL7) as vm2: vm1.install_katello_ca() vm1.register_contenthost(org.label, ak1.name) assert vm1.subscribed vm2.install_katello_ca() vm2.register_contenthost(org.label, ak2.name) assert vm2.subscribed with session: session.organization.select(org.name) ak1 = session.activationkey.read(ak1.name) assert len(ak1['content_hosts']['resources']) == 1 assert ak1['content_hosts']['resources'][0]['Name'] == vm1.hostname # fixme: drop next line after airgun#63 is solved session.activationkey.search(ak2.name) ak2 = session.activationkey.read(ak2.name) assert len(ak2['content_hosts']['resources']) == 1 assert ak2['content_hosts']['resources'][0]['Name'] == vm2.hostname
def test_negative_usage_limit(self): """Test that Usage limit actually limits usage @id: 9fe2d661-66f8-46a4-ae3f-0a9329494bdd @Steps: 1. Create Activation key 2. Update Usage Limit to a finite number 3. Register Systems to match the Usage Limit 4. Attempt to register an other system after reaching the Usage Limit @Assert: System Registration fails. Appropriate error shown @CaseLevel: System """ name = gen_string('alpha') host_limit = '1' with Session(self.browser) as session: make_activationkey( session, org=self.organization.name, name=name, env=ENVIRONMENT, ) self.assertIsNotNone(self.activationkey.search(name)) self.activationkey.update(name, limit=host_limit) self.assertIsNotNone( self.activationkey.wait_until_element( common_locators['alert.success_sub_form'])) with VirtualMachine(distro=self.vm_distro) as vm1: with VirtualMachine(distro=self.vm_distro) as vm2: vm1.install_katello_ca() result = vm1.register_contenthost(self.organization.label, name) self.assertEqual(result.return_code, 0) vm2.install_katello_ca() result = vm2.register_contenthost(self.organization.label, name) self.assertNotEqual(result.return_code, 0) self.assertGreater(len(result.stderr), 0) self.assertIn( 'Max Hosts ({0}) reached for activation key'.format( host_limit), result.stderr)
def test_subscription_manager_overall_status( self, ssh_command, sleep, config_provisioning_server, host_os_version_patch ): vm = VirtualMachine() vm.create() assert vm.subscription_manager_status().stdout == 'Overall Status: Current' assert ( vm.subscription_manager_list_repos().stdout == 'This system has no repositories available through subscriptions.' )
def test_name_limit(self): """Check whether exception is risen in case of too long host name (more than 59 chars)""" self.configure_provisioning_server() domain = self.provisioning_server.split('.', 1)[1] with self.assertRaises(VirtualMachineError): VirtualMachine( tag='test', target_image='a'*(59 - len(domain)) )
def test_positive_host_associations(self): """Register few hosts with different activation keys and ensure proper data is reflected under Associations > Content Hosts tab :id: 111aa2af-caf4-4940-8e4b-5b071d488876 :expectedresults: Only hosts, registered by specific AK are shown under Associations > Content Hosts tab :BZ: 1344033, 1372826, 1394388 :CaseLevel: System """ org = entities.Organization().create() org_entities = setup_org_for_a_custom_repo({ 'url': FAKE_1_YUM_REPO, 'organization-id': org.id, }) ak1 = entities.ActivationKey( id=org_entities['activationkey-id']).read() ak2 = entities.ActivationKey( content_view=org_entities['content-view-id'], environment=org_entities['lifecycle-environment-id'], organization=org.id, ).create() with VirtualMachine(distro=DISTRO_RHEL7) as vm1, VirtualMachine( distro=DISTRO_RHEL7) as vm2: vm1.install_katello_ca() vm1.register_contenthost(org.label, ak1.name) self.assertTrue(vm1.subscribed) vm2.install_katello_ca() vm2.register_contenthost(org.label, ak2.name) self.assertTrue(vm2.subscribed) with Session(self) as session: set_context(session, org=org.name) ak1_hosts = self.activationkey.fetch_associated_content_hosts( ak1.name) self.assertEqual(len(ak1_hosts), 1) self.assertIn(vm1.hostname, ak1_hosts) ak2_hosts = self.activationkey.fetch_associated_content_hosts( ak2.name) self.assertEqual(len(ak2_hosts), 1) self.assertIn(vm2.hostname, ak2_hosts)
def test_positive_candlepin_events_processed_by_STOMP(session): """Verify that Candlepin events are being read and processed by attaching subscriptions, validating host subscriptions status, and viewing processed and failed Candlepin events :id: 9510fd1c-2efb-4132-8665-9a72273cd1af :steps: 1. Register Content Host without subscriptions attached 2. Verify subscriptions status is red "invalid" 3. Import a Manifest 4. Attach subs to content host 5. Verify subscription status is green "valid" 6. Check for processed and failed Candlepin events :expectedresults: Candlepin events are being read and processed correctly without any failures :BZ: #1826515 :CaseImportance: High """ org = entities.Organization().create() repo = entities.Repository(product=entities.Product( organization=org).create()).create() repo.sync() ak = entities.ActivationKey( content_view=org.default_content_view, max_hosts=100, organization=org, environment=entities.LifecycleEnvironment(id=org.library.id), ).create() with VirtualMachine(distro=DISTRO_RHEL7) as vm: vm.install_katello_ca() vm.register_contenthost(org.name, ak.name) with session: session.organization.select(org_name=org.name) host = session.contenthost.read(vm.hostname, widget_names='details')['details'] sub_status = host['subscription_status'] assert "Unentitled" in sub_status with manifests.clone() as manifest: upload_manifest(org.id, manifest.content) session.contenthost.add_subscription(vm.hostname, DEFAULT_SUBSCRIPTION_NAME) session.browser.refresh() updated_sub_status = session.contenthost.read( vm.hostname, widget_names='details')['details']['subscription_status'] assert "Fully entitled" in updated_sub_status response = entities.Ping().search_json( )["services"]["candlepin_events"] assert response["status"] == "ok" assert "0 Failed" in response["message"]
def test_negative_usage_limit(session, module_org): """Test that Usage limit actually limits usage :id: 9fe2d661-66f8-46a4-ae3f-0a9329494bdd :Steps: 1. Create Activation key 2. Update Usage Limit to a finite number 3. Register Systems to match the Usage Limit 4. Attempt to register an other system after reaching the Usage Limit :expectedresults: System Registration fails. Appropriate error shown :CaseLevel: System """ name = gen_string('alpha') hosts_limit = '1' with session: session.activationkey.create({ 'name': name, 'lce': {ENVIRONMENT: True}, }) assert session.activationkey.search(name) == name session.activationkey.update( name, {'details.hosts_limit': hosts_limit}) ak = session.activationkey.read(name) assert ak['details']['hosts_limit'] == hosts_limit with VirtualMachine(distro=DISTRO_RHEL6) as vm1: with VirtualMachine(distro=DISTRO_RHEL6) as vm2: vm1.install_katello_ca() vm1.register_contenthost(module_org.label, name) assert vm1.subscribed vm2.install_katello_ca() result = vm2.register_contenthost(module_org.label, name) assert not vm2.subscribed assert len(result.stderr) > 0 assert ( 'Max Hosts ({0}) reached for activation key' .format(hosts_limit) in result.stderr )
def setUpClass(cls): # noqa super(InstallerTestCase, cls).setUpClass() cls.vm = VirtualMachine(cls.vm_cpu, cls.vm_ram, cls.vm_os) cls.vm.create() key_filename = conf.properties.get('main.server.ssh.key_private') with settings(key_filename=key_filename, user='******', warn_only=True): execute( product_install, 'upstream', host=cls.vm.ip_addr )
def test_positive_run_default_job_template_multiple_hosts_by_ip( self, fixture_vmsetup, fixture_org ): """Run default job template against multiple hosts by ip :id: 694a21d3-243b-4296-8bd0-4bad9663af15 :expectedresults: Verify the job was successfully ran against all hosts :parametrized: yes """ self.org = fixture_org self.client = fixture_vmsetup Host.set_parameter( { 'host': self.client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', } ) with VirtualMachine(distro=DISTRO_RHEL7) as client2: client2.install_katello_ca() client2.register_contenthost(self.org.label, lce='Library') add_remote_execution_ssh_key(client2.ip_addr) Host.set_parameter( { 'host': client2.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', } ) invocation_command = make_job_invocation( { 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': "name ~ {} or name ~ {}".format( self.client.hostname, client2.hostname ), } ) # collect output messages from clients output_msgs = [] for vm in self.client, client2: output_msgs.append( 'host output from {}: {}'.format( vm.hostname, ' '.join( JobInvocation.get_output( {'id': invocation_command['id'], 'host': vm.hostname} ) ), ) ) assert invocation_command['success'] == '2', output_msgs
def test_positive_install_in_hc(self): """Install errata in a host-collection @id: 6f0242df-6511-4c0f-95fc-3fa32c63a064 @Setup: Errata synced on satellite server. @Steps: 1. PUT /api/v2/hosts/bulk/update_content @Assert: errata is installed in the host-collection. @CaseLevel: System """ with VirtualMachine(distro=DISTRO_RHEL7) as client1, VirtualMachine( distro=DISTRO_RHEL7) as client2: clients = [client1, client2] for client in clients: client.install_katello_ca() result = client.register_contenthost(self.org.label, self.activation_key.name) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() host_ids = [ entities.Host().search( query={'search': 'name={0}'.format(client.hostname)})[0].id for client in clients ] self._install_package(clients, host_ids, FAKE_1_CUSTOM_PACKAGE) entities.Host().install_content( data={ 'organization_id': self.org.id, 'included': { 'ids': host_ids }, 'content_type': 'errata', 'content': [CUSTOM_REPO_ERRATA_ID], }) self._validate_package_installed(clients, FAKE_2_CUSTOM_PACKAGE)
def test_dont_create_if_already_created(self, ssh_command, sleep): """Check if the creation steps are run more than once""" self.configure_provisoning_server() vm = VirtualMachine() with patch.multiple(vm, image_dir='/opt/robottelo/images', provisioning_server='provisioning.example.com'): vm.create() vm.create() self.assertEqual(vm.ip_addr, '192.168.0.1') self.assertEqual(ssh_command.call_count, 3)
def setUp(self): """Create a VM, subscribe it to satellite-tools repo, install katello-ca and katello-agent packages""" super(ContentHostTestCase, self).setUp() self.client = VirtualMachine(distro=DISTRO_RHEL7) self.client.create() self.client.install_katello_ca() result = self.client.register_contenthost( self.session_org.label, self.activation_key.name) self.assertEqual(result.return_code, 0) self.client.enable_repo(REPOS['rhst7']['id']) self.client.install_katello_agent()
def test_positive_usage_limit(self): """Test that Usage limit actually limits usage @Feature: Activation key - Usage limit @Steps: 1. Create Activation key 2. Update Usage Limit to a finite number 3. Register Content hosts to match the Usage Limit 4. Attempt to register an other Content host after reaching the Usage Limit @Assert: Content host Registration fails. Appropriate error shown """ env = make_lifecycle_environment({u'organization-id': self.org['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ContentView.publish({u'id': new_cv['id']}) cvv = ContentView.info({u'id': new_cv['id']})['versions'][0] ContentView.version_promote({ u'id': cvv['id'], u'to-lifecycle-environment-id': env['id'], }) new_ak = make_activation_key({ u'lifecycle-environment-id': env['id'], u'content-view': new_cv['name'], u'organization-id': self.org['id'], u'max-content-hosts': '1', }) with VirtualMachine(distro='rhel65') as vm1: with VirtualMachine(distro='rhel65') as vm2: vm1.install_katello_ca() result = vm1.register_contenthost( new_ak['name'], self.org['label']) self.assertEqual(result.return_code, 0) vm2.install_katello_ca() result = vm2.register_contenthost( new_ak['name'], self.org['label']) self.assertEqual(result.return_code, 255) self.assertGreater(len(result.stderr), 0)
def test_positive_apply_for_all_hosts(self): """Apply an erratum for all content hosts :id: d70a1bee-67f4-4883-a0b9-2ccc08a91738 :Setup: Errata synced on satellite server. :Steps: 1. Go to Content -> Errata. Select an erratum -> Content Hosts tab. 2. Select all Content Hosts and apply the erratum. :expectedresults: Check that the erratum is applied in all the content hosts. :CaseLevel: System """ with VirtualMachine(distro=DISTRO_RHEL7) as client1, VirtualMachine( distro=DISTRO_RHEL7) as client2: clients = [client1, client2] for client in clients: client.install_katello_ca() result = client.register_contenthost( self.session_org.label, self.activation_key.name, ) self.assertEqual(result.return_code, 0) client.enable_repo(REPOS['rhst7']['id']) client.install_katello_agent() client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE)) with Session(self.browser): result = self.errata.install( CUSTOM_REPO_ERRATA_ID, [client.hostname for client in clients], ) self.assertEqual(result, 'success') for client in clients: self.assertIsNotNone( self.contenthost.package_search( client.hostname, FAKE_2_CUSTOM_PACKAGE))