def test_pre_subscription_scenario_autoattach(self): """Create content host and register with Satellite :id: preupgrade-940fc78c-ffa6-4d9a-9c4b-efa1b9480a22 :steps: 1. Before Satellite upgrade. 2. Create new Organization and Location 3. Upload a manifest in it. 4. Create a AK with 'auto-attach False' and without Subscription add in it. 5. Create a content host. 6. Update content host location. :expectedresults: 1. Content host should be created. 2. Content host location should be updated. """ org = entities.Organization().create() loc = entities.Location(organization=[org]).create() manifests.upload_manifest_locked(org.id, interface=manifests.INTERFACE_API) act_key = entities.ActivationKey(auto_attach=False, organization=org.id, environment=org.library.id).create() rhel7_client = dockerize(ak_name=act_key.name, distro='rhel7', org_label=org.label) client_container_id = [value for value in rhel7_client.values()][0] client_container_name = [key for key in rhel7_client.keys()][0] host_location_update(client_container_name=client_container_name, logger_obj=self.logger, loc=loc) wait_for( lambda: org.name in execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=self.docker_vm, )[self.docker_vm], timeout=100, delay=2, logger=self.logger, ) status = execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=self.docker_vm, )[self.docker_vm] self.assertIn(org.name, status) global_dict = { self.__class__.__name__: { 'client_container_id': client_container_id } } create_dict(global_dict)
def test_pre_subscription_scenario_autoattach(self, request, default_sat): """Create content host and register with Satellite :id: preupgrade-940fc78c-ffa6-4d9a-9c4b-efa1b9480a22 :steps: 1. Before Satellite upgrade. 2. Create new Organization and Location. 3. Upload a manifest in it. 4. Create a AK with 'auto-attach False' and without Subscription add in it. 5. Create a content host. 6. Update content host location. :expectedresults: 1. Content host should be created. 2. Content host location should be updated. """ docker_vm = settings.upgrade.docker_vm container_name = f"{request.node.name}_docker_client" org = entities.Organization(name=request.node.name + "_org").create() loc = entities.Location(name=request.node.name + "_loc", organization=[org]).create() manifests.upload_manifest_locked(org.id, interface=manifests.INTERFACE_API) act_key = entities.ActivationKey( auto_attach=False, organization=org.id, environment=org.library.id, name=request.node.name + "_ak", ).create() rhel7_client = dockerize(ak_name=act_key.name, distro='rhel7', org_label=org.label) client_container_id = [value for value in rhel7_client.values()][0] ssh.command(f"docker rename {client_container_id} {container_name}", hostname=f'{docker_vm}') client_container_hostname = [key for key in rhel7_client.keys()][0] host_location_update( client_container_name=f"{client_container_hostname}", loc=loc) wait_for( lambda: org.name in execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=docker_vm, )[docker_vm], timeout=300, delay=30, ) status = execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=docker_vm, )[docker_vm] assert org.name in status
def test_pre_scenario_generate_errata_for_client(self): """Create product and repo from which the errata will be generated for the Satellite client or content host. :id: 88fd28e6-b4df-46c0-91d6-784859fd1c21 :steps: 1. Create Life Cycle Environment, Product and Custom Yum Repo 2. Create custom tools, rhel repos and sync them 3. Create content view and publish it 4. Create activation key and add subscription. 5. Registering Docker Content Host RHEL7 6. Check katello agent and goferd service running on host 7. Generate Errata by Installing Outdated/Older Packages 8. Collect the Erratum list :expectedresults: 1. The content host is created 2. errata count, erratum list will be generated to satellite client/content host """ org = entities.Organization().create() loc = entities.Location(organization=[org]).create() environment = entities.LifecycleEnvironment(organization=org).search( query={'search': 'name=Library'})[0] product = entities.Product(organization=org).create() custom_yum_repo = entities.Repository( product=product, content_type='yum', url=settings.repos.yum_9.url).create() product.sync() tools_repo, rhel_repo = self._create_custom_rhel_tools_repos(product) repolist = [custom_yum_repo, tools_repo, rhel_repo] content_view = publish_content_view(org=org, repolist=repolist) ak = entities.ActivationKey(content_view=content_view, organization=org.id, environment=environment).create() subscription = entities.Subscription(organization=org).search( query={'search': f'name={product.name}'})[0] ak.add_subscriptions(data={'subscription_id': subscription.id}) rhel7_client = dockerize(ak_name=ak.name, distro='rhel7', org_label=org.label) client_container_id = list(rhel7_client.values())[0] client_container_name = [key for key in rhel7_client.keys()][0] host_location_update(client_container_name=client_container_name, logger_obj=logger, loc=loc) docker_vm = settings.upgrade.docker_vm wait_for( lambda: org.name in execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=docker_vm, )[docker_vm], timeout=800, delay=2, logger=logger, ) install_or_update_package(client_hostname=client_container_id, package="katello-agent") run_goferd(client_hostname=client_container_id) for package in FAKE_9_YUM_OUTDATED_PACKAGES: install_or_update_package(client_hostname=client_container_id, package=package) host = entities.Host().search( query={'search': f'activation_key={ak.name}'})[0] installable_errata_count = host.content_facet_attributes[ 'errata_counts']['total'] assert installable_errata_count > 1 erratum_list = entities.Errata(repository=custom_yum_repo).search( query={ 'order': 'updated ASC', 'per_page': 1000 }) errata_ids = [errata.errata_id for errata in erratum_list] assert sorted(errata_ids) == sorted(settings.repos.yum_9.errata) scenario_dict = { self.__class__.__name__: { 'rhel_client': rhel7_client, 'activation_key': ak.name, 'custom_repo_id': custom_yum_repo.id, 'product_id': product.id, 'conten_view_id': content_view.id, } } create_dict(scenario_dict)
def test_pre_scenario_custom_repo_check(self): """This is pre-upgrade scenario test to verify if we can create a custom repository and consume it via content host. :id: preupgrade-eb6831b1-c5b6-4941-a325-994a09467478 :steps: 1. Before Satellite upgrade. 2. Create new Organization, Location. 3. Create Product, custom repo, cv. 4. Create activation key and add subscription. 5. Create a content host, register and install package on it. :expectedresults: 1. Custom repo is created. 2. Package is installed on Content host. """ org = entities.Organization().create() loc = entities.Location(organization=[org]).create() lce = entities.LifecycleEnvironment(organization=org).create() product = entities.Product(organization=org).create() create_repo(rpm1, FILE_PATH) repo = entities.Repository(product=product.id, url=CUSTOM_REPO).create() repo.sync() content_view = publish_content_view(org=org, repolist=repo) promote(content_view.version[0], lce.id) result = ssh.command( 'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}/' 'Packages/b/|grep {}'.format(org.label, lce.name, content_view.label, product.label, repo.label, RPM1_NAME)) assert result.return_code == 0 assert len(result.stdout) >= 1 subscription = entities.Subscription(organization=org).search( query={'search': f'name={product.name}'})[0] ak = entities.ActivationKey(content_view=content_view, organization=org.id, environment=lce).create() ak.add_subscriptions(data={'subscription_id': subscription.id}) rhel7_client = dockerize(ak_name=ak.name, distro='rhel7', org_label=org.label) client_container_id = [value for value in rhel7_client.values()][0] client_container_name = [key for key in rhel7_client.keys()][0] host_location_update(client_container_name=client_container_name, logger_obj=logger, loc=loc) status = execute( docker_execute_command, client_container_id, 'subscription-manager identity', host=DOCKER_VM, )[DOCKER_VM] assert org.name in status install_or_update_package(client_hostname=client_container_id, package=RPM1_NAME) scenario_dict = { self.__class__.__name__: { 'content_view_name': content_view.name, 'lce_id': lce.id, 'lce_name': lce.name, 'org_label': org.label, 'prod_label': product.label, 'rhel_client': rhel7_client, 'repo_name': repo.name, } } create_dict(scenario_dict)