def test_positive_host_collection_host_pagination(self): """Check if pagination configured on per-page param defined in hammer host-collection hosts command overrides global configuration defined on /etc/hammer/cli_config.yml, which default is 20 per page @BZ: 1343583 @id: bbe1108b-bfb2-4a03-94ef-8fd1b5a0ec82 @Assert: Number of host per page follows per_page configuration restriction @CaseLevel: Integration """ host_collection = self._new_host_collection({ 'name': gen_string('alpha', 15) }) host_ids = ','.join( self._make_content_host_helper()['id'] for i in range(2) ) HostCollection.add_host({ u'host-ids': host_ids, u'id': host_collection['id'], u'organization-id': self.org['id'], }) for number in range(1, 3): listed_hosts = HostCollection.hosts({ u'id': host_collection['id'], u'organization-id': self.org['id'], u'per-page': number }) self.assertEqual(len(listed_hosts), number)
def test_positive_host_collection_host_pagination(module_org): """Check if pagination configured on per-page param defined in hammer host-collection hosts command overrides global configuration defined on /etc/hammer/cli_config.yml, which default is 20 per page :BZ: 1343583 :id: bbe1108b-bfb2-4a03-94ef-8fd1b5a0ec82 :expectedresults: Number of host per page follows per_page configuration restriction :CaseLevel: Integration """ host_collection = make_host_collection({'organization-id': module_org.id}) host_ids = ','.join(_make_fake_host_helper(module_org)['id'] for _ in range(2)) HostCollection.add_host({'host-ids': host_ids, 'id': host_collection['id']}) for number in range(1, 3): listed_hosts = HostCollection.hosts( { 'id': host_collection['id'], 'organization-id': module_org.id, 'per-page': number, } ) assert len(listed_hosts) == number
def test_positive_list_hosts(self): """Check if content hosts added to host collection is listed @id: 3075cb97-8448-4358-8ffc-0d5cd0078ca3 @Assert: Content-host added to host-collection is listed @CaseLevel: Integration """ host_col_name = gen_string('alpha', 15) new_host_col = self._new_host_collection({'name': host_col_name}) new_system = self._make_content_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ u'host-ids': new_system['id'], u'id': new_host_col['id'], u'organization-id': self.org['id'], }) result = HostCollection.info({ u'id': new_host_col['id'], u'organization-id': self.org['id'] }) self.assertGreater(result['total-hosts'], no_of_content_host) result = HostCollection.hosts({ u'name': host_col_name, u'organization-id': self.org['id'] }) self.assertEqual(new_system['name'].lower(), result[0]['name'])
def test_positive_register_host_ak_with_host_collection( katello_agent_client, module_cv, module_lce, module_org, rhel7_contenthost, default_sat): """Attempt to register a host using activation key with host collection :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb :BZ: 1385814 :expectedresults: Host successfully registered and listed in host collection :CaseLevel: System """ # client = katello_agent_client['client'] host_info = katello_agent_client['host_info'] # create a new activation key activation_key = make_activation_key({ 'lifecycle-environment-id': module_lce.id, 'organization-id': module_org.id, 'content-view-id': module_cv.id, }) hc = make_host_collection({'organization-id': module_org.id}) ActivationKey.add_host_collection({ 'id': activation_key['id'], 'organization-id': module_org.id, 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': module_org.id, 'host-ids': host_info['id'] }) with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as vm: vm.install_katello_ca(default_sat) # register the client host with the current activation key vm.register_contenthost(module_org.name, activation_key=activation_key['name']) assert vm.subscribed # note: when registering the host, it should be automatically added to the host-collection client_host = Host.info({'name': vm.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': module_org.id }) assert len(hosts) == 2 expected_hosts_ids = {host_info['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def test_positive_register_host_ak_with_host_collection(self): """Attempt to register a host using activation key with host collection :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb :BZ: 1385814 :expectedresults: Host successfully registered and listed in host collection :CaseLevel: System """ # create a new activation key activation_key = make_activation_key({ 'lifecycle-environment-id': self.env['id'], 'organization-id': self.org['id'], 'content-view-id': self.content_view['id'], }) hc = make_host_collection({'organization-id': self.org['id']}) ActivationKey.add_host_collection({ 'id': activation_key['id'], 'organization-id': self.org['id'], 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': self.org['id'], 'host-ids': self.host['id'] }) with VirtualMachine() as client: client.create() client.install_katello_ca() # register the client host with the current activation key client.register_contenthost(self.org['name'], activation_key=activation_key['name']) assert client.subscribed # note: when registering the host, it should be automatically added # to the host collection client_host = Host.info({'name': client.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': self.org['id'] }) assert len(hosts) == 2 expected_hosts_ids = {self.host['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def test_positive_register_host_ak_with_host_collection( module_org, module_ak_with_cv, default_sat): """Attempt to register a host using activation key with host collection :id: 62459e8a-0cfa-44ff-b70c-7f55b4757d66 :expectedresults: Host successfully registered and listed in host collection :BZ: 1385814 :CaseLevel: System """ host_info = _make_fake_host_helper(module_org) hc = make_host_collection({'organization-id': module_org.id}) ActivationKey.add_host_collection({ 'id': module_ak_with_cv.id, 'organization-id': module_org.id, 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': module_org.id, 'host-ids': host_info['id'] }) with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as client: client.install_katello_ca(default_sat) # register the client host with the current activation key client.register_contenthost(module_org.name, activation_key=module_ak_with_cv.name) assert client.subscribed # note: when registering the host, it should be automatically added to the host-collection client_host = Host.info({'name': client.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': module_org.id }) assert len(hosts) == 2 expected_hosts_ids = {host_info['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def test_positive_end_to_end(module_org): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = list(valid_data_list().values())[0] desc = list(valid_data_list().values())[0] new_host_col = make_host_collection( {'description': desc, 'name': name, 'organization-id': module_org.id} ) assert new_host_col['name'] == name assert new_host_col['description'] == desc # add host new_system = _make_fake_host_helper(module_org) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert result['total-hosts'] > no_of_content_host # list hosts result = HostCollection.hosts({'name': name, 'organization-id': module_org.id}) assert new_system['name'].lower() == result[0]['name'] # List all host collections within organization result = HostCollection.list({'organization': module_org.name}) assert len(result) >= 1 # Filter list by name result = HostCollection.list({'name': name, 'organization-id': module_org.id}) assert len(result) == 1 assert result[0]['id'] == new_host_col['id'] # Filter list by associated host name result = HostCollection.list({'organization': module_org.name, 'host': new_system['name']}) assert len(result) == 1 assert result[0]['name'] == new_host_col['name'] # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id']})['total-hosts'] HostCollection.remove_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert no_of_content_host > result['total-hosts'] # update new_name = list(valid_data_list().values())[0] new_desc = list(valid_data_list().values())[0] HostCollection.update( {'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name} ) result = HostCollection.info({'id': new_host_col['id']}) assert result['name'] == new_name assert result['description'] == new_desc # delete HostCollection.delete({'id': new_host_col['id']}) with pytest.raises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_end_to_end(self): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = valid_data_list()[0] desc = valid_data_list()[0] new_host_col = make_host_collection({ 'description': desc, 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_host_col['name'], name) self.assertEqual(new_host_col['description'], desc) # add host new_system = self._make_fake_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(result['total-hosts'], no_of_content_host) # list hosts result = HostCollection.hosts({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_system['name'].lower(), result[0]['name']) # List all host collections within organization result = HostCollection.list( {'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by name result = HostCollection.list({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], new_host_col['id']) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': new_system['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], new_host_col['name']) # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id'] })['total-hosts'] HostCollection.remove_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(no_of_content_host, result['total-hosts']) # update new_name = valid_data_list()[0] new_desc = valid_data_list()[0] HostCollection.update({ 'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['name'], new_name) self.assertEqual(result['description'], new_desc) # delete HostCollection.delete({'id': new_host_col['id']}) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})