diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 7da1f9608ee..00000000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 100 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 79dd0cd9a28..5fda357b321 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,7 +15,6 @@ updates: - "6.14.z" - "6.13.z" - "6.12.z" - - "6.11.z" # Maintain dependencies for our GitHub Actions - package-ecosystem: "github-actions" @@ -28,4 +27,3 @@ updates: - "6.14.z" - "6.13.z" - "6.12.z" - - "6.11.z" diff --git a/.github/workflows/auto_cherry_pick.yml b/.github/workflows/auto_cherry_pick.yml index 43e1c8c43b7..14a833977b3 100644 --- a/.github/workflows/auto_cherry_pick.yml +++ b/.github/workflows/auto_cherry_pick.yml @@ -10,6 +10,7 @@ env: assignee: ${{ github.event.pull_request.assignee.login }} title: ${{ github.event.pull_request.title }} number: ${{ github.event.number }} + is_dependabot_pr: '' jobs: @@ -40,12 +41,24 @@ jobs: label: ${{ github.event.pull_request.labels.*.name }} steps: + # Needed to avoid out-of-memory error + - name: Set Swap Space + uses: pierotofy/set-swap-space@master + with: + swap-size-gb: 10 + ## Robottelo Repo Checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 if: ${{ startsWith(matrix.label, '6.') && matrix.label != github.base_ref }} with: fetch-depth: 0 + ## Set env var for dependencies label PR + - name: Set env var is_dependabot_pr to `dependencies` to set the label + if: contains(github.event.pull_request.labels.*.name, 'dependencies') + run: | + echo "is_dependabot_pr=dependencies" >> $GITHUB_ENV + ## CherryPicking and AutoMerging - name: Cherrypicking to zStream branch id: cherrypick @@ -58,6 +71,7 @@ jobs: Auto_Cherry_Picked ${{ matrix.label }} No-CherryPick + ${{ env.is_dependabot_pr }} assignees: ${{ env.assignee }} - name: Add Parent PR's PRT comment to Auto_Cherry_Picked PR's diff --git a/.github/workflows/dependency_merge.yml b/.github/workflows/dependency_merge.yml index 3e1c62e5a97..be56def8996 100644 --- a/.github/workflows/dependency_merge.yml +++ b/.github/workflows/dependency_merge.yml @@ -17,7 +17,7 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/dispatch_release.yml b/.github/workflows/dispatch_release.yml index dc57c0bc877..51b6b90919a 100644 --- a/.github/workflows/dispatch_release.yml +++ b/.github/workflows/dispatch_release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Git User setup run: "git config --local user.email Satellite-QE.satqe.com && git config --local user.name Satellite-QE" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index cc58fb9177a..fc61b228cbc 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,7 +18,7 @@ jobs: python-version: ['3.10', '3.11'] steps: - name: Checkout Robottelo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Up Python-${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -46,18 +46,25 @@ jobs: - name: Collect Tests run: | + # To skip vault login in pull request checks + export VAULT_SECRET_ID_FOR_DYNACONF=somesecret pytest --collect-only --disable-pytest-warnings tests/foreman/ tests/robottelo/ pytest --collect-only --disable-pytest-warnings -m pre_upgrade tests/upgrades/ pytest --collect-only --disable-pytest-warnings -m post_upgrade tests/upgrades/ - name: Collect Tests with xdist run: | + # To skip vault login in pull request checks + export VAULT_SECRET_ID_FOR_DYNACONF=somesecret pytest --collect-only --setup-plan --disable-pytest-warnings -n 2 tests/foreman/ tests/robottelo/ pytest --collect-only --setup-plan --disable-pytest-warnings -n 2 -m pre_upgrade tests/upgrades/ pytest --collect-only --setup-plan --disable-pytest-warnings -n 2 -m post_upgrade tests/upgrades/ - name: Run Robottelo's Tests - run: pytest -sv tests/robottelo/ + run: | + # To skip vault login in pull request checks + export VAULT_SECRET_ID_FOR_DYNACONF=somesecret + pytest -sv tests/robottelo/ - name: Make Docs run: | diff --git a/.github/workflows/update_robottelo_image.yml b/.github/workflows/update_robottelo_image.yml index 2b2e4654bdc..945f76b15dc 100644 --- a/.github/workflows/update_robottelo_image.yml +++ b/.github/workflows/update_robottelo_image.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get image tag id: image_tag diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index e19f5b02a4d..317eccf6871 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.11] steps: - name: Checkout Robottelo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Up Python-${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7626efe6a69..c86df504763 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,31 +1,22 @@ # configuration for pre-commit git hooks repos: -- repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: - id: trailing-whitespace exclude: tests/foreman/data/ - - id: end-of-file-fixer - id: check-yaml - id: debug-statements -- repo: https://github.com/asottile/pyupgrade - rev: v3.3.0 - hooks: - - id: pyupgrade - args: [--py38-plus] - repo: https://github.com/psf/black rev: 22.10.0 hooks: - id: black -- repo: https://github.com/pycqa/flake8 - rev: 6.0.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.277 hooks: - - id: flake8 + - id: ruff + args: [--fix, --exit-non-zero-on-fix] - repo: local hooks: - id: fix-uuids diff --git a/BEST_PRACTICES.md b/BEST_PRACTICES.md new file mode 100644 index 00000000000..a0b41a4dfd2 --- /dev/null +++ b/BEST_PRACTICES.md @@ -0,0 +1,149 @@ +# Helpers Best Practices - Guide +Welcome to the **Helpers Best Practices Guide**! This comprehensive guide is designed to assist contributors in locating existing helpers and adding new ones to the right place, making them accessible through appropriate objects, fixtures, and importables. By following these best practices, we aim to improve the organization of helpers within the framework, enhance the discovery of helpful tools, and minimize the duplication of helper definitions and maintenance efforts. + +## Introduction +The scattered and misaligned placement of helpers within the framework can lead to challenges in discovering and managing helpers, resulting in duplicated definitions and increased maintenance overhead. To address these issues, we have outlined best practices for defining helper functions, modules, classes and fixtures. These guidelines will help you make informed decisions about where to place different types of helpers within the framework. + + +## General Practices +Here are some general best practices for helper management: +- **Prefer API Calls**: When creating test setups, prioritize using API calls (nailgun methods) over UI and CLI interactions, as they tend to be faster and more efficient, unless there is a specific need for specific endpoint based setups. UI setups should be the last resort. +- **Utilize `target_sat` Fixtures**: Ensure that all tests make use of target satellite fixtures to access a wide range of helper methods provided by the satellite object. +- **Non-Reusable helpers**: If helper/fixture is not reusable, keep them closer to test in test module itself. +- **No one liner functions**: If the helper function is just a one-liner, It's recommended to directly replace the function code where it's used. + +## Python Packages and Modules: + +### pytest_fixtures + +In the `pytest_fixtures` Python package, we provide globally accessible fixtures for use in all tests and fixtures. These fixtures are cached by scopes, making them highly reusable without the need for reimplementation. There are two types of fixtures within this package: + +#### Components +- Component fixtures serve as setup and teardown utilities for component tests. +- Each individual fixture module in this package contains and represents fixtures for specific components. + +#### Core +- Core fixtures are framework-level fixtures that serve as setup and teardown for component tests. +- Several special fixture modules deserve mention here: + - `broker.py`: Contains all the `target_sat` fixtures, scoped by usage, which should be used in every functional test in `robottelo`. These fixtures return the same satellite instance for all scoped fixtures, provided that the calling test does not have a destructive marker. For tests with destructive markers, they return a new satellite instance from an image. + - `contenthosts.py`: Houses all content host creation fixtures. All fixture markers for content hosts should be added here since the `fixture_markers` pytest plugin operates on these fixtures, adding markers and user properties to tests that use them. + - `sat_cap_factory.py`: Contains fixtures that create satellites/capsules from scratch without using the xDist satellite. These fixtures should be placed here, as the `factory_collection` pytest plugin operates on them, adding markers to tests that use these fixtures. + - `xdist.py`: Includes the xDist distribution session-scoped fixture, which distributes and generates satellites for running Robottelo tests. The behavior of xDist is based on the `xdist_behavior` set in the `server.yaml` configuration file. + +### Robottelo + +#### host_helpers +- `api_factory.py` + - This module contains the `APIFactory` class. Helpers within this class facilitate integrated operations between components of the satellite object using satellite API calls. + - Since we favor API test setups, this class is the preferred location for adding generic helpers that can be used across UI, CLI, and API tests. + - Helpers added to this class or inherited by this class can be accessed as `sat_obj.api_factory.helper_func_name()`. + +- `cli_factory.py` + - This module contains the `CLIFactory` class. Helpers within this class enable integrated operations between components of the satellite object using satellite CLI hammer commands. + - While it is not our primary choice to add more CLI-based helpers, this class is the appropriate place to add them if the test demands it. + - Helpers added to this class or inherited by this class can be accessed as `sat_obj.cli_factory.helper_func_name()`. + +- `ui_factory.py` + - This module contains a `UIFactory` class that accepts a session object as a parameter. Helpers within this class enable integrated operations between components of the satellite object using the satellite UI. + - Although adding more UI-based helpers is not our preference, this class is suitable for adding them if the test demands it. + - Helpers added to this class or inherited by this class can be accessed as `sat_obj.ui_factory(session).helper_func_name()`. + - The session object provided here is the existing session object from the test case where the helper is being accessed. + - One can use different session object when session is created for different user parameters if needed. + +- `*_mixins.py` + - Classes in mixin modules are inherited by the `Satellite`, `Capsule`, and `Host` classes in the `robottelo/hosts.py` module. Refer to the `hosts.py` module section for more details on that class. + - Mixin classes in these mixin modules and their methods extend functionalities for the host classes in `robottelo/hosts.py` mentioned on above line. + - Unlike methods in `robottelo/hosts.py`, these methods do not pertain to the hosts themselves but perform operations on those hosts and integration between host components. + +#### utils + - Helpers/Utilities which are not directly related to any host object (that does not need operations on hosts) should be added to utils package. + - We have special utility modules for a specific subject. One can add utility helpers in those modules if the helper relates to any of the utlity modules or create new module for new specific subject. + - If the helper does not fit into any of the existing utils modules or subject of helper(s) is not big enough to create new , then add in `robottelo/utils/__init__.py` as a standalone helper. + +#### hosts.py +The `hosts.py` module primarily contains three main classes that represent RedHat Satellite's hosts. Each higher ordered class here inherits the behavior of the previous host class.: + +- **ContentHost**: + - This class represents the ContentHost or Client, including crucial properties and methods that describe these hosts. + - Properties like `hostname` specify details about specific ContentHosts. + - The `nailgun_host` property returns the API/nailgun object for the ContentHost. + - Methods within this class manage operations on ContentHosts, particularly for reconfiguring them. Other operational methods are part of the ContentHost mixins. + - This class inherits methods from `Brokers` modules `Host` class, hence methods from that class are available with this class objects. +- **Capsule**: + - This class represents the Capsule host and includes essential properties and methods that describe the Capsule host. + - Properties like `url` and `is_stream` specify details about the specific Capsule host. + - The `satellite` property returns the satellite object to which the Capsule is connected. + - Methods within this class manage operations related to the Capsule, especially for reconfiguring it via installation processes. Other operational methods are part of the Capsule mixins. e.g `sat.restart_services()` + - This class inherits methods from ContentHost class, hence methods from these classes are available with this class objects. +- **Satellite**: + - This class serves as the representation of the Satellite host and includes essential properties and methods that describe the Satellite host. + - Properties like `hostname` and `port` specify specific details about the Satellite host. + - Properties like `api`, `cli`, and `ui_session` provide access to interface objects that expose satellite components through various endpoints. For example, you can access these components as `sat.api.ActivationKey`, `sat.cli.ActivationKey`, or `sat.ui_session.ActivationKey`. + - Methods within this class handle satellite operations, especially for reconfiguring the satellite via installation processes etc. Other operational methods are part of the Satellite mixins, including factories. e.g `sat.capsule_certs_generate()` + - This class inherits methods from ContentHost and Capsule classes, hence methods from those classes are available with this class objects. + +By adhering to these best practices, you'll contribute to the efficient organization and accessibility of helpers within the framework, enhancing the overall development experience and maintainability + of the project. Thank you for your commitment to best practices! + + +## FAQs: + +_**Question. When should I prefer/not prefer fixtures over to helper function when implementing a new helper ?**_ + +_Answer:_ The answers could be multiple. Fixture over functions are preferred when: + - A new helper function should be cached based on scope of the function usage. + - A new helper has dependency on other fixtures. + - A new helper provides the facility of setup and teardown in the helper function itself. + - A new helper as a fixture accept parameters, allowing you to create dynamic test scenarios. + +_**Question. Where should I implement the fixture that could be used by all tests from all endpoints?**_ + + _Answer:_ The global package `pytest_fixtures` is the recommended place. Choose the right subpackage `core` if framework fixture `component` if component fixture. + +_**Question. Where should we implement the helper functions needed by fixtures ?**_ + + _Answer:_ It is preferred to use reusable helper function in utils modules but if the function is not reusable, it should live in the fixture own module. + +_**Question. Whats the most preferred user interface for writing helper that could be used across all three interfaces tests ?**_ + + _Answer:_ API helpers are preferred but if test demands setup from UI/CLI interfaces then the helper should be added in those interfaces. + +_**Question. I want to create a property / method to describe satellite/capsule/host, where should I add that property ?**_ + + _Answer:_ Satellite/Caspule/ContentHost classes (but not in their mixins) are the best to add properties/methods that describe those. + +_**Question. I want to perform operations on Satellite/Capsule/ContentHost like execute CLI commands, read conf files etc, where should I add a method for that?**_ + + _Answer:_ Add into existing mixin classes in mixin modules in `robottelo/host_helpers/*_mixins.py` or create a new targeted mixin class and inherit than in host classes of `robottelo/hosts.py` module + +_**Question. I have new CLI or UI or API entity or operation to implement, should it be in factory object or endpoint object.**_ + + _Answer:_ New entity/subcommand/operations added in satellite product should be added to be accessed by endpoint onjects. e.g `target_sat.api.ComponentNew()`. The factory objects are just for adding helpers. + +_**Question. When should I prefer helper function as a host object method over utils function ?**_ + + _Answer:_ When the new function is dependent on existing host methods or attributes then its good implement such helper function in host classes as it makes to access those host methods and attributes easier. + +_**Question. What helper functions goes into `robottelo/utils/__init__.py` module?**_ + + _Answer:_ If the helper does not fit into any of the existing utils modules or subject of helper(s) is not big enough to create new , then add in `robottelo/utils/__init__.py` as a standalone helper. + +_**Question. I have a helper function that applies to all Satellite, Capsule, ContentHost classes. Which class should I choose to add it?**_ + + _Answer:_ The recommeded class in such cases is always the highest parent class. Here ContentHost class is the highest parent class where this function should be added as a class method or a mixin method. + +_**Question. I have some upgrade scenario helpers to implement, where should I add them?**_ + + _Answer:_ Upgrade scenarios are not special in this case. All helpers/function except framework should be same as being used in foreman tests and hence all rules are applied. + +_**Question. Where should a non-reusable helper function reside?**_ + + _Answer:_ The preffered place is the test module where its being used. + +_**Question. I need to extend the functionality of third party library methods/objects, should I do it in robottelo?**_ + + _Answer:_ Its recommended to extend the functionality of third library methods in that library itself if its being maintained by SatelliteQE like airgun,nailgun, manifester or is active community like widgetastic, wrapanapi. Else extend that appropriately in utils, host methods or fixtures. + +_**Question. What if I see two helper methods/functions almost doing equal operations with a little diff ?**_ + + _Answer:_ See if this could be merged in one function with optional parameters else leave them separated. E.g provisioning functions using API calls with minimum difference and being used in API, UI and CLI tests then merge them. But if two provisioning helpers one for CLI and API tests and tests demands it then good to keep it separate. diff --git a/conftest.py b/conftest.py index 91eb0d54ae9..c58f71c991b 100644 --- a/conftest.py +++ b/conftest.py @@ -3,6 +3,7 @@ pytest_plugins = [ # Plugins + 'pytest_plugins.auto_vault', 'pytest_plugins.disable_rp_params', 'pytest_plugins.external_logging', 'pytest_plugins.fixture_markers', diff --git a/pyproject.toml b/pyproject.toml index 2a45bb81ace..b042ee54c72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,38 @@ exclude = ''' )/ ''' +[tool.ruff] +target-version = "py311" +fixable = ["ALL"] + +select = [ + # "C90", # mccabe + "E", # pycodestyle + "F", # flake8 + "I", # isort + # "Q", # flake8-quotes + "UP", # pyupgrade + "W", # pycodestyle +] + +ignore = [ + "E501", # line too long - handled by black +] + +[tool.ruff.isort] +force-sort-within-sections = true +known-first-party = [ + "robottelo", +] +combine-as-imports = true + + +[tool.ruff.flake8-quotes] +inline-quotes = "single" + +[tool.ruff.mccabe] +max-complexity = 20 + [tool.pytest.ini_options] junit_logging = 'all' addopts = '--show-capture=no' diff --git a/pytest_fixtures/component/acs.py b/pytest_fixtures/component/acs.py index df222b90553..065e64d935f 100644 --- a/pytest_fixtures/component/acs.py +++ b/pytest_fixtures/component/acs.py @@ -1,8 +1,7 @@ # Alternate Content Sources fixtures import pytest -from robottelo.constants.repos import CUSTOM_FILE_REPO -from robottelo.constants.repos import CUSTOM_RPM_REPO +from robottelo.constants.repos import CUSTOM_FILE_REPO, CUSTOM_RPM_REPO @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/computeprofile.py b/pytest_fixtures/component/computeprofile.py index 859dc64abd0..3f2cce6043c 100644 --- a/pytest_fixtures/component/computeprofile.py +++ b/pytest_fixtures/component/computeprofile.py @@ -1,6 +1,6 @@ # Compute Profile Fixtures -import pytest from nailgun import entities +import pytest @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/contentview.py b/pytest_fixtures/component/contentview.py index e82f69d04b5..c1879f43338 100644 --- a/pytest_fixtures/component/contentview.py +++ b/pytest_fixtures/component/contentview.py @@ -1,6 +1,6 @@ # Content View Fixtures -import pytest from nailgun.entity_mixins import call_entity_method_with_timeout +import pytest from robottelo.constants import DEFAULT_CV diff --git a/pytest_fixtures/component/domain.py b/pytest_fixtures/component/domain.py index 5cc524ff3b5..c62b45f54d5 100644 --- a/pytest_fixtures/component/domain.py +++ b/pytest_fixtures/component/domain.py @@ -1,6 +1,6 @@ # Domain Fixtures -import pytest from nailgun import entities +import pytest @pytest.fixture(scope='session') diff --git a/pytest_fixtures/component/host.py b/pytest_fixtures/component/host.py index 1fb55a33001..4f070a86a64 100644 --- a/pytest_fixtures/component/host.py +++ b/pytest_fixtures/component/host.py @@ -1,14 +1,10 @@ # Host Specific Fixtures -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.factory import setup_org_for_a_rh_repo -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import DEFAULT_CV, ENVIRONMENT, PRDS, REPOS, REPOSET @pytest.fixture diff --git a/pytest_fixtures/component/hostgroup.py b/pytest_fixtures/component/hostgroup.py index 43b2668b6e2..65be6196183 100644 --- a/pytest_fixtures/component/hostgroup.py +++ b/pytest_fixtures/component/hostgroup.py @@ -1,6 +1,6 @@ # Hostgroup Fixtures -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.logging import logger diff --git a/pytest_fixtures/component/katello_agent.py b/pytest_fixtures/component/katello_agent.py index b25304cb8ae..0428f91a740 100644 --- a/pytest_fixtures/component/katello_agent.py +++ b/pytest_fixtures/component/katello_agent.py @@ -1,5 +1,5 @@ -import pytest from box import Box +import pytest from robottelo.config import settings from robottelo.utils.installer import InstallerCommand @@ -48,7 +48,9 @@ def katello_agent_client(sat_with_katello_agent, rhel_contenthost): org = sat_with_katello_agent.api.Organization().create() client_repo = settings.repos['SATCLIENT_REPO'][f'RHEL{rhel_contenthost.os_version.major}'] sat_with_katello_agent.register_host_custom_repo( - org, rhel_contenthost, [client_repo, settings.repos.yum_1.url] + org, + rhel_contenthost, + [client_repo, settings.repos.yum_1.url], ) rhel_contenthost.install_katello_agent() host_info = sat_with_katello_agent.cli.Host.info({'name': rhel_contenthost.hostname}) diff --git a/pytest_fixtures/component/katello_certs_check.py b/pytest_fixtures/component/katello_certs_check.py index d9150fa539b..f14299ebd52 100644 --- a/pytest_fixtures/component/katello_certs_check.py +++ b/pytest_fixtures/component/katello_certs_check.py @@ -1,8 +1,8 @@ # katello_certs_check Fixtures from pathlib import Path -import pytest from fauxfactory import gen_string +import pytest from robottelo.constants import CERT_DATA as cert_data from robottelo.hosts import Capsule diff --git a/pytest_fixtures/component/maintain.py b/pytest_fixtures/component/maintain.py index ff8e8387c4b..152656f8dc1 100644 --- a/pytest_fixtures/component/maintain.py +++ b/pytest_fixtures/component/maintain.py @@ -6,8 +6,8 @@ from robottelo import constants from robottelo.config import settings from robottelo.constants import SATELLITE_MAINTAIN_YML -from robottelo.hosts import Capsule -from robottelo.hosts import Satellite +from robottelo.hosts import Capsule, Satellite, SatelliteHostError +from robottelo.logging import logger synced_repos = pytest.StashKey[dict] @@ -21,16 +21,27 @@ def module_stash(request): yield request.node.stash -@pytest.fixture(scope='session') -def sat_maintain(request, session_target_sat, session_capsule_configured): +@pytest.fixture(scope='module') +def sat_maintain(request, module_target_sat, module_capsule_configured): if settings.remotedb.server: yield Satellite(settings.remotedb.server) else: - session_target_sat.register_to_cdn(pool_ids=settings.subscription.fm_rhn_poolid.split()) - hosts = {'satellite': session_target_sat, 'capsule': session_capsule_configured} + module_target_sat.register_to_cdn(pool_ids=settings.subscription.fm_rhn_poolid.split()) + hosts = {'satellite': module_target_sat, 'capsule': module_capsule_configured} yield hosts[request.param] +@pytest.fixture +def start_satellite_services(sat_maintain): + """Teardown for satellite-maintain tests to ensure that all Satellite services are started""" + yield + logger.info('Ensuring that all %s services are running', sat_maintain.__class__.__name__) + result = sat_maintain.cli.Service.start() + if result.status != 0: + logger.error('Unable to start all %s services', sat_maintain.__class__.__name__) + raise SatelliteHostError('Failed to start Satellite services') + + @pytest.fixture def setup_backup_tests(request, sat_maintain): """Teardown for backup/restore tests""" @@ -42,9 +53,7 @@ def _finalize(): @pytest.fixture(scope='module') -def module_synced_repos( - sat_maintain, session_capsule_configured, module_sca_manifest, module_stash -): +def module_synced_repos(sat_maintain, module_capsule_configured, module_sca_manifest, module_stash): if not module_stash[synced_repos]: org = sat_maintain.satellite.api.Organization().create() sat_maintain.satellite.upload_manifest(org.id, module_sca_manifest.content) @@ -80,13 +89,13 @@ def module_synced_repos( lce = sat_maintain.satellite.api.LifecycleEnvironment( organization=module_stash[synced_repos]['org'] ).search(query={'search': f'name={constants.ENVIRONMENT}'})[0] - session_capsule_configured.nailgun_capsule.content_add_lifecycle_environment( + module_capsule_configured.nailgun_capsule.content_add_lifecycle_environment( data={'environment_id': lce.id} ) - result = session_capsule_configured.nailgun_capsule.content_lifecycle_environments() + result = module_capsule_configured.nailgun_capsule.content_lifecycle_environments() assert lce.id in [capsule_lce['id'] for capsule_lce in result['results']] # sync the Capsule - sync_status = session_capsule_configured.nailgun_capsule.content_sync() + sync_status = module_capsule_configured.nailgun_capsule.content_sync() assert sync_status['result'] == 'success' yield { diff --git a/pytest_fixtures/component/os.py b/pytest_fixtures/component/os.py index 6d11e9c94fd..e6039c1b6f9 100644 --- a/pytest_fixtures/component/os.py +++ b/pytest_fixtures/component/os.py @@ -1,6 +1,6 @@ # Operating System Fixtures -import pytest from nailgun import entities +import pytest @pytest.fixture(scope='session') diff --git a/pytest_fixtures/component/oscap.py b/pytest_fixtures/component/oscap.py index 6fdd3866c29..356050f94a7 100644 --- a/pytest_fixtures/component/oscap.py +++ b/pytest_fixtures/component/oscap.py @@ -1,15 +1,12 @@ from pathlib import PurePath -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.factory import make_scapcontent -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import OSCAP_PROFILE -from robottelo.constants import OSCAP_TAILORING_FILE +from robottelo.config import robottelo_tmp_dir, settings +from robottelo.constants import OSCAP_PROFILE, OSCAP_TAILORING_FILE, DataFile @pytest.fixture(scope="session") diff --git a/pytest_fixtures/component/provision_azure.py b/pytest_fixtures/component/provision_azure.py index d1fe7f1f128..0483758b51a 100644 --- a/pytest_fixtures/component/provision_azure.py +++ b/pytest_fixtures/component/provision_azure.py @@ -1,15 +1,17 @@ # Azure CR Fixtures -import pytest from fauxfactory import gen_string +import pytest from wrapanapi import AzureSystem from robottelo.config import settings -from robottelo.constants import AZURERM_RHEL7_FT_BYOS_IMG_URN -from robottelo.constants import AZURERM_RHEL7_FT_CUSTOM_IMG_URN -from robottelo.constants import AZURERM_RHEL7_FT_GALLERY_IMG_URN -from robottelo.constants import AZURERM_RHEL7_FT_IMG_URN -from robottelo.constants import AZURERM_RHEL7_UD_IMG_URN -from robottelo.constants import DEFAULT_ARCHITECTURE +from robottelo.constants import ( + AZURERM_RHEL7_FT_BYOS_IMG_URN, + AZURERM_RHEL7_FT_CUSTOM_IMG_URN, + AZURERM_RHEL7_FT_GALLERY_IMG_URN, + AZURERM_RHEL7_FT_IMG_URN, + AZURERM_RHEL7_UD_IMG_URN, + DEFAULT_ARCHITECTURE, +) @pytest.fixture(scope='session') diff --git a/pytest_fixtures/component/provision_gce.py b/pytest_fixtures/component/provision_gce.py index fbdb2a886e9..af260bdb38c 100644 --- a/pytest_fixtures/component/provision_gce.py +++ b/pytest_fixtures/component/provision_gce.py @@ -2,16 +2,18 @@ import json from tempfile import mkstemp -import pytest from fauxfactory import gen_string +import pytest from wrapanapi.systems.google import GoogleCloudSystem from robottelo.config import settings -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_PTABLE -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import GCE_RHEL_CLOUD_PROJECTS -from robottelo.constants import GCE_TARGET_RHEL_IMAGE_NAME +from robottelo.constants import ( + DEFAULT_ARCHITECTURE, + DEFAULT_PTABLE, + FOREMAN_PROVIDERS, + GCE_RHEL_CLOUD_PROJECTS, + GCE_TARGET_RHEL_IMAGE_NAME, +) from robottelo.exceptions import GCECertNotFoundError diff --git a/pytest_fixtures/component/provision_libvirt.py b/pytest_fixtures/component/provision_libvirt.py index 16f2d962e27..d8638d9a32a 100644 --- a/pytest_fixtures/component/provision_libvirt.py +++ b/pytest_fixtures/component/provision_libvirt.py @@ -12,3 +12,10 @@ def module_cr_libvirt(module_target_sat, module_org, module_location): @pytest.fixture(scope='module') def module_libvirt_image(module_target_sat, module_cr_libvirt): return module_target_sat.api.Image(compute_resource=module_cr_libvirt).create() + + +@pytest.fixture(scope='module') +def module_libvirt_provisioning_sat(module_provisioning_sat): + # Configure Libvirt CR for provisioning + module_provisioning_sat.sat.configure_libvirt_cr() + yield module_provisioning_sat diff --git a/pytest_fixtures/component/provision_pxe.py b/pytest_fixtures/component/provision_pxe.py index aaa9837b810..1fc0e47397b 100644 --- a/pytest_fixtures/component/provision_pxe.py +++ b/pytest_fixtures/component/provision_pxe.py @@ -3,11 +3,11 @@ import re from tempfile import mkstemp -import pytest from box import Box from broker import Broker from fauxfactory import gen_string from packaging.version import Version +import pytest from robottelo import constants from robottelo.config import settings @@ -285,6 +285,7 @@ def pxe_loader(request): PXE_LOADER_MAP = { 'bios': {'vm_firmware': 'bios', 'pxe_loader': 'PXELinux BIOS'}, 'uefi': {'vm_firmware': 'uefi', 'pxe_loader': 'Grub2 UEFI'}, + 'ipxe': {'vm_firmware': 'bios', 'pxe_loader': 'iPXE Embedded'}, } return Box(PXE_LOADER_MAP[getattr(request, 'param', 'bios')]) diff --git a/pytest_fixtures/component/provisioning_template.py b/pytest_fixtures/component/provisioning_template.py index 6b8e96de7e9..cb4ea6d84d5 100644 --- a/pytest_fixtures/component/provisioning_template.py +++ b/pytest_fixtures/component/provisioning_template.py @@ -1,13 +1,11 @@ # Provisioning Template Fixtures -import pytest from box import Box from nailgun import entities from packaging.version import Version +import pytest from robottelo import constants -from robottelo.constants import DEFAULT_PTABLE -from robottelo.constants import DEFAULT_PXE_TEMPLATE -from robottelo.constants import DEFAULT_TEMPLATE +from robottelo.constants import DEFAULT_PTABLE, DEFAULT_PXE_TEMPLATE, DEFAULT_TEMPLATE @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/repository.py b/pytest_fixtures/component/repository.py index 1cc17092768..2336bf12e5a 100644 --- a/pytest_fixtures/component/repository.py +++ b/pytest_fixtures/component/repository.py @@ -1,13 +1,10 @@ # Repository Fixtures -import pytest from fauxfactory import gen_string from nailgun import entities from nailgun.entity_mixins import call_entity_method_with_timeout +import pytest -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import DEFAULT_ARCHITECTURE, PRDS, REPOS, REPOSET @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/satellite_auth.py b/pytest_fixtures/component/satellite_auth.py index e37c6cb9609..9c39ed3ade3 100644 --- a/pytest_fixtures/component/satellite_auth.py +++ b/pytest_fixtures/component/satellite_auth.py @@ -1,20 +1,21 @@ import copy import socket -import pytest from box import Box from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import AUDIENCE_MAPPER -from robottelo.constants import CERT_PATH -from robottelo.constants import GROUP_MEMBERSHIP_MAPPER -from robottelo.constants import HAMMER_CONFIG -from robottelo.constants import HAMMER_SESSIONS -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE -from robottelo.hosts import IPAHost -from robottelo.hosts import SSOHost +from robottelo.constants import ( + AUDIENCE_MAPPER, + CERT_PATH, + GROUP_MEMBERSHIP_MAPPER, + HAMMER_CONFIG, + HAMMER_SESSIONS, + LDAP_ATTR, + LDAP_SERVER_TYPE, +) +from robottelo.hosts import IPAHost, SSOHost from robottelo.utils.datafactory import gen_string from robottelo.utils.installer import InstallerCommand from robottelo.utils.issue_handlers import is_open diff --git a/pytest_fixtures/component/smartproxy.py b/pytest_fixtures/component/smartproxy.py index 3b711dfbeff..d879eff5d3a 100644 --- a/pytest_fixtures/component/smartproxy.py +++ b/pytest_fixtures/component/smartproxy.py @@ -13,11 +13,6 @@ def default_smart_proxy(session_target_sat): return session_target_sat.api.SmartProxy(id=smart_proxy.id).read() -@pytest.fixture(scope='session') -def import_puppet_classes(default_smart_proxy): - default_smart_proxy.import_puppetclasses(environment='production') - - @pytest.fixture(scope='module') def module_fake_proxy(request, module_target_sat): """Create a Proxy and register the cleanup function""" diff --git a/pytest_fixtures/component/subnet.py b/pytest_fixtures/component/subnet.py index e43f9952652..0e1ddb1b782 100644 --- a/pytest_fixtures/component/subnet.py +++ b/pytest_fixtures/component/subnet.py @@ -1,6 +1,6 @@ # Subnet Fixtures -import pytest from nailgun import entities +import pytest @pytest.fixture(scope='module') diff --git a/pytest_fixtures/component/taxonomy.py b/pytest_fixtures/component/taxonomy.py index 2276b3c3b88..faad21122e5 100644 --- a/pytest_fixtures/component/taxonomy.py +++ b/pytest_fixtures/component/taxonomy.py @@ -1,10 +1,9 @@ # Content Component fixtures -import pytest from manifester import Manifester +import pytest from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import DEFAULT_ORG +from robottelo.constants import DEFAULT_LOC, DEFAULT_ORG from robottelo.utils.manifest import clone diff --git a/pytest_fixtures/component/templatesync.py b/pytest_fixtures/component/templatesync.py index 6b5881a95fc..3dee193cdd3 100644 --- a/pytest_fixtures/component/templatesync.py +++ b/pytest_fixtures/component/templatesync.py @@ -1,6 +1,6 @@ +from fauxfactory import gen_string import pytest import requests -from fauxfactory import gen_string from robottelo.config import settings from robottelo.constants import FOREMAN_TEMPLATE_ROOT_DIR @@ -24,7 +24,7 @@ def create_import_export_local_dir(target_sat): f'mkdir -p {dir_path} && ' f'chown foreman -R {root_dir} && ' f'restorecon -R -v {root_dir} && ' - f'chcon -t httpd_sys_rw_content_t {dir_path} -R' + f'chcon -t foreman_lib_t {dir_path} -R' ) if result.status != 0: logger.debug(result.stdout) diff --git a/pytest_fixtures/component/user.py b/pytest_fixtures/component/user.py index fea405520e4..3f4d1034e6e 100644 --- a/pytest_fixtures/component/user.py +++ b/pytest_fixtures/component/user.py @@ -1,5 +1,5 @@ -import pytest from nailgun import entities +import pytest @pytest.fixture diff --git a/pytest_fixtures/component/user_role.py b/pytest_fixtures/component/user_role.py index 8e4f3f00bea..92b742e6966 100644 --- a/pytest_fixtures/component/user_role.py +++ b/pytest_fixtures/component/user_role.py @@ -1,7 +1,6 @@ -import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string +from fauxfactory import gen_alphanumeric, gen_string from nailgun import entities +import pytest @pytest.fixture(scope='class') diff --git a/pytest_fixtures/core/broker.py b/pytest_fixtures/core/broker.py index 4c89dea35c5..9d207fcd9d7 100644 --- a/pytest_fixtures/core/broker.py +++ b/pytest_fixtures/core/broker.py @@ -1,13 +1,11 @@ from contextlib import contextmanager -import pytest from box import Box from broker import Broker +import pytest from robottelo.config import settings -from robottelo.hosts import ContentHostError -from robottelo.hosts import lru_sat_ready_rhel -from robottelo.hosts import Satellite +from robottelo.hosts import ContentHostError, Satellite, lru_sat_ready_rhel @pytest.fixture(scope='session') diff --git a/pytest_fixtures/core/contenthosts.py b/pytest_fixtures/core/contenthosts.py index 131beda131d..586fa95eb57 100644 --- a/pytest_fixtures/core/contenthosts.py +++ b/pytest_fixtures/core/contenthosts.py @@ -4,13 +4,12 @@ The functions in this module are read in the pytest_plugins/fixture_markers.py module All functions in this module will be treated as fixtures that apply the contenthost mark """ -import pytest from broker import Broker +import pytest from robottelo import constants from robottelo.config import settings -from robottelo.hosts import ContentHost -from robottelo.hosts import Satellite +from robottelo.hosts import ContentHost, Satellite def host_conf(request): diff --git a/pytest_fixtures/core/reporting.py b/pytest_fixtures/core/reporting.py index 24f1124f4c6..baf9d3cde7d 100644 --- a/pytest_fixtures/core/reporting.py +++ b/pytest_fixtures/core/reporting.py @@ -1,12 +1,10 @@ import datetime -import pytest from _pytest.junitxml import xml_key +import pytest from xdist import get_xdist_worker_id -from robottelo.config import setting_is_set -from robottelo.config import settings - +from robottelo.config import setting_is_set, settings FMT_XUNIT_TIME = '%Y-%m-%dT%H:%M:%S' diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 018a89fdc24..f08e722cbbf 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -1,17 +1,17 @@ from contextlib import contextmanager -import pytest from broker import Broker +import pytest from wait_for import wait_for -from robottelo.config import configure_airgun -from robottelo.config import configure_nailgun -from robottelo.config import settings -from robottelo.hosts import Capsule -from robottelo.hosts import get_sat_rhel_version -from robottelo.hosts import IPAHost -from robottelo.hosts import lru_sat_ready_rhel -from robottelo.hosts import Satellite +from robottelo.config import configure_airgun, configure_nailgun, settings +from robottelo.hosts import ( + Capsule, + IPAHost, + Satellite, + get_sat_rhel_version, + lru_sat_ready_rhel, +) from robottelo.logging import logger from robottelo.utils.installer import InstallerCommand @@ -301,7 +301,11 @@ def installer_satellite(request): sat.setup_firewall() # # Register for RHEL8 repos, get Ohsnap repofile, and enable and download satellite sat.register_to_cdn() - sat.download_repofile(product='satellite', release=settings.server.version.release) + sat.download_repofile( + product='satellite', + release=settings.server.version.release, + snap=settings.server.version.snap, + ) sat.execute('dnf -y module enable satellite:el8 && dnf -y install satellite') installed_version = sat.execute('rpm --query satellite').stdout assert sat_version in installed_version diff --git a/pytest_fixtures/core/ui.py b/pytest_fixtures/core/ui.py index 0addff500df..7edbd39b731 100644 --- a/pytest_fixtures/core/ui.py +++ b/pytest_fixtures/core/ui.py @@ -1,5 +1,5 @@ -import pytest from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError from robottelo.logging import logger diff --git a/pytest_fixtures/core/upgrade.py b/pytest_fixtures/core/upgrade.py index 291bae18fbf..a79f4867979 100644 --- a/pytest_fixtures/core/upgrade.py +++ b/pytest_fixtures/core/upgrade.py @@ -1,5 +1,5 @@ -import pytest from broker import Broker +import pytest from robottelo.hosts import Capsule from robottelo.logging import logger diff --git a/pytest_fixtures/core/xdist.py b/pytest_fixtures/core/xdist.py index 18088f8a572..4d02fe026d0 100644 --- a/pytest_fixtures/core/xdist.py +++ b/pytest_fixtures/core/xdist.py @@ -1,12 +1,10 @@ """Fixtures specific to or relating to pytest's xdist plugin""" import random -import pytest from broker import Broker +import pytest -from robottelo.config import configure_airgun -from robottelo.config import configure_nailgun -from robottelo.config import settings +from robottelo.config import configure_airgun, configure_nailgun, settings from robottelo.hosts import Satellite from robottelo.logging import logger diff --git a/pytest_plugins/auto_vault.py b/pytest_plugins/auto_vault.py new file mode 100644 index 00000000000..e63fc7f0835 --- /dev/null +++ b/pytest_plugins/auto_vault.py @@ -0,0 +1,10 @@ +"""Plugin enables pytest to notify and update the requirements""" +import subprocess + +from robottelo.utils.vault import Vault + + +def pytest_addoption(parser): + """Options to allow user to update the requirements""" + with Vault() as vclient: + vclient.login(stdout=subprocess.PIPE, stderr=subprocess.PIPE) diff --git a/pytest_plugins/factory_collection.py b/pytest_plugins/factory_collection.py index f8933e45a7b..6472c2b909c 100644 --- a/pytest_plugins/factory_collection.py +++ b/pytest_plugins/factory_collection.py @@ -1,5 +1,4 @@ -from inspect import getmembers -from inspect import isfunction +from inspect import getmembers, isfunction def pytest_configure(config): diff --git a/pytest_plugins/fixture_markers.py b/pytest_plugins/fixture_markers.py index e2126d86dad..888a720d13e 100644 --- a/pytest_plugins/fixture_markers.py +++ b/pytest_plugins/fixture_markers.py @@ -1,10 +1,8 @@ +from inspect import getmembers, isfunction import re -from inspect import getmembers -from inspect import isfunction from robottelo.config import settings - TARGET_FIXTURES = [ 'rhel_contenthost', 'content_hosts', diff --git a/pytest_plugins/issue_handlers.py b/pytest_plugins/issue_handlers.py index d2dfb3be55e..3da2044faff 100644 --- a/pytest_plugins/issue_handlers.py +++ b/pytest_plugins/issue_handlers.py @@ -1,20 +1,21 @@ +from collections import defaultdict +from datetime import datetime import inspect import json import re -from collections import defaultdict -from datetime import datetime import pytest from robottelo.config import settings from robottelo.logging import collection_logger as logger from robottelo.utils import slugify_component -from robottelo.utils.issue_handlers import add_workaround -from robottelo.utils.issue_handlers import bugzilla -from robottelo.utils.issue_handlers import is_open -from robottelo.utils.issue_handlers import should_deselect -from robottelo.utils.version import search_version_key -from robottelo.utils.version import VersionEncoder +from robottelo.utils.issue_handlers import ( + add_workaround, + bugzilla, + is_open, + should_deselect, +) +from robottelo.utils.version import VersionEncoder, search_version_key DEFAULT_BZ_CACHE_FILE = 'bz_cache.json' diff --git a/pytest_plugins/logging_hooks.py b/pytest_plugins/logging_hooks.py index f7bcaf43620..9cd7ea4c84f 100644 --- a/pytest_plugins/logging_hooks.py +++ b/pytest_plugins/logging_hooks.py @@ -4,16 +4,17 @@ import pytest from xdist import is_xdist_worker -from robottelo.logging import broker_log_setup -from robottelo.logging import DEFAULT_DATE_FORMAT -from robottelo.logging import logger -from robottelo.logging import logging_yaml -from robottelo.logging import robottelo_log_dir -from robottelo.logging import robottelo_log_file +from robottelo.logging import ( + DEFAULT_DATE_FORMAT, + broker_log_setup, + logger, + logging_yaml, + robottelo_log_dir, + robottelo_log_file, +) try: - from pytest_reportportal import RPLogger - from pytest_reportportal import RPLogHandler + from pytest_reportportal import RPLogger, RPLogHandler except ImportError: pass @@ -73,5 +74,7 @@ def pytest_runtest_logstart(nodeid, location): logger.info(f'Started Test: {nodeid}') -def pytest_runtest_logfinish(nodeid, location): - logger.info(f'Finished Test: {nodeid}') +def pytest_runtest_logreport(report): + """Process the TestReport produced for each of the setup, + call and teardown runtest phases of an item.""" + logger.info('Finished %s for test: %s, result: %s', report.when, report.nodeid, report.outcome) diff --git a/pytest_plugins/marker_deselection.py b/pytest_plugins/marker_deselection.py index ca68ead0165..ee2cd4c1485 100644 --- a/pytest_plugins/marker_deselection.py +++ b/pytest_plugins/marker_deselection.py @@ -2,7 +2,6 @@ from robottelo.logging import collection_logger as logger - non_satCI_components = ['Virt-whoConfigurePlugin'] diff --git a/pytest_plugins/metadata_markers.py b/pytest_plugins/metadata_markers.py index f409dd804c7..70aee47c6c7 100644 --- a/pytest_plugins/metadata_markers.py +++ b/pytest_plugins/metadata_markers.py @@ -6,7 +6,6 @@ from robottelo.config import settings from robottelo.hosts import get_sat_rhel_version -from robottelo.hosts import get_sat_version from robottelo.logging import collection_logger as logger FMT_XUNIT_TIME = '%Y-%m-%dT%H:%M:%S' @@ -59,7 +58,7 @@ def pytest_configure(config): @pytest.hookimpl(tryfirst=True) -def pytest_collection_modifyitems(session, items, config): +def pytest_collection_modifyitems(items, config): """Add markers and user_properties for testimony token metadata user_properties is used by the junit plugin, and thus by many test report systems @@ -74,7 +73,7 @@ def pytest_collection_modifyitems(session, items, config): """ # get RHEL version of the satellite rhel_version = get_sat_rhel_version().base_version - sat_version = get_sat_version().base_version + sat_version = settings.server.version.get('release') snap_version = settings.server.version.get('snap', '') # split the option string and handle no option, single option, multiple diff --git a/pytest_plugins/requirements/req_updater.py b/pytest_plugins/requirements/req_updater.py index a647fc51e26..664a9bb92a5 100644 --- a/pytest_plugins/requirements/req_updater.py +++ b/pytest_plugins/requirements/req_updater.py @@ -1,5 +1,5 @@ -import subprocess from functools import cached_property +import subprocess class ReqUpdater: diff --git a/pytest_plugins/settings_skip.py b/pytest_plugins/settings_skip.py index 7a211cd32ae..6ee053adee5 100644 --- a/pytest_plugins/settings_skip.py +++ b/pytest_plugins/settings_skip.py @@ -1,7 +1,6 @@ import pytest -from robottelo.config import setting_is_set -from robottelo.config import settings +from robottelo.config import setting_is_set, settings def pytest_configure(config): diff --git a/pytest_plugins/upgrade/scenario_workers.py b/pytest_plugins/upgrade/scenario_workers.py index 87d84b97f86..099ff1c0fe3 100644 --- a/pytest_plugins/upgrade/scenario_workers.py +++ b/pytest_plugins/upgrade/scenario_workers.py @@ -3,10 +3,7 @@ import pytest -from robottelo.config import configure_airgun -from robottelo.config import configure_nailgun -from robottelo.config import settings - +from robottelo.config import configure_airgun, configure_nailgun, settings _json_file = 'upgrade_workers.json' json_file = Path(_json_file) diff --git a/requirements-optional.txt b/requirements-optional.txt index 6a0e2ce2e83..03665f3e3d8 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -2,11 +2,11 @@ flake8==6.1.0 pytest-cov==4.1.0 redis==5.0.0 -pre-commit==3.3.3 +pre-commit==3.4.0 # For generating documentation. -sphinx==7.2.5 -sphinx-autoapi==2.1.1 +sphinx==7.2.6 +sphinx-autoapi==3.0.0 # For 'manage' interactive shell manage==0.1.15 diff --git a/requirements.txt b/requirements.txt index b8bbd702d51..27c5bddb85e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ # Version updates managed by dependabot betelgeuse==1.10.0 -broker[docker]==0.3.3 -cryptography==41.0.3 -deepdiff==6.3.1 -dynaconf[vault]==3.2.2 +broker[docker]==0.4.1 +cryptography==41.0.4 +deepdiff==6.5.0 +dynaconf[vault]==3.2.3 fauxfactory==3.1.0 jinja2==3.1.2 -manifester==0.0.13 +manifester==0.0.14 navmazing==1.1.6 -productmd==1.36 +productmd==1.37 pyotp==2.9.0 python-box==7.1.1 -pytest==7.4.0 +pytest==7.4.2 pytest-services==2.2.1 pytest-mock==3.11.1 -pytest-reportportal==5.2.1 +pytest-reportportal==5.2.2 pytest-xdist==3.3.1 pytest-ibutsu==2.2.4 PyYAML==6.0.1 diff --git a/robottelo/cli/contentview.py b/robottelo/cli/contentview.py index bd1a96fe4c5..fb8001f89d7 100644 --- a/robottelo/cli/contentview.py +++ b/robottelo/cli/contentview.py @@ -34,8 +34,7 @@ -h, --help print help """ from robottelo.cli import hammer -from robottelo.cli.base import Base -from robottelo.cli.base import CLIError +from robottelo.cli.base import Base, CLIError class ContentViewFilterRule(Base): diff --git a/robottelo/cli/factory.py b/robottelo/cli/factory.py index 78deaf5ff29..007fa7dadfd 100644 --- a/robottelo/cli/factory.py +++ b/robottelo/cli/factory.py @@ -3,20 +3,22 @@ """ import datetime import os +from os import chmod import pprint import random -from os import chmod from tempfile import mkstemp from time import sleep -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_netmask -from fauxfactory import gen_string -from fauxfactory import gen_url +from fauxfactory import ( + gen_alphanumeric, + gen_choice, + gen_integer, + gen_ipaddr, + gen_mac, + gen_netmask, + gen_string, + gen_url, +) from robottelo import constants from robottelo.cli.activationkey import ActivationKey @@ -24,9 +26,11 @@ from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.computeresource import ComputeResource from robottelo.cli.content_credentials import ContentCredential -from robottelo.cli.contentview import ContentView -from robottelo.cli.contentview import ContentViewFilter -from robottelo.cli.contentview import ContentViewFilterRule +from robottelo.cli.contentview import ( + ContentView, + ContentViewFilter, + ContentViewFilterRule, +) from robottelo.cli.discoveryrule import DiscoveryRule from robottelo.cli.domain import Domain from robottelo.cli.environment import Environment @@ -60,8 +64,7 @@ from robottelo.cli.template import Template from robottelo.cli.template_input import TemplateInput from robottelo.cli.user import User -from robottelo.cli.usergroup import UserGroup -from robottelo.cli.usergroup import UserGroupExternal +from robottelo.cli.usergroup import UserGroup, UserGroupExternal from robottelo.cli.virt_who_config import VirtWhoConfig from robottelo.config import settings from robottelo.logging import logger @@ -70,7 +73,6 @@ from robottelo.utils.decorators import cacheable from robottelo.utils.manifest import clone - ORG_KEYS = ['organization', 'organization-id', 'organization-label'] CONTENT_VIEW_KEYS = ['content-view', 'content-view-id'] LIFECYCLE_KEYS = ['lifecycle-environment', 'lifecycle-environment-id'] @@ -940,6 +942,7 @@ def make_job_invocation_with_credentials(options=None, credentials=None): 'dynamic': None, 'effective-user': None, 'end-time': None, + 'feature': None, 'input-files': None, 'inputs': None, 'job-template': None, diff --git a/robottelo/cli/report_template.py b/robottelo/cli/report_template.py index 43b92d0bb98..e8a60b9beb6 100644 --- a/robottelo/cli/report_template.py +++ b/robottelo/cli/report_template.py @@ -25,10 +25,8 @@ from tempfile import mkstemp from robottelo import ssh -from robottelo.cli.base import Base -from robottelo.cli.base import CLIError -from robottelo.constants import DataFile -from robottelo.constants import REPORT_TEMPLATE_FILE +from robottelo.cli.base import Base, CLIError +from robottelo.constants import REPORT_TEMPLATE_FILE, DataFile class ReportTemplate(Base): diff --git a/robottelo/cli/rex_feature.py b/robottelo/cli/rex_feature.py new file mode 100644 index 00000000000..354fdc51ffe --- /dev/null +++ b/robottelo/cli/rex_feature.py @@ -0,0 +1,26 @@ +""" +Usage:: + + hammer remote-execution-feature [OPTIONS] SUBCOMMAND [ARG] ... + +Parameters:: + + SUBCOMMAND Subcommand + [ARG] ... Subcommand arguments + +Subcommands:: + + info Show remote execution feature + list List remote execution features + update Update a job template + +""" +from robottelo.cli.base import Base + + +class RemoteExecutionFeature(Base): + """ + Handles Remote Execution Feature commands + """ + + command_base = 'remote-execution-feature' diff --git a/robottelo/cli/template_input.py b/robottelo/cli/template_input.py index 1393642cb35..cfe548384c3 100644 --- a/robottelo/cli/template_input.py +++ b/robottelo/cli/template_input.py @@ -15,8 +15,7 @@ info Show template input details list List template inputs """ -from robottelo.cli.base import Base -from robottelo.cli.base import CLIError +from robottelo.cli.base import Base, CLIError class TemplateInput(Base): diff --git a/robottelo/cli/webhook.py b/robottelo/cli/webhook.py index 70edda993e9..379555630c5 100644 --- a/robottelo/cli/webhook.py +++ b/robottelo/cli/webhook.py @@ -13,10 +13,8 @@ Options: -h, --help Print help """ -from robottelo.cli.base import Base -from robottelo.cli.base import CLIError -from robottelo.constants import WEBHOOK_EVENTS -from robottelo.constants import WEBHOOK_METHODS +from robottelo.cli.base import Base, CLIError +from robottelo.constants import WEBHOOK_EVENTS, WEBHOOK_METHODS class Webhook(Base): diff --git a/robottelo/config/__init__.py b/robottelo/config/__init__.py index 0062ce17b6f..5bd85ab5737 100644 --- a/robottelo/config/__init__.py +++ b/robottelo/config/__init__.py @@ -9,8 +9,7 @@ from nailgun.config import ServerConfig from robottelo.config.validators import VALIDATORS -from robottelo.logging import logger -from robottelo.logging import robottelo_root_dir +from robottelo.logging import logger, robottelo_root_dir if not os.getenv('ROBOTTELO_DIR'): # dynaconf robottelo file uses ROBOTELLO_DIR for screenshots @@ -150,8 +149,7 @@ def configure_nailgun(): of this. * Set a default value for ``nailgun.entities.GPGKey.content``. """ - from nailgun import entities - from nailgun import entity_mixins + from nailgun import entities, entity_mixins from nailgun.config import ServerConfig entity_mixins.CREATE_MISSING = True diff --git a/robottelo/config/validators.py b/robottelo/config/validators.py index dcd242f2b5b..b605a1cd229 100644 --- a/robottelo/config/validators.py +++ b/robottelo/config/validators.py @@ -1,8 +1,6 @@ from dynaconf import Validator -from robottelo.constants import AZURERM_VALID_REGIONS -from robottelo.constants import VALID_GCE_ZONES - +from robottelo.constants import AZURERM_VALID_REGIONS, VALID_GCE_ZONES VALIDATORS = dict( supportability=[ diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 738af4f2f36..a5d7db37956 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -18,6 +18,7 @@ class Colored(Box): # This should be updated after each version branch SATELLITE_VERSION = "6.15" SATELLITE_OS_VERSION = "8" +SAT_NON_GA_VERSIONS = ['6.14', '6.15'] # Default system ports HTTPS_PORT = '443' @@ -315,7 +316,6 @@ class Colored(Box): 'rhel7_extra': 'Red Hat Enterprise Linux 7 Server - Extras (RPMs)', 'rhel7_optional': 'Red Hat Enterprise Linux 7 Server - Optional (RPMs)', 'rhel7_sup': 'Red Hat Enterprise Linux 7 Server - Supplementary (RPMs)', - 'rhst7_610': 'Red Hat Satellite Tools 6.10 (for RHEL 7 Server) (RPMs)', } SM_OVERALL_STATUS = { @@ -857,6 +857,7 @@ class Colored(Box): PULP_EXPORT_DIR = '/var/lib/pulp/exports/' PULP_IMPORT_DIR = '/var/lib/pulp/imports/' +EXPORT_LIBRARY_NAME = 'Export-Library' PUPPET_COMMON_INSTALLER_OPTS = { 'foreman-proxy-puppetca': 'true', diff --git a/robottelo/host_helpers/__init__.py b/robottelo/host_helpers/__init__.py index 87e78daae75..fa564dda27f 100644 --- a/robottelo/host_helpers/__init__.py +++ b/robottelo/host_helpers/__init__.py @@ -1,13 +1,16 @@ -from robottelo.host_helpers.capsule_mixins import CapsuleInfo -from robottelo.host_helpers.capsule_mixins import EnablePluginsCapsule -from robottelo.host_helpers.contenthost_mixins import HostInfo -from robottelo.host_helpers.contenthost_mixins import SystemFacts -from robottelo.host_helpers.contenthost_mixins import VersionedContent -from robottelo.host_helpers.satellite_mixins import ContentInfo -from robottelo.host_helpers.satellite_mixins import EnablePluginsSatellite -from robottelo.host_helpers.satellite_mixins import Factories -from robottelo.host_helpers.satellite_mixins import ProvisioningSetup -from robottelo.host_helpers.satellite_mixins import SystemInfo +from robottelo.host_helpers.capsule_mixins import CapsuleInfo, EnablePluginsCapsule +from robottelo.host_helpers.contenthost_mixins import ( + HostInfo, + SystemFacts, + VersionedContent, +) +from robottelo.host_helpers.satellite_mixins import ( + ContentInfo, + EnablePluginsSatellite, + Factories, + ProvisioningSetup, + SystemInfo, +) class ContentHostMixins(HostInfo, SystemFacts, VersionedContent): diff --git a/robottelo/host_helpers/api_factory.py b/robottelo/host_helpers/api_factory.py index 23219148a53..92f40652d34 100644 --- a/robottelo/host_helpers/api_factory.py +++ b/robottelo/host_helpers/api_factory.py @@ -2,23 +2,23 @@ It is not meant to be used directly, but as part of a robottelo.hosts.Satellite instance example: my_satellite.api_factory.api_method() """ -import time from contextlib import contextmanager +import time -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_string +from fauxfactory import gen_ipaddr, gen_mac, gen_string from nailgun import entity_mixins from nailgun.client import request from nailgun.entity_mixins import call_entity_method_with_timeout from requests import HTTPError from robottelo.config import settings -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_PTABLE -from robottelo.constants import DEFAULT_PXE_TEMPLATE -from robottelo.constants import DEFAULT_TEMPLATE -from robottelo.constants import REPO_TYPE +from robottelo.constants import ( + DEFAULT_ARCHITECTURE, + DEFAULT_PTABLE, + DEFAULT_PXE_TEMPLATE, + DEFAULT_TEMPLATE, + REPO_TYPE, +) from robottelo.exceptions import ImproperlyConfigured from robottelo.host_helpers.repository_mixins import initiate_repo_helpers diff --git a/robottelo/host_helpers/capsule_mixins.py b/robottelo/host_helpers/capsule_mixins.py index ed82d7e543a..0a4c88ddf6c 100644 --- a/robottelo/host_helpers/capsule_mixins.py +++ b/robottelo/host_helpers/capsule_mixins.py @@ -1,8 +1,7 @@ -import time from datetime import datetime +import time -from robottelo.constants import PUPPET_CAPSULE_INSTALLER -from robottelo.constants import PUPPET_COMMON_INSTALLER_OPTS +from robottelo.constants import PUPPET_CAPSULE_INSTALLER, PUPPET_COMMON_INSTALLER_OPTS from robottelo.logging import logger from robottelo.utils.installer import InstallerCommand diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index b78370bd9e8..cf7d8a28058 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -4,25 +4,26 @@ example: my_satellite.cli_factory.make_org() """ import datetime +from functools import lru_cache, partial import inspect import os +from os import chmod import pprint import random -from functools import lru_cache -from functools import partial -from os import chmod from tempfile import mkstemp from time import sleep from box import Box -from fauxfactory import gen_alpha -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_netmask -from fauxfactory import gen_url +from fauxfactory import ( + gen_alpha, + gen_alphanumeric, + gen_choice, + gen_integer, + gen_ipaddr, + gen_mac, + gen_netmask, + gen_url, +) from robottelo import constants from robottelo.cli.base import CLIReturnCodeError diff --git a/robottelo/host_helpers/contenthost_mixins.py b/robottelo/host_helpers/contenthost_mixins.py index 30fbf576e1f..f009503666a 100644 --- a/robottelo/host_helpers/contenthost_mixins.py +++ b/robottelo/host_helpers/contenthost_mixins.py @@ -1,14 +1,12 @@ """A collection of mixins for robottelo.hosts classes""" -import json from functools import cached_property +import json from tempfile import NamedTemporaryFile from robottelo import constants -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings +from robottelo.config import robottelo_tmp_dir, settings from robottelo.logging import logger -from robottelo.utils.ohsnap import dogfood_repofile_url -from robottelo.utils.ohsnap import dogfood_repository +from robottelo.utils.ohsnap import dogfood_repofile_url, dogfood_repository class VersionedContent: @@ -65,7 +63,7 @@ def OSCAP(self): 'cbrhel': constants.OSCAP_PROFILE[f'cbrhel{self._v_major}'], } - def _dogfood_helper(self, product, release, snap, repo=None): + def _dogfood_helper(self, product, release, repo=None): """Function to return repository related attributes based on the input and the host object """ @@ -89,18 +87,17 @@ def _dogfood_helper(self, product, release, snap, repo=None): 'or the version of the Satellite object. ' f'settings: {settings_release}, parameter: {release}' ) - snap = str(snap or settings.server.version.get("snap")) - return product, release, snap, v_major, repo + return product, release, v_major, repo def download_repofile(self, product=None, release=None, snap=''): """Downloads the tools/client, capsule, or satellite repos on the machine""" - product, release, snap, v_major, _ = self._dogfood_helper(product, release, snap) + product, release, v_major, _ = self._dogfood_helper(product, release) url = dogfood_repofile_url(settings.ohsnap, product, release, v_major, snap) self.execute(f'curl -o /etc/yum.repos.d/dogfood.repo -L {url}') def dogfood_repository(self, repo=None, product=None, release=None, snap=''): """Returns a repository definition based on the arguments provided""" - product, release, snap, v_major, repo = self._dogfood_helper(product, release, snap, repo) + product, release, v_major, repo = self._dogfood_helper(product, release, repo) return dogfood_repository(settings.ohsnap, repo, product, release, v_major, snap, self.arch) def enable_tools_repo(self, organization_id): diff --git a/robottelo/host_helpers/repository_mixins.py b/robottelo/host_helpers/repository_mixins.py index a60affdd75d..99b5576edb9 100644 --- a/robottelo/host_helpers/repository_mixins.py +++ b/robottelo/host_helpers/repository_mixins.py @@ -7,12 +7,14 @@ from robottelo import constants from robottelo.config import settings -from robottelo.exceptions import DistroNotSupportedError -from robottelo.exceptions import OnlyOneOSRepositoryAllowed -from robottelo.exceptions import ReposContentSetupWasNotPerformed -from robottelo.exceptions import RepositoryAlreadyCreated -from robottelo.exceptions import RepositoryAlreadyDefinedError -from robottelo.exceptions import RepositoryDataNotFound +from robottelo.exceptions import ( + DistroNotSupportedError, + OnlyOneOSRepositoryAllowed, + ReposContentSetupWasNotPerformed, + RepositoryAlreadyCreated, + RepositoryAlreadyDefinedError, + RepositoryDataNotFound, +) def initiate_repo_helpers(satellite): diff --git a/robottelo/host_helpers/satellite_mixins.py b/robottelo/host_helpers/satellite_mixins.py index 4f469ef0d90..263510f6783 100644 --- a/robottelo/host_helpers/satellite_mixins.py +++ b/robottelo/host_helpers/satellite_mixins.py @@ -1,4 +1,5 @@ import contextlib +from functools import cache import io import os import random @@ -9,12 +10,15 @@ from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.proxy import CapsuleTunnelError from robottelo.config import settings -from robottelo.constants import PULP_EXPORT_DIR -from robottelo.constants import PULP_IMPORT_DIR -from robottelo.constants import PUPPET_COMMON_INSTALLER_OPTS -from robottelo.constants import PUPPET_SATELLITE_INSTALLER +from robottelo.constants import ( + PULP_EXPORT_DIR, + PULP_IMPORT_DIR, + PUPPET_COMMON_INSTALLER_OPTS, + PUPPET_SATELLITE_INSTALLER, +) from robottelo.host_helpers.api_factory import APIFactory from robottelo.host_helpers.cli_factory import CLIFactory +from robottelo.host_helpers.ui_factory import UIFactory from robottelo.logging import logger from robottelo.utils.installer import InstallerCommand from robottelo.utils.manifest import clone @@ -141,13 +145,14 @@ def upload_manifest(self, org_id, manifest=None, interface='API', timeout=None): :returns: the manifest upload result """ - if manifest is None: - manifest = clone() + if not isinstance(manifest, bytes | io.BytesIO): + if manifest.content is None: + manifest = clone() if timeout is None: # Set the timeout to 1500 seconds to align with the API timeout. timeout = 1500000 if interface == 'CLI': - if isinstance(manifest.content, (bytes, io.BytesIO)): + if hasattr(manifest, 'path'): self.put(f'{manifest.path}', f'{manifest.name}') result = self.cli.Subscription.upload( {'file': manifest.name, 'organization-id': org_id}, timeout=timeout @@ -158,7 +163,7 @@ def upload_manifest(self, org_id, manifest=None, interface='API', timeout=None): {'file': manifest.filename, 'organization-id': org_id}, timeout=timeout ) else: - if not isinstance(manifest, (bytes, io.BytesIO)): + if not isinstance(manifest, bytes | io.BytesIO): manifest = manifest.content result = self.api.Subscription().upload( data={'organization_id': org_id}, files={'content': manifest} @@ -351,3 +356,7 @@ def api_factory(self): if not getattr(self, '_api_factory', None): self._api_factory = APIFactory(self) return self._api_factory + + @cache + def ui_factory(self, session): + return UIFactory(self, session=session) diff --git a/robottelo/host_helpers/ui_factory.py b/robottelo/host_helpers/ui_factory.py new file mode 100644 index 00000000000..cb85436051e --- /dev/null +++ b/robottelo/host_helpers/ui_factory.py @@ -0,0 +1,58 @@ +""" +It is not meant to be used directly, but as part of a robottelo.hosts.Satellite instance +Need to pass the existing session object to the ui_factory method as a parameter +example: my_satellite.ui_factory(session).ui_method() +""" +from fauxfactory import gen_string + +from robottelo.constants import DEFAULT_CV, ENVIRONMENT + + +class UIFactory: + """This class is part of a mixin and not to be used directly. See robottelo.hosts.Satellite""" + + def __init__(self, satellite, session=None): + self._satellite = satellite + self._session = session + + def create_fake_host( + self, + host, + interface_id=gen_string('alpha'), + global_parameters=None, + host_parameters=None, + extra_values=None, + new_host_details=False, + ): + if extra_values is None: + extra_values = {} + os_name = f'{host.operatingsystem.name} {host.operatingsystem.major}' + name = host.name if host.name is not None else gen_string('alpha').lower() + values = { + 'host.name': name, + 'host.organization': host.organization.name, + 'host.location': host.location.name, + 'host.lce': ENVIRONMENT, + 'host.content_view': DEFAULT_CV, + 'operating_system.architecture': host.architecture.name, + 'operating_system.operating_system': os_name, + 'operating_system.media_type': 'All Media', + 'operating_system.media': host.medium.name, + 'operating_system.ptable': host.ptable.name, + 'operating_system.root_password': host.root_pass, + 'interfaces.interface.interface_type': 'Interface', + 'interfaces.interface.device_identifier': interface_id, + 'interfaces.interface.mac': host.mac, + 'interfaces.interface.domain': host.domain.name, + 'interfaces.interface.primary': True, + 'interfaces.interface.interface_additional_data.virtual_nic': False, + 'parameters.global_params': global_parameters, + 'parameters.host_params': host_parameters, + 'additional_information.comment': 'Host with fake data', + } + values.update(extra_values) + if new_host_details: + self._session.host_new.create(values) + else: + self._session.host.create(values) + return f'{name}.{host.domain.name}' diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 29cd0415d6d..9b6923d7449 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -1,71 +1,65 @@ +from configparser import ConfigParser import contextlib +from contextlib import contextmanager +from datetime import datetime +from functools import cached_property, lru_cache import importlib import io import json +from pathlib import Path, PurePath import random import re +from tempfile import NamedTemporaryFile import time +from urllib.parse import urljoin, urlparse, urlunsplit import warnings -from configparser import ConfigParser -from contextlib import contextmanager -from datetime import datetime -from functools import cached_property -from functools import lru_cache -from pathlib import Path -from pathlib import PurePath -from tempfile import NamedTemporaryFile -from urllib.parse import urljoin -from urllib.parse import urlparse -from urllib.parse import urlunsplit -import requests -import yaml from box import Box from broker import Broker from broker.hosts import Host from dynaconf.vendor.box.exceptions import BoxKeyError -from fauxfactory import gen_alpha -from fauxfactory import gen_string +from fauxfactory import gen_alpha, gen_string from manifester import Manifester from nailgun import entities from packaging.version import Version +import requests from ssh2.exceptions import AuthenticationError -from wait_for import TimedOutError -from wait_for import wait_for +from wait_for import TimedOutError, wait_for from wrapanapi.entities.vm import VmState +import yaml from robottelo import constants from robottelo.cli.base import Base from robottelo.cli.factory import CLIFactoryError -from robottelo.config import configure_airgun -from robottelo.config import configure_nailgun -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings -from robottelo.constants import CUSTOM_PUPPET_MODULE_REPOS -from robottelo.constants import CUSTOM_PUPPET_MODULE_REPOS_PATH -from robottelo.constants import CUSTOM_PUPPET_MODULE_REPOS_VERSION -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import HAMMER_CONFIG -from robottelo.constants import KEY_CLOAK_CLI -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants import RHSSO_NEW_GROUP -from robottelo.constants import RHSSO_NEW_USER -from robottelo.constants import RHSSO_RESET_PASSWORD -from robottelo.constants import RHSSO_USER_UPDATE -from robottelo.constants import SATELLITE_VERSION -from robottelo.exceptions import DownloadFileError -from robottelo.exceptions import HostPingFailed -from robottelo.host_helpers import CapsuleMixins -from robottelo.host_helpers import ContentHostMixins -from robottelo.host_helpers import SatelliteMixins +from robottelo.config import ( + configure_airgun, + configure_nailgun, + robottelo_tmp_dir, + settings, +) +from robottelo.constants import ( + CUSTOM_PUPPET_MODULE_REPOS, + CUSTOM_PUPPET_MODULE_REPOS_PATH, + CUSTOM_PUPPET_MODULE_REPOS_VERSION, + DEFAULT_ARCHITECTURE, + HAMMER_CONFIG, + KEY_CLOAK_CLI, + PRDS, + REPOS, + REPOSET, + RHSSO_NEW_GROUP, + RHSSO_NEW_USER, + RHSSO_RESET_PASSWORD, + RHSSO_USER_UPDATE, + SATELLITE_VERSION, +) +from robottelo.exceptions import DownloadFileError, HostPingFailed +from robottelo.host_helpers import CapsuleMixins, ContentHostMixins, SatelliteMixins from robottelo.logging import logger from robottelo.utils import validate_ssh_pub_key from robottelo.utils.datafactory import valid_emails_list from robottelo.utils.installer import InstallerCommand - POWER_OPERATIONS = { VmState.RUNNING: 'running', VmState.STOPPED: 'stopped', @@ -226,16 +220,31 @@ def satellite(self): self._satellite = Satellite() return self._satellite + @property + def _sat_host_record(self): + """Provide access to this host's Host record if it exists.""" + hosts = self.satellite.api.Host().search(query={'search': self.hostname}) + if not hosts: + logger.debug('No host record found for %s on Satellite', self.hostname) + return None + return hosts[0] + + def _delete_host_record(self): + """Delete the Host record of this host from Satellite.""" + if h_record := self._sat_host_record: + logger.debug('Deleting host record for %s from Satellite', self.hostname) + h_record.delete() + @property def nailgun_host(self): """If this host is subscribed, provide access to its nailgun object""" if self.identity.get('registered_to') == self.satellite.hostname: try: - host_list = self.satellite.api.Host().search(query={'search': self.hostname})[0] + host = self._sat_host_record except Exception as err: logger.error(f'Failed to get nailgun host for {self.hostname}: {err}') - host_list = None - return host_list + host = None + return host else: logger.warning(f'Host {self.hostname} not registered to {self.satellite.hostname}') @@ -373,14 +382,20 @@ def clean_cached_properties(self): del self.__dict__[name] def setup(self): + logger.debug('START: setting up host %s', self) if not self.blank: self.remove_katello_ca() + logger.debug('END: setting up host %s', self) + def teardown(self): + logger.debug('START: tearing down host %s', self) if not self.blank and not getattr(self, '_skip_context_checkin', False): self.unregister() - if type(self) is not Satellite and self.nailgun_host: - self.nailgun_host.delete() + if type(self) is not Satellite: # do not delete Satellite's host record + self._delete_host_record() + + logger.debug('END: tearing down host %s', self) def power_control(self, state=VmState.RUNNING, ensure=True): """Lookup the host workflow for power on and execute @@ -886,7 +901,7 @@ def put(self, local_path, remote_path=None): If local_path is a manifest object, write its contents to a temporary file then continue with the upload. """ - if 'utils.Manifest' in str(local_path): + if 'utils.manifest' in str(local_path): with NamedTemporaryFile(dir=robottelo_tmp_dir) as content_file: content_file.write(local_path.content.read()) content_file.flush() @@ -1137,6 +1152,8 @@ def configure_rhai_client( # Register client if self.execute('insights-client --register').status != 0: raise ContentHostError('Unable to register client to Insights through Satellite') + if self.execute('insights-client --test-connection').status != 0: + raise ContentHostError('Test connection failed via insights.') def unregister_insights(self): """Unregister insights client. @@ -1255,9 +1272,9 @@ def virt_who_hypervisor_config( :param bool upload_manifest: whether to upload the organization manifest :param list extra_repos: (Optional) repositories dict options to setup additionally. """ - from robottelo.cli.org import Org from robottelo.cli import factory as cli_factory from robottelo.cli.lifecycleenvironment import LifecycleEnvironment + from robottelo.cli.org import Org from robottelo.cli.subscription import Subscription from robottelo.cli.virt_who_config import VirtWhoConfig @@ -1666,6 +1683,19 @@ def set_rex_script_mode_provider(self, mode='ssh'): if result.status != 0: raise SatelliteHostError(f'Failed to enable pull provider: {result.stdout}') + def run_installer_arg(self, *args, timeout='20m'): + """Run an installer argument on capsule""" + installer_args = list(args) + installer_command = InstallerCommand( + installer_args=installer_args, + ) + result = self.execute( + installer_command.get_command(), + timeout=timeout, + ) + if result.status != 0: + raise SatelliteHostError(f'Failed to execute with argument: {result.stderr}') + def set_mqtt_resend_interval(self, value): """Set the time interval in seconds at which the notification should be re-sent to the mqtt host until the job is picked up or cancelled""" @@ -1705,6 +1735,7 @@ def cli(self): except AttributeError: # not everything has an mro method, we don't care about them pass + self._cli._configured = True return self._cli @@ -1757,6 +1788,7 @@ class DecClass(cls): except AttributeError: # not everything has an mro method, we don't care about them pass + self._api._configured = True return self._api @property @@ -1786,6 +1818,7 @@ def cli(self): except AttributeError: # not everything has an mro method, we don't care about them pass + self._cli._configured = True return self._cli @contextmanager @@ -1997,7 +2030,7 @@ def register_host_custom_repo(self, module_org, rhel_contenthost, repo_urls): """Register content host to Satellite and sync repos :param module_org: Org where contenthost will be registered. - :param rhel_contenthost: contenthost to be register with Satellite. + :param rhel_contenthost: contenthost to be registered with Satellite. :param repo_urls: List of URLs to be synced and made available to contenthost via subscription-manager. :return: None @@ -2057,6 +2090,9 @@ def register_host_custom_repo(self, module_org, rhel_contenthost, repo_urls): # refresh repository metadata on the host rhel_contenthost.execute('subscription-manager repos --list') + # Override the repos to enabled + rhel_contenthost.execute(r'subscription-manager repos --enable \*') + def enroll_ad_and_configure_external_auth(self, ad_data): """Enroll Satellite Server to an AD Server. diff --git a/robottelo/logging.py b/robottelo/logging.py index bea19024454..5b09fdeef68 100644 --- a/robottelo/logging.py +++ b/robottelo/logging.py @@ -2,12 +2,11 @@ import os from pathlib import Path -import logzero -import yaml from box import Box from broker.logger import setup_logzero as broker_log_setup +import logzero from manifester.logger import setup_logzero as manifester_log_setup - +import yaml robottelo_root_dir = Path(os.environ.get('ROBOTTELO_DIR', Path(__file__).resolve().parent.parent)) robottelo_log_dir = robottelo_root_dir.joinpath('logs') diff --git a/robottelo/ui/__init__.py b/robottelo/ui/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/robottelo/ui/utils.py b/robottelo/ui/utils.py deleted file mode 100644 index d22bb25dae5..00000000000 --- a/robottelo/ui/utils.py +++ /dev/null @@ -1,47 +0,0 @@ -from fauxfactory import gen_string - -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT - - -def create_fake_host( - session, - host, - interface_id=gen_string('alpha'), - global_parameters=None, - host_parameters=None, - extra_values=None, - new_host_details=False, -): - if extra_values is None: - extra_values = {} - os_name = f'{host.operatingsystem.name} {host.operatingsystem.major}' - name = host.name if host.name is not None else gen_string('alpha').lower() - values = { - 'host.name': name, - 'host.organization': host.organization.name, - 'host.location': host.location.name, - 'host.lce': ENVIRONMENT, - 'host.content_view': DEFAULT_CV, - 'operating_system.architecture': host.architecture.name, - 'operating_system.operating_system': os_name, - 'operating_system.media_type': 'All Media', - 'operating_system.media': host.medium.name, - 'operating_system.ptable': host.ptable.name, - 'operating_system.root_password': host.root_pass, - 'interfaces.interface.interface_type': 'Interface', - 'interfaces.interface.device_identifier': interface_id, - 'interfaces.interface.mac': host.mac, - 'interfaces.interface.domain': host.domain.name, - 'interfaces.interface.primary': True, - 'interfaces.interface.interface_additional_data.virtual_nic': False, - 'parameters.global_params': global_parameters, - 'parameters.host_params': host_parameters, - 'additional_information.comment': 'Host with fake data', - } - values.update(extra_values) - if new_host_details: - session.host_new.create(values) - else: - session.host.create(values) - return f'{name}.{host.domain.name}' diff --git a/robottelo/utils/__init__.py b/robottelo/utils/__init__.py index 369c3e35585..0cf4020ca5a 100644 --- a/robottelo/utils/__init__.py +++ b/robottelo/utils/__init__.py @@ -1,34 +1,12 @@ # General utility functions which does not fit into other util modules OR # Independent utility functions that doesnt need separate module import base64 -import os import re -from pathlib import Path from cryptography.hazmat.backends import default_backend as crypto_default_backend from cryptography.hazmat.primitives import serialization as crypto_serialization from cryptography.hazmat.primitives.asymmetric import rsa -from robottelo.constants import Colored -from robottelo.exceptions import InvalidVaultURLForOIDC - - -def export_vault_env_vars(filename=None, envdata=None): - if not envdata: - envdata = Path(filename or '.env').read_text() - vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', envdata)[0] - - # Vault CLI Env Var - os.environ['VAULT_ADDR'] = vaulturl - - # Dynaconf Vault Env Vars - if re.findall('VAULT_ENABLED_FOR_DYNACONF=(.*)', envdata)[0] == 'true': - if 'localhost:8200' in vaulturl: - raise InvalidVaultURLForOIDC( - f"{Colored.REDDARK}{vaulturl} doesnt supports OIDC login," - "please change url to corp vault in env file!" - ) - def gen_ssh_keypairs(): """Generates private SSH key with its public key""" diff --git a/robottelo/utils/datafactory.py b/robottelo/utils/datafactory.py index 27bf92fabe5..7de716e1046 100644 --- a/robottelo/utils/datafactory.py +++ b/robottelo/utils/datafactory.py @@ -1,18 +1,13 @@ """Data Factory for all entities""" +from functools import wraps import random import string -from functools import wraps from urllib.parse import quote_plus -from fauxfactory import gen_alpha -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url -from fauxfactory import gen_utf8 +from fauxfactory import gen_alpha, gen_integer, gen_string, gen_url, gen_utf8 from robottelo.config import settings -from robottelo.constants import DOMAIN -from robottelo.constants import STRING_TYPES +from robottelo.constants import DOMAIN, STRING_TYPES class InvalidArgumentError(Exception): diff --git a/robottelo/utils/decorators/__init__.py b/robottelo/utils/decorators/__init__.py index 1d79cba7a26..371afd50f16 100644 --- a/robottelo/utils/decorators/__init__.py +++ b/robottelo/utils/decorators/__init__.py @@ -1,7 +1,6 @@ """Implements various decorators""" from functools import wraps - OBJECT_CACHE = {} diff --git a/robottelo/utils/decorators/func_locker.py b/robottelo/utils/decorators/func_locker.py index 723c4be1ff1..2d575d8f560 100644 --- a/robottelo/utils/decorators/func_locker.py +++ b/robottelo/utils/decorators/func_locker.py @@ -39,11 +39,11 @@ def test_that_conflict_with_test_to_lock(self) with locking_function(self.test_to_lock): # do some operations that conflict with test_to_lock """ +from contextlib import contextmanager import functools import inspect import os import tempfile -from contextlib import contextmanager from pytest_services.locks import file_lock diff --git a/robottelo/utils/decorators/func_shared/shared.py b/robottelo/utils/decorators/func_shared/shared.py index 568f6adf212..62e529b8d8a 100644 --- a/robottelo/utils/decorators/func_shared/shared.py +++ b/robottelo/utils/decorators/func_shared/shared.py @@ -87,24 +87,21 @@ def shared_class_method(cls, org=None, repo=None): import datetime import functools import hashlib +from importlib import import_module import inspect import os import sys import traceback import uuid -from importlib import import_module from nailgun.entities import Entity -from robottelo.config import setting_is_set -from robottelo.config import settings +from robottelo.config import setting_is_set, settings from robottelo.logging import logger -from robottelo.utils.decorators.func_shared import file_storage -from robottelo.utils.decorators.func_shared import redis_storage +from robottelo.utils.decorators.func_shared import file_storage, redis_storage from robottelo.utils.decorators.func_shared.file_storage import FileStorageHandler from robottelo.utils.decorators.func_shared.redis_storage import RedisStorageHandler - _storage_handlers = {'file': FileStorageHandler, 'redis': RedisStorageHandler} DEFAULT_STORAGE_HANDLER = 'file' diff --git a/robottelo/utils/io/__init__.py b/robottelo/utils/io/__init__.py index 2a00c546720..33a4381fd4c 100644 --- a/robottelo/utils/io/__init__.py +++ b/robottelo/utils/io/__init__.py @@ -1,8 +1,8 @@ # Helper methods for tests requiring I/0 import hashlib import json -import tarfile from pathlib import Path +import tarfile def get_local_file_data(path): diff --git a/robottelo/utils/issue_handlers/__init__.py b/robottelo/utils/issue_handlers/__init__.py index d48c1948f24..4789bbc8a74 100644 --- a/robottelo/utils/issue_handlers/__init__.py +++ b/robottelo/utils/issue_handlers/__init__.py @@ -1,7 +1,6 @@ # Methods related to issue handlers in general from robottelo.utils.issue_handlers import bugzilla - handler_methods = {'BZ': bugzilla.is_open_bz} SUPPORTED_HANDLERS = tuple(f"{handler}:" for handler in handler_methods.keys()) diff --git a/robottelo/utils/issue_handlers/bugzilla.py b/robottelo/utils/issue_handlers/bugzilla.py index 6fca11eb894..20836a3660d 100644 --- a/robottelo/utils/issue_handlers/bugzilla.py +++ b/robottelo/utils/issue_handlers/bugzilla.py @@ -1,21 +1,16 @@ -import re from collections import defaultdict +import re +from packaging.version import Version import pytest import requests -from packaging.version import Version -from tenacity import retry -from tenacity import stop_after_attempt -from tenacity import wait_fixed +from tenacity import retry, stop_after_attempt, wait_fixed from robottelo.config import settings -from robottelo.constants import CLOSED_STATUSES -from robottelo.constants import OPEN_STATUSES -from robottelo.constants import WONTFIX_RESOLUTIONS +from robottelo.constants import CLOSED_STATUSES, OPEN_STATUSES, WONTFIX_RESOLUTIONS from robottelo.hosts import get_sat_version from robottelo.logging import logger - # match any version as in `sat-6.2.x` or `sat-6.2.0` or `6.2.9` # The .version group being a `d.d` string that can be casted to Version() VERSION_RE = re.compile(r'(?:sat-)*?(?P\d\.\d)\.\w*') diff --git a/robottelo/utils/manifest.py b/robottelo/utils/manifest.py index 58539b6cb36..52c220f3c59 100644 --- a/robottelo/utils/manifest.py +++ b/robottelo/utils/manifest.py @@ -4,11 +4,10 @@ import uuid import zipfile -import requests from cryptography.hazmat.backends import default_backend as crypto_default_backend -from cryptography.hazmat.primitives import hashes -from cryptography.hazmat.primitives import serialization as crypto_serialization +from cryptography.hazmat.primitives import hashes, serialization as crypto_serialization from cryptography.hazmat.primitives.asymmetric import padding +import requests from robottelo.config import settings diff --git a/robottelo/utils/ohsnap.py b/robottelo/utils/ohsnap.py index ac9bf6b81c1..74494766114 100644 --- a/robottelo/utils/ohsnap.py +++ b/robottelo/utils/ohsnap.py @@ -1,12 +1,11 @@ """Utility module to communicate with Ohsnap API""" -import requests from box import Box from packaging.version import Version +import requests from wait_for import wait_for from robottelo import constants -from robottelo.exceptions import InvalidArgumentError -from robottelo.exceptions import RepositoryDataNotFound +from robottelo.exceptions import InvalidArgumentError, RepositoryDataNotFound from robottelo.logging import logger diff --git a/robottelo/utils/report_portal/portal.py b/robottelo/utils/report_portal/portal.py index bf377d52f20..3d44ac6c691 100644 --- a/robottelo/utils/report_portal/portal.py +++ b/robottelo/utils/report_portal/portal.py @@ -1,7 +1,5 @@ import requests -from tenacity import retry -from tenacity import stop_after_attempt -from tenacity import wait_fixed +from tenacity import retry, stop_after_attempt, wait_fixed from robottelo.config import settings from robottelo.logging import logger diff --git a/robottelo/utils/vault.py b/robottelo/utils/vault.py new file mode 100644 index 00000000000..a4b5d48adb4 --- /dev/null +++ b/robottelo/utils/vault.py @@ -0,0 +1,114 @@ +"""Hashicorp Vault Utils where vault CLI is wrapped to perform vault operations""" +import json +import os +import re +import subprocess +import sys + +from robottelo.exceptions import InvalidVaultURLForOIDC +from robottelo.logging import logger, robottelo_root_dir + + +class Vault: + + HELP_TEXT = ( + "Vault CLI in not installed in your system, " + "refer link https://learn.hashicorp.com/tutorials/vault/getting-started-install to " + "install vault CLI as per your system spec!" + ) + + def __init__(self, env_file='.env'): + self.env_path = robottelo_root_dir.joinpath(env_file) + + def setup(self): + self.export_vault_addr() + + def teardown(self): + del os.environ['VAULT_ADDR'] + + def export_vault_addr(self): + envdata = self.env_path.read_text() + vaulturl = re.findall('VAULT_URL_FOR_DYNACONF=(.*)', envdata)[0] + + # Set Vault CLI Env Var + os.environ['VAULT_ADDR'] = vaulturl + + # Dynaconf Vault Env Vars + if re.findall('VAULT_ENABLED_FOR_DYNACONF=(.*)', envdata)[0] == 'true': + if 'localhost:8200' in vaulturl: + raise InvalidVaultURLForOIDC( + f"{vaulturl} doesnt supports OIDC login," + "please change url to corp vault in env file!" + ) + + def exec_vault_command(self, command: str, **kwargs): + """A wrapper to execute the vault CLI commands + + :param comamnd str: The vault CLI command + :param kwargs dict: Arguments to the subprocess run command to customize the run behavior + """ + vcommand = subprocess.run(command, shell=True, **kwargs) # capture_output=True + if vcommand.returncode != 0: + verror = str(vcommand.stderr) + if vcommand.returncode == 127: + logger.error(f"Error! {self.HELP_TEXT}") + sys.exit(1) + if vcommand.stderr: + if 'Error revoking token' in verror: + logger.info("Token is alredy revoked!") + elif 'Error looking up token' in verror: + logger.warning("Warning! Vault not logged in!") + else: + logger.error(f"Error! {verror}") + return vcommand + + def login(self, **kwargs): + if 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ: + if self.status(**kwargs).returncode != 0: + logger.warning( + "Warning! The browser is about to open for vault OIDC login, " + "close the tab once the sign-in is done!" + ) + if ( + self.exec_vault_command(command="vault login -method=oidc", **kwargs).returncode + == 0 + ): + self.exec_vault_command(command="vault token renew -i 10h", **kwargs) + logger.info("Success! Vault OIDC Logged-In and extended for 10 hours!") + # Fetching tokens + token = self.exec_vault_command( + "vault token lookup --format json", capture_output=True + ).stdout + token = json.loads(str(token.decode('UTF-8')))['data']['id'] + # Setting new token in env file + envdata = self.env_path.read_text() + envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', f"VAULT_TOKEN_FOR_DYNACONF={token}", envdata + ) + self.env_path.write_text(envdata) + logger.info( + "Success! New OIDC token added to .env file to access secrets from vault!" + ) + + def logout(self): + # Teardown - Setting dymmy token in env file + envdata = self.env_path.read_text() + envdata = re.sub( + '.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", envdata + ) + self.env_path.write_text(envdata) + self.exec_vault_command('vault token revoke -self') + logger.info("Success! OIDC token removed from Env file successfully!") + + def status(self, **kwargs): + vstatus = self.exec_vault_command('vault token lookup', **kwargs) + if vstatus.returncode == 0: + logger.info(str(vstatus.stdout.decode('UTF-8'))) + return vstatus + + def __enter__(self): + self.setup() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.teardown() diff --git a/robottelo/utils/virtwho.py b/robottelo/utils/virtwho.py index b53480265b1..8c7a6c48658 100644 --- a/robottelo/utils/virtwho.py +++ b/robottelo/utils/virtwho.py @@ -3,11 +3,9 @@ import re import uuid -import requests -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url +from fauxfactory import gen_integer, gen_string, gen_url from nailgun import entities +import requests from wait_for import wait_for from robottelo import ssh diff --git a/scripts/config_helpers.py b/scripts/config_helpers.py index 6176fa1cb5e..85283bea05e 100644 --- a/scripts/config_helpers.py +++ b/scripts/config_helpers.py @@ -3,8 +3,8 @@ import click import deepdiff -import yaml from logzero import logger +import yaml def merge_nested_dictionaries(original, new, overwrite=False): diff --git a/scripts/graph_entities.py b/scripts/graph_entities.py index ff21877c31c..a404c616911 100755 --- a/scripts/graph_entities.py +++ b/scripts/graph_entities.py @@ -9,8 +9,7 @@ """ import inspect -from nailgun import entities -from nailgun import entity_mixins +from nailgun import entities, entity_mixins def graph(): diff --git a/scripts/tokenize_customer_scenario.py b/scripts/tokenize_customer_scenario.py index 273a2075d4d..14a0cbf75a5 100644 --- a/scripts/tokenize_customer_scenario.py +++ b/scripts/tokenize_customer_scenario.py @@ -14,12 +14,9 @@ $ python scripts/tokenize_customer_scenario.py """ import codemod -from codemod import Query -from codemod import regex_suggestor -from codemod import run_interactive +from codemod import Query, regex_suggestor, run_interactive from codemod.helpers import path_filter - codemod.base.yes_to_all = True # this script can be changed to accept this list as param diff --git a/scripts/vault_login.py b/scripts/vault_login.py index 6f311bfeadc..300d81759a5 100755 --- a/scripts/vault_login.py +++ b/scripts/vault_login.py @@ -1,86 +1,14 @@ #!/usr/bin/env python # This Enables and Disables individuals OIDC token to access secrets from vault -import json -import os -import re -import subprocess import sys -from pathlib import Path - -from robottelo.constants import Colored -from robottelo.utils import export_vault_env_vars - - -HELP_TEXT = ( - "Vault CLI in not installed in your system, " - "refer link https://learn.hashicorp.com/tutorials/vault/getting-started-install to " - "install vault CLI as per your system spec!" -) - - -def _vault_command(command: str): - vcommand = subprocess.run(command, capture_output=True, shell=True) - if vcommand.returncode != 0: - verror = str(vcommand.stderr) - if vcommand.returncode == 127: - print(f"{Colored.REDDARK}Error! {HELP_TEXT}") - sys.exit(1) - elif 'Error revoking token' in verror: - print(f"{Colored.GREEN}Token is alredy revoked!") - sys.exit(0) - elif 'Error looking up token' in verror: - print(f"{Colored.YELLOW}Warning! Vault not logged in, please run 'make vault-login'!") - sys.exit(2) - else: - print(f"{Colored.REDDARK}Error! {verror}") - sys.exit(1) - return vcommand - - -def _vault_login(root_path, envdata): - print( - f"{Colored.WHITELIGHT}Warning! The browser is about to open for vault OIDC login, " - "close the tab once the sign-in is done!" - ) - if _vault_command(command="vault login -method=oidc").returncode == 0: - _vault_command(command="vault token renew -i 10h") - print(f"{Colored.GREEN}Success! Vault OIDC Logged-In and extended for 10 hours!") - # Fetching token - token = _vault_command("vault token lookup --format json").stdout - token = json.loads(str(token.decode('UTF-8')))['data']['id'] - # Setting new token in env file - envdata = re.sub('.*VAULT_TOKEN_FOR_DYNACONF=.*', f"VAULT_TOKEN_FOR_DYNACONF={token}", envdata) - with open(root_path, 'w') as envfile: - envfile.write(envdata) - print( - f"{Colored.GREEN}Success! New OIDC token added to .env file to access secrets from vault!" - ) - - -def _vault_logout(root_path, envdata): - # Teardown - Setting dymmy token in env file - envdata = re.sub('.*VAULT_TOKEN_FOR_DYNACONF=.*', "# VAULT_TOKEN_FOR_DYNACONF=myroot", envdata) - with open(root_path, 'w') as envfile: - envfile.write(envdata) - _vault_command('vault token revoke -self') - print(f"{Colored.GREEN}Success! OIDC token removed from Env file successfully!") - - -def _vault_status(): - vstatus = _vault_command('vault token lookup') - if vstatus.returncode == 0: - print(str(vstatus.stdout.decode('UTF-8'))) +from robottelo.utils.vault import Vault if __name__ == '__main__': - root_path = Path('.env') - envdata = root_path.read_text() - export_vault_env_vars(envdata=envdata) - if sys.argv[-1] == '--login': - _vault_login(root_path, envdata) - elif sys.argv[-1] == '--status': - _vault_status() - else: - _vault_logout(root_path, envdata) - # Unsetting VAULT URL - del os.environ['VAULT_ADDR'] + with Vault() as vclient: + if sys.argv[-1] == '--login': + vclient.login() + elif sys.argv[-1] == '--status': + vclient.status() + else: + vclient.logout() diff --git a/setup.py b/setup.py index e173ae35c1e..7e0feb9f2b3 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from setuptools import find_packages -from setuptools import setup +from setuptools import find_packages, setup with open('README.rst') as f: README = f.read() diff --git a/tests/foreman/api/test_acs.py b/tests/foreman/api/test_acs.py index 773b2b300fe..bb4cfaf125e 100644 --- a/tests/foreman/api/test_acs.py +++ b/tests/foreman/api/test_acs.py @@ -16,12 +16,11 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError -from robottelo.constants.repos import PULP_FIXTURE_ROOT -from robottelo.constants.repos import PULP_SUBPATHS_COMBINED +from robottelo.constants.repos import PULP_FIXTURE_ROOT, PULP_SUBPATHS_COMBINED @pytest.mark.e2e diff --git a/tests/foreman/api/test_activationkey.py b/tests/foreman/api/test_activationkey.py index 0a4c48de8a3..96da8a8f4c8 100644 --- a/tests/foreman/api/test_activationkey.py +++ b/tests/foreman/api/test_activationkey.py @@ -18,22 +18,19 @@ """ import http +from fauxfactory import gen_integer, gen_string +from nailgun import client, entities import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string -from nailgun import client -from nailgun import entities from requests.exceptions import HTTPError -from robottelo.config import get_credentials -from robottelo.config import user_nailgun_config -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.config import get_credentials, user_nailgun_config +from robottelo.constants import PRDS, REPOS, REPOSET +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_names_list, + parametrized, + valid_data_list, +) @filtered_datapoint diff --git a/tests/foreman/api/test_ansible.py b/tests/foreman/api/test_ansible.py index 3a9b8f0a726..b01cab6401a 100644 --- a/tests/foreman/api/test_ansible.py +++ b/tests/foreman/api/test_ansible.py @@ -16,10 +16,12 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest +from wait_for import wait_for -from robottelo.config import settings +from robottelo.config import settings, user_nailgun_config +from robottelo.utils.issue_handlers import is_open @pytest.mark.e2e @@ -253,3 +255,89 @@ def test_add_and_remove_ansible_role_hostgroup(target_sat): target_sat.api.HostGroup(id=hg.id).remove_ansible_role(data={'ansible_role_id': role}) host_roles = target_sat.api.HostGroup(id=hg.id).list_ansible_roles() assert len(host_roles) == 0 + + +@pytest.fixture(scope='function') +def filtered_user(target_sat, module_org, module_location): + """ + :Steps: + 1. Create a role with a host view filtered + 2. Create a user with that role + 3. Setup a host + """ + api = target_sat.api + role = api.Role( + name=gen_string('alpha'), location=[module_location], organization=[module_org] + ).create() + # assign view_hosts (with a filter, to test BZ 1699188), + # view_hostgroups, view_facts permissions to the role + permission_hosts = api.Permission().search(query={'search': 'name="view_hosts"'}) + permission_hostgroups = api.Permission().search(query={'search': 'name="view_hostgroups"'}) + permission_facts = api.Permission().search(query={'search': 'name="view_facts"'}) + api.Filter(permission=permission_hosts, search='name != nonexistent', role=role).create() + api.Filter(permission=permission_hostgroups, role=role).create() + api.Filter(permission=permission_facts, role=role).create() + + password = gen_string('alpha') + user = api.User( + role=[role], password=password, location=[module_location], organization=[module_org] + ).create() + + return user, password + + +@pytest.fixture(scope='function') +def rex_host_in_org_and_loc(target_sat, module_org, module_location, rex_contenthost): + api = target_sat.api + host = api.Host().search(query={'search': f'name={rex_contenthost.hostname}'})[0] + host_id = host.id + api.Host(id=host_id, organization=[module_org.id]).update(['organization']) + api.Host(id=host_id, location=module_location.id).update(['location']) + return host + + +@pytest.mark.rhel_ver_match('[78]') +@pytest.mark.tier2 +def test_positive_read_facts_with_filter( + target_sat, rex_contenthost, filtered_user, rex_host_in_org_and_loc +): + """ + Read host's Ansible facts as a user with a role that has host filter + + :id: 483d5faf-7a4c-4cb7-b14f-369768ad99b0 + + 1. Run Ansible roles on a host + 2. Using API, read Ansible facts of that host + + :expectedresults: Ansible facts returned + + :BZ: 1699188 + + :customerscenario: true + """ + user, password = filtered_user + host = rex_host_in_org_and_loc + + # gather ansible facts by running ansible roles on the host + host.play_ansible_roles() + if is_open('BZ:2216471'): + host_wait = target_sat.api.Host().search( + query={'search': f'name={rex_contenthost.hostname}'} + )[0] + wait_for( + lambda: len(host_wait.get_facts()) > 0, + timeout=30, + delay=2, + ) + + user_cfg = user_nailgun_config(user.login, password) + host = target_sat.api.Host(server_config=user_cfg).search( + query={'search': f'name={rex_contenthost.hostname}'} + )[0] + # get facts through API + facts = host.get_facts() + assert 'subtotal' in facts + assert facts['subtotal'] == 1 + assert 'results' in facts + assert rex_contenthost.hostname in facts['results'] + assert len(facts['results'][rex_contenthost.hostname]) > 0 diff --git a/tests/foreman/api/test_architecture.py b/tests/foreman/api/test_architecture.py index cb34a1513ec..f88c8adba18 100644 --- a/tests/foreman/api/test_architecture.py +++ b/tests/foreman/api/test_architecture.py @@ -16,14 +16,16 @@ :Upstream: No """ -import pytest from fauxfactory import gen_choice from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) @pytest.mark.tier1 diff --git a/tests/foreman/api/test_audit.py b/tests/foreman/api/test_audit.py index 5169e44dbca..59b19d0806c 100644 --- a/tests/foreman/api/test_audit.py +++ b/tests/foreman/api/test_audit.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/api/test_bookmarks.py b/tests/foreman/api/test_bookmarks.py index 91c8ef2df8a..71ae30391ab 100644 --- a/tests/foreman/api/test_bookmarks.py +++ b/tests/foreman/api/test_bookmarks.py @@ -18,15 +18,13 @@ """ import random -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.constants import BOOKMARK_ENTITIES -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import valid_data_list - +from robottelo.utils.datafactory import invalid_values_list, valid_data_list # List of unique bookmark controller values, preserving order CONTROLLERS = list(dict.fromkeys(entity['controller'] for entity in BOOKMARK_ENTITIES)) diff --git a/tests/foreman/api/test_capsule.py b/tests/foreman/api/test_capsule.py new file mode 100644 index 00000000000..b8304979e70 --- /dev/null +++ b/tests/foreman/api/test_capsule.py @@ -0,0 +1,219 @@ +"""Tests for the ``smart_proxies`` paths. + +:Requirement: Smartproxy + +:CaseAutomation: Automated + +:CaseLevel: Component + +:CaseComponent: Capsule + +:Team: Platform + +:TestType: Functional + +:CaseImportance: Critical + +:Upstream: No +""" +from fauxfactory import gen_string, gen_url +import pytest +from requests import HTTPError + +from robottelo.config import user_nailgun_config + + +@pytest.mark.e2e +@pytest.mark.upgrade +@pytest.mark.tier1 +def test_positive_update_capsule(target_sat, module_capsule_configured): + """Update various capsule properties + + :id: a3d3eaa9-ed8d-42e6-9c83-20251e5ca9af + + :steps: + 1. Get deployed capsule from fixture + 2. Refresh features + 3. Update capsule organization + 4. Update capsule location + 5. Update capsule name + + :expectedresults: All capsule properties are updated + + :bz: 2077824 + + :customerscenario: true + + """ + new_name = f'{gen_string("alpha")}-{module_capsule_configured.name}' + capsule = target_sat.api.SmartProxy().search( + query={'search': f'name = {module_capsule_configured.hostname}'} + )[0] + + # refresh features + features = capsule.refresh() + module_capsule_configured.run_installer_arg('enable-foreman-proxy-plugin-openscap') + features_new = capsule.refresh() + assert len(features_new["features"]) == len(features["features"]) + 1 + assert 'Openscap' in [feature["name"] for feature in features_new["features"]] + + # update organizations + organizations = [target_sat.api.Organization().create() for _ in range(2)] + capsule.organization = organizations + capsule = capsule.update(['organization']) + assert {org.id for org in capsule.organization} == {org.id for org in organizations} + + # update locations + locations = [target_sat.api.Location().create() for _ in range(2)] + capsule.location = locations + capsule = capsule.update(['location']) + assert {loc.id for loc in capsule.organization} == {loc.id for loc in organizations} + + # update name + capsule.name = new_name + capsule = capsule.update(['name']) + assert capsule.name == new_name + + # serching for non-default capsule BZ#2077824 + capsules = target_sat.api.SmartProxy().search(query={'search': 'id != 1'}) + assert len(capsules) > 0 + assert capsule.url in [cps.url for cps in capsules] + assert capsule.name in [cps.name for cps in capsules] + + +@pytest.mark.skip_if_not_set('fake_capsules') +@pytest.mark.tier1 +def test_negative_create_with_url(target_sat): + """Capsule creation with random URL + + :id: e48a6260-97e0-4234-a69c-77bbbcde85d6 + + :expectedresults: Proxy is not created + + """ + # Create a random proxy + with pytest.raises(HTTPError) as context: + target_sat.api.SmartProxy(url=gen_url(scheme='https')).create() + assert 'Unable to communicate' in context.value.response.text + + +@pytest.mark.skip_if_not_set('fake_capsules') +@pytest.mark.tier1 +@pytest.mark.upgrade +def test_positive_delete(target_sat): + """Capsule deletion + + :id: 872bf12e-736d-43d1-87cf-2923966b59d0 + + :expectedresults: Capsule is deleted + + :BZ: 1398695 + """ + new_port = target_sat.available_capsule_port + with target_sat.default_url_on_new_port(9090, new_port) as url: + proxy = target_sat.api.SmartProxy(url=url).create() + proxy.delete() + with pytest.raises(HTTPError): + proxy.read() + + +@pytest.mark.skip_if_not_set('fake_capsules') +@pytest.mark.tier1 +def test_positive_update_url(request, target_sat): + """Capsule url updated + + :id: 0305fd54-4e0c-4dd9-a537-d342c3dc867e + + :expectedresults: Capsule has the url updated + + """ + # Create fake capsule with name + name = gen_string('alpha') + port = target_sat.available_capsule_port + with target_sat.default_url_on_new_port(9090, port) as url: + proxy = target_sat.api.SmartProxy(url=url, name=name).create() + assert proxy.name == name + # Open another tunnel to update url + new_port = target_sat.available_capsule_port + with target_sat.default_url_on_new_port(9090, new_port) as url: + proxy.url = url + proxy = proxy.update(['url']) + assert proxy.url == url + + +@pytest.mark.skip_if_not_set('fake_capsules') +@pytest.mark.tier2 +@pytest.mark.upgrade +def test_positive_import_puppet_classes( + request, + session_puppet_enabled_sat, + puppet_proxy_port_range, + module_puppet_org, + module_puppet_loc, +): + """Import puppet classes from proxy for admin and non-admin user + + :id: 385efd1b-6146-47bf-babf-0127ce5955ed + + :expectedresults: Puppet classes are imported from proxy + + :CaseComponent: Puppet + + :CaseLevel: Integration + + :BZ: 1398695, 2142555 + + :customerscenario: true + """ + puppet_sat = session_puppet_enabled_sat + update_msg = ( + 'Successfully updated environment and puppetclasses from the on-disk puppet installation' + ) + no_update_msg = 'No changes to your environments detected' + # Create role, add permissions and create non-admin user + user_login = gen_string('alpha') + user_password = gen_string('alpha') + role = puppet_sat.api.Role().create() + puppet_sat.api_factory.create_role_permissions( + role, + { + 'ForemanPuppet::Puppetclass': [ + 'view_puppetclasses', + 'create_puppetclasses', + 'import_puppetclasses', + ] + }, + ) + user = puppet_sat.api.User( + role=[role], + admin=True, + login=user_login, + password=user_password, + organization=[module_puppet_org], + location=[module_puppet_loc], + ).create() + request.addfinalizer(user.delete) + request.addfinalizer(role.delete) + + new_port = puppet_sat.available_capsule_port + with puppet_sat.default_url_on_new_port(9090, new_port) as url: + proxy = puppet_sat.api.SmartProxy(url=url).create() + + result = proxy.import_puppetclasses() + assert result['message'] in [update_msg, no_update_msg] + # Import puppetclasses with environment + result = proxy.import_puppetclasses(environment='production') + assert result['message'] in [update_msg, no_update_msg] + + # Non-Admin user with access to import_puppetclasses + user_cfg = user_nailgun_config(user_login, user_password) + user_cfg.url = f'https://{puppet_sat.hostname}' + user_proxy = puppet_sat.api.SmartProxy(server_config=user_cfg, id=proxy.id).read() + + result = user_proxy.import_puppetclasses() + assert result['message'] in [update_msg, no_update_msg] + # Import puppetclasses with environment + result = user_proxy.import_puppetclasses(environment='production') + assert result['message'] in [update_msg, no_update_msg] + + request.addfinalizer(puppet_sat.api.SmartProxy(id=proxy.id).delete) diff --git a/tests/foreman/api/test_capsulecontent.py b/tests/foreman/api/test_capsulecontent.py index 7a9e576bdeb..120b0c0354e 100644 --- a/tests/foreman/api/test_capsulecontent.py +++ b/tests/foreman/api/test_capsulecontent.py @@ -17,22 +17,23 @@ :Upstream: No """ -import re from datetime import datetime +import re from time import sleep -import pytest -from nailgun import client -from nailgun import entities +from nailgun import client, entities from nailgun.entity_mixins import call_entity_method_with_timeout +import pytest from robottelo import constants from robottelo.config import settings from robottelo.constants import DataFile from robottelo.constants.repos import ANSIBLE_GALAXY -from robottelo.content_info import get_repo_files_by_url -from robottelo.content_info import get_repomd -from robottelo.content_info import get_repomd_revision +from robottelo.content_info import ( + get_repo_files_by_url, + get_repomd, + get_repomd_revision, +) from robottelo.utils.issue_handlers import is_open @@ -1214,7 +1215,7 @@ def test_positive_capsule_sync_status_persists( 4. Publish CV 5. Promote to lifecycle env 6. Sync Capsule - 7. Delete the task using foreman-rake console + 7. Delete all sync tasks using foreman-rake console 8. Verify the status of capsule is still synced :bz: 1956985 @@ -1237,35 +1238,30 @@ def test_positive_capsule_sync_status_persists( cv = cv.read() cvv = cv.version[-1].read() + timestamp = datetime.utcnow() cvv.promote(data={'environment_ids': function_lce.id}) - cvv = cvv.read() - - timestamp = (datetime.utcnow()).strftime('%Y-%m-%d %H:%M') module_capsule_configured.wait_for_sync() - search_result = target_sat.wait_for_tasks( - search_query='label = Actions::Katello::CapsuleContent::Sync' - f' and organization_id = {function_org.id}' - f' and started_at >= "{timestamp}"', - search_rate=15, - max_tries=5, - ) - # Delete the task using UUID (search_result[0].id) + # Delete all capsule sync tasks so that we fall back for audits. task_result = target_sat.execute( - f"""echo "ForemanTasks::Task.find( - '{search_result[0].id}').destroy!" | foreman-rake console""" + """echo "ForemanTasks::Task.where(action:'Synchronize capsule """ + f"""\\'{module_capsule_configured.hostname}\\'').delete_all" | foreman-rake console""" ) assert task_result.status == 0 - # Ensure task record was deleted. + + # Ensure task records were deleted. task_result = target_sat.execute( - f"""echo "ForemanTasks::Task.find('{search_result[0].id}')" | foreman-rake console""" + """echo "ForemanTasks::Task.where(action:'Synchronize capsule """ + f"""\\'{module_capsule_configured.hostname}\\'')" | foreman-rake console""" ) assert task_result.status == 0 - assert 'RecordNotFound' in task_result.stdout + assert '[]' in task_result.stdout # Check sync status again, and ensure last_sync_time is still correct sync_status = module_capsule_configured.nailgun_capsule.content_get_sync() - assert sync_status['last_sync_time'] >= timestamp + assert ( + datetime.strptime(sync_status['last_sync_time'], '%Y-%m-%d %H:%M:%S UTC') >= timestamp + ) @pytest.mark.tier4 @pytest.mark.skip_if_not_set('capsule') diff --git a/tests/foreman/api/test_classparameters.py b/tests/foreman/api/test_classparameters.py index fb4d3da4f2f..de34f81ae11 100644 --- a/tests/foreman/api/test_classparameters.py +++ b/tests/foreman/api/test_classparameters.py @@ -19,15 +19,12 @@ import json from random import choice +from fauxfactory import gen_boolean, gen_integer, gen_string import pytest -from fauxfactory import gen_boolean -from fauxfactory import gen_integer -from fauxfactory import gen_string from requests import HTTPError from robottelo.config import settings -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import filtered_datapoint, parametrized @filtered_datapoint diff --git a/tests/foreman/api/test_computeprofile.py b/tests/foreman/api/test_computeprofile.py index 4cb695a9290..d0ee003c7a3 100644 --- a/tests/foreman/api/test_computeprofile.py +++ b/tests/foreman/api/test_computeprofile.py @@ -16,13 +16,15 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) @pytest.mark.parametrize('name', **parametrized(valid_data_list())) diff --git a/tests/foreman/api/test_computeresource_azurerm.py b/tests/foreman/api/test_computeresource_azurerm.py index 89501467e70..74d6a733093 100644 --- a/tests/foreman/api/test_computeresource_azurerm.py +++ b/tests/foreman/api/test_computeresource_azurerm.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.constants import AZURERM_FILE_URI -from robottelo.constants import AZURERM_PLATFORM_DEFAULT -from robottelo.constants import AZURERM_PREMIUM_OS_Disk -from robottelo.constants import AZURERM_RHEL7_FT_CUSTOM_IMG_URN -from robottelo.constants import AZURERM_RHEL7_UD_IMG_URN -from robottelo.constants import AZURERM_VM_SIZE_DEFAULT +from robottelo.constants import ( + AZURERM_FILE_URI, + AZURERM_PLATFORM_DEFAULT, + AZURERM_RHEL7_FT_CUSTOM_IMG_URN, + AZURERM_RHEL7_UD_IMG_URN, + AZURERM_VM_SIZE_DEFAULT, + AZURERM_PREMIUM_OS_Disk, +) class TestAzureRMComputeResourceTestCase: diff --git a/tests/foreman/api/test_computeresource_gce.py b/tests/foreman/api/test_computeresource_gce.py index eb841508176..69bcdd7cbdf 100644 --- a/tests/foreman/api/test_computeresource_gce.py +++ b/tests/foreman/api/test_computeresource_gce.py @@ -21,12 +21,11 @@ """ import random -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.constants import GCE_RHEL_CLOUD_PROJECTS -from robottelo.constants import VALID_GCE_ZONES +from robottelo.constants import GCE_RHEL_CLOUD_PROJECTS, VALID_GCE_ZONES @pytest.mark.skip_if_not_set('gce') diff --git a/tests/foreman/api/test_computeresource_libvirt.py b/tests/foreman/api/test_computeresource_libvirt.py index a76e4d84ee5..e7e0112a0d8 100644 --- a/tests/foreman/api/test_computeresource_libvirt.py +++ b/tests/foreman/api/test_computeresource_libvirt.py @@ -20,16 +20,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import LIBVIRT_RESOURCE_URL -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) pytestmark = [pytest.mark.skip_if_not_set('libvirt')] diff --git a/tests/foreman/api/test_contentcredentials.py b/tests/foreman/api/test_contentcredentials.py index 71053b2900f..81602c953e4 100644 --- a/tests/foreman/api/test_contentcredentials.py +++ b/tests/foreman/api/test_contentcredentials.py @@ -18,15 +18,17 @@ """ from copy import copy -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests import HTTPError from robottelo.constants import DataFile -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) key_content = DataFile.VALID_GPG_KEY_FILE.read_text() diff --git a/tests/foreman/api/test_contentview.py b/tests/foreman/api/test_contentview.py index 7bacc6b7b6b..0e1e94c88d4 100644 --- a/tests/foreman/api/test_contentview.py +++ b/tests/foreman/api/test_contentview.py @@ -18,28 +18,28 @@ """ import random -import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_utf8 +from fauxfactory import gen_integer, gen_string, gen_utf8 from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.config import settings -from robottelo.config import user_nailgun_config -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CUSTOM_RPM_SHA_512_FEED_COUNT -from robottelo.constants import DataFile -from robottelo.constants import FILTER_ERRATA_TYPE -from robottelo.constants import PERMISSIONS -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants.repos import CUSTOM_RPM_SHA_512 -from robottelo.constants.repos import FEDORA_OSTREE_REPO -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.config import settings, user_nailgun_config +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CUSTOM_RPM_SHA_512_FEED_COUNT, + FILTER_ERRATA_TYPE, + PERMISSIONS, + PRDS, + REPOS, + REPOSET, + DataFile, +) +from robottelo.constants.repos import CUSTOM_RPM_SHA_512, FEDORA_OSTREE_REPO +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) # Some tests repeatedly publish content views or promote content view versions. # How many times should that be done? A higher number means a more interesting diff --git a/tests/foreman/api/test_contentviewfilter.py b/tests/foreman/api/test_contentviewfilter.py index 9bfc61778e8..5c1e175ed4c 100644 --- a/tests/foreman/api/test_contentviewfilter.py +++ b/tests/foreman/api/test_contentviewfilter.py @@ -23,19 +23,18 @@ import http from random import randint +from fauxfactory import gen_integer, gen_string +from nailgun import client, entities import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string -from nailgun import client -from nailgun import entities from requests.exceptions import HTTPError -from robottelo.config import get_credentials -from robottelo.config import settings +from robottelo.config import get_credentials, settings from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/api/test_contentviewversion.py b/tests/foreman/api/test_contentviewversion.py index 50cabbadcb2..ca0e5e7cf36 100644 --- a/tests/foreman/api/test_contentviewversion.py +++ b/tests/foreman/api/test_contentviewversion.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import DataFile -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + DEFAULT_CV, + ENVIRONMENT, + DataFile, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/api/test_convert2rhel.py b/tests/foreman/api/test_convert2rhel.py index 544f01b3e86..ce2e78d85b2 100644 --- a/tests/foreman/api/test_convert2rhel.py +++ b/tests/foreman/api/test_convert2rhel.py @@ -18,9 +18,7 @@ import requests from robottelo.config import settings -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import REPOS +from robottelo.constants import DEFAULT_ARCHITECTURE, DEFAULT_SUBSCRIPTION_NAME, REPOS def create_repo(sat, org, repo_url, ssl_cert=None): @@ -49,6 +47,12 @@ def create_activation_key(sat, org, lce, cv, subscription_id): environment=lce, ).create() act_key.add_subscriptions(data={'subscription_id': subscription_id}) + content = sat.cli.ActivationKey.product_content({'id': act_key.id, 'organization-id': org.id}) + act_key.content_override( + data={'content_overrides': [{'content_label': content[0]['label'], 'value': '1'}]} + ) + ak_subscriptions = act_key.product_content()['results'] + ak_subscriptions[0]['enabled'] = True return act_key @@ -61,11 +65,11 @@ def update_cv(sat, cv, lce, repos): return cv -def register_host(sat, act_key, module_org, module_loc, host, ubi=None): +def register_host(sat, act_key, org, module_loc, host, ubi=None): """Register host to satellite""" # generate registration command command = sat.api.RegistrationCommand( - organization=module_org, + organization=org, activation_keys=[act_key.name], location=module_loc, insecure=True, @@ -85,13 +89,21 @@ def ssl_cert(module_target_sat, module_org): @pytest.fixture -def activation_key_rhel(target_sat, module_org, module_lce, module_promoted_cv, version): +def activation_key_rhel( + module_target_sat, module_entitlement_manifest_org, module_lce, module_promoted_cv, version +): """Create activation key that will be used after conversion for registration""" - subs = target_sat.api.Subscription(organization=module_org).search( - query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'} - ) + subs = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org.id + ).search(query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'}) assert subs - return create_activation_key(target_sat, module_org, module_lce, module_promoted_cv, subs[0].id) + return create_activation_key( + module_target_sat, + module_entitlement_manifest_org, + module_lce, + module_promoted_cv, + subs[0].id, + ) @pytest.fixture(scope='module') @@ -125,6 +137,8 @@ def enable_rhel_subscriptions(module_target_sat, module_entitlement_manifest_org module_target_sat.wait_for_tasks( search_query=(f'id = {task["id"]}'), poll_timeout=2500, + search_rate=20, + max_tries=10, ) task_status = module_target_sat.api.ForemanTask(id=task['id']).poll() assert task_status['result'] == 'success' @@ -133,9 +147,9 @@ def enable_rhel_subscriptions(module_target_sat, module_entitlement_manifest_org @pytest.fixture def centos( - target_sat, + module_target_sat, centos_host, - module_org, + module_entitlement_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -146,15 +160,28 @@ def centos( # updating centos packages on CentOS 8 is necessary for conversion major = version.split('.')[0] if major == '8': - centos_host.execute("yum update -y centos-*") + centos_host.execute('yum -y update centos-*') repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(target_sat, module_org, repo_url) - cv = update_cv(target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]) - c2r_sub = target_sat.api.Subscription(organization=module_org, name=repo.product.name).search()[ - 0 - ] - act_key = create_activation_key(target_sat, module_org, module_lce, cv, c2r_sub.id) - register_host(target_sat, act_key, module_org, smart_proxy_location, centos_host) + repo = create_repo(module_target_sat, module_entitlement_manifest_org, repo_url) + cv = update_cv( + module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] + ) + c2r_sub = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org.id, name=repo.product.name + ).search()[0] + act_key = create_activation_key( + module_target_sat, module_entitlement_manifest_org, module_lce, cv, c2r_sub.id + ) + register_host( + module_target_sat, + act_key, + module_entitlement_manifest_org, + smart_proxy_location, + centos_host, + ) + centos_host.execute('yum -y update kernel*') + if centos_host.execute('needs-restarting -r').status == 1: + centos_host.power_control(state='reboot') yield centos_host # close ssh session before teardown, because of reboot in conversion it may cause problems centos_host.close() @@ -162,9 +189,9 @@ def centos( @pytest.fixture def oracle( - target_sat, + module_target_sat, oracle_host, - module_org, + module_entitlement_manifest_org, smart_proxy_location, module_promoted_cv, module_lce, @@ -185,16 +212,27 @@ def oracle( oracle_host.power_control(state='reboot') major = version.split('.')[0] repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major) - repo = create_repo(target_sat, module_org, repo_url, ssl_cert) - cv = update_cv(target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]) - c2r_sub = target_sat.api.Subscription(organization=module_org, name=repo.product.name).search()[ - 0 - ] - act_key = create_activation_key(target_sat, module_org, module_lce, cv, c2r_sub.id) + repo = create_repo(module_target_sat, module_entitlement_manifest_org, repo_url, ssl_cert) + cv = update_cv( + module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo] + ) + c2r_sub = module_target_sat.api.Subscription( + organization=module_entitlement_manifest_org, name=repo.product.name + ).search()[0] + act_key = create_activation_key( + module_target_sat, module_entitlement_manifest_org, module_lce, cv, c2r_sub.id + ) ubi_url = settings.repos.convert2rhel.ubi7 if major == '7' else settings.repos.convert2rhel.ubi8 - ubi = create_repo(target_sat, module_org, ubi_url) + ubi = create_repo(module_target_sat, module_entitlement_manifest_org, ubi_url) ubi_repo = ubi.full_path.replace('https', 'http') - register_host(target_sat, act_key, module_org, smart_proxy_location, oracle_host, ubi_repo) + register_host( + module_target_sat, + act_key, + module_entitlement_manifest_org, + smart_proxy_location, + oracle_host, + ubi_repo, + ) yield oracle_host # close ssh session before teardown, because of reboot in conversion it may cause problems oracle_host.close() @@ -203,7 +241,7 @@ def oracle( @pytest.fixture(scope='module') def version(request): """Version of converted OS""" - return settings.content_host.get(request.param).vm.release + return settings.content_host.get(request.param).vm.deploy_rhel_version @pytest.mark.e2e @@ -212,7 +250,7 @@ def version(request): ['oracle7', 'oracle8'], indirect=True, ) -def test_convert2rhel_oracle(target_sat, oracle, activation_key_rhel, version): +def test_convert2rhel_oracle(module_target_sat, oracle, activation_key_rhel, version): """Convert Oracle linux to RHEL :id: 7fd393f0-551a-4de0-acdd-7f026b485f79 @@ -229,46 +267,42 @@ def test_convert2rhel_oracle(target_sat, oracle, activation_key_rhel, version): :CaseImportance: Medium """ - host_content = target_sat.api.Host(id=oracle.hostname).read_json() + host_content = module_target_sat.api.Host(id=oracle.hostname).read_json() assert host_content['operatingsystem_name'] == f"OracleLinux {version}" # execute job 'Convert 2 RHEL' on host template_id = ( - target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id + module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id ) - job = target_sat.api.JobInvocation().run( + job = module_target_sat.api.JobInvocation().run( synchronous=False, data={ 'job_template_id': template_id, 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'Data telemetry': 'yes', }, 'targeting_type': 'static_query', 'search_query': f'name = {oracle.hostname}', }, ) # wait for job to complete - target_sat.wait_for_tasks( - f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1000 + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=2500 ) - result = target_sat.api.JobInvocation(id=job['id']).read() + result = module_target_sat.api.JobInvocation(id=job['id']).read() assert result.succeeded == 1 # check facts: correct os and valid subscription status - host_content = target_sat.api.Host(id=oracle.hostname).read_json() - # workaround for BZ 2080347 - assert ( - host_content['operatingsystem_name'].startswith(f"RHEL Server {version}") - or host_content['operatingsystem_name'].startswith(f"RedHat {version}") - or host_content['operatingsystem_name'].startswith(f"RHEL {version}") - ) + host_content = module_target_sat.api.Host(id=oracle.hostname).read_json() + assert host_content['subscription_status'] == 0 @pytest.mark.e2e -@pytest.mark.parametrize("version", ['centos7', 'centos8'], indirect=True) -def test_convert2rhel_centos(target_sat, centos, activation_key_rhel, version): +@pytest.mark.parametrize('version', ['centos7', 'centos8'], indirect=True) +def test_convert2rhel_centos(module_target_sat, centos, activation_key_rhel, version): """Convert Centos linux to RHEL :id: 6f698440-7d85-4deb-8dd9-363ea9003b92 @@ -285,39 +319,41 @@ def test_convert2rhel_centos(target_sat, centos, activation_key_rhel, version): :CaseImportance: Medium """ - host_content = target_sat.api.Host(id=centos.hostname).read_json() + host_content = module_target_sat.api.Host(id=centos.hostname).read_json() major = version.split('.')[0] - assert host_content['operatingsystem_name'] == f"CentOS {major}" - + assert host_content['operatingsystem_name'] == f'CentOS {major}' # execute job 'Convert 2 RHEL' on host template_id = ( - target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id + module_target_sat.api.JobTemplate().search(query={'search': 'name="Convert to RHEL"'})[0].id ) - job = target_sat.api.JobInvocation().run( + job = module_target_sat.api.JobInvocation().run( synchronous=False, data={ 'job_template_id': template_id, 'inputs': { 'Activation Key': activation_key_rhel.id, 'Restart': 'yes', + 'Data telemetry': 'yes', }, 'targeting_type': 'static_query', 'search_query': f'name = {centos.hostname}', }, ) # wait for job to complete - target_sat.wait_for_tasks( - f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1000 + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', + poll_timeout=2500, + search_rate=20, ) - result = target_sat.api.JobInvocation(id=job['id']).read() + result = module_target_sat.api.JobInvocation(id=job['id']).read() assert result.succeeded == 1 # check facts: correct os and valid subscription status - host_content = target_sat.api.Host(id=centos.hostname).read_json() + host_content = module_target_sat.api.Host(id=centos.hostname).read_json() # workaround for BZ 2080347 assert ( - host_content['operatingsystem_name'].startswith(f"RHEL Server {version}") - or host_content['operatingsystem_name'].startswith(f"RedHat {version}") - or host_content['operatingsystem_name'].startswith(f"RHEL {version}") + host_content['operatingsystem_name'].startswith(f'RHEL Server {version}') + or host_content['operatingsystem_name'].startswith(f'RedHat {version}') + or host_content['operatingsystem_name'].startswith(f'RHEL {version}') ) assert host_content['subscription_status'] == 0 diff --git a/tests/foreman/api/test_discoveredhost.py b/tests/foreman/api/test_discoveredhost.py index ee2f1aa92ff..9b4a5ae5e22 100644 --- a/tests/foreman/api/test_discoveredhost.py +++ b/tests/foreman/api/test_discoveredhost.py @@ -16,14 +16,10 @@ """ import re -import pytest -from fauxfactory import gen_choice -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_string +from fauxfactory import gen_choice, gen_ipaddr, gen_mac, gen_string from nailgun import entity_mixins -from wait_for import TimedOutError -from wait_for import wait_for +import pytest +from wait_for import TimedOutError, wait_for from robottelo.logging import logger from robottelo.utils.datafactory import valid_data_list diff --git a/tests/foreman/api/test_discoveryrule.py b/tests/foreman/api/test_discoveryrule.py index 2c3680e2985..f55a287d675 100644 --- a/tests/foreman/api/test_discoveryrule.py +++ b/tests/foreman/api/test_discoveryrule.py @@ -16,11 +16,9 @@ :Upstream: No """ -import pytest -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_string +from fauxfactory import gen_choice, gen_integer, gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.utils.datafactory import valid_data_list diff --git a/tests/foreman/api/test_docker.py b/tests/foreman/api/test_docker.py index 5d5fe969a72..e87dac66fb6 100644 --- a/tests/foreman/api/test_docker.py +++ b/tests/foreman/api/test_docker.py @@ -12,23 +12,21 @@ :Upstream: No """ -from random import choice -from random import randint -from random import shuffle +from random import choice, randint, shuffle -import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url +from fauxfactory import gen_string, gen_url from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import invalid_docker_upstream_names -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_docker_repository_names -from robottelo.utils.datafactory import valid_docker_upstream_names +from robottelo.constants import CONTAINER_REGISTRY_HUB, CONTAINER_UPSTREAM_NAME +from robottelo.utils.datafactory import ( + generate_strings_list, + invalid_docker_upstream_names, + parametrized, + valid_docker_repository_names, + valid_docker_upstream_names, +) DOCKER_PROVIDER = 'Docker' diff --git a/tests/foreman/api/test_environment.py b/tests/foreman/api/test_environment.py index 1225659cb18..cb965244211 100644 --- a/tests/foreman/api/test_environment.py +++ b/tests/foreman/api/test_environment.py @@ -20,14 +20,16 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import invalid_environments_list -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_environments_list +from robottelo.utils.datafactory import ( + invalid_environments_list, + invalid_names_list, + parametrized, + valid_environments_list, +) @pytest.mark.e2e diff --git a/tests/foreman/api/test_errata.py b/tests/foreman/api/test_errata.py index 7e0afba949d..f33931fe833 100644 --- a/tests/foreman/api/test_errata.py +++ b/tests/foreman/api/test_errata.py @@ -19,12 +19,11 @@ # For ease of use hc refers to host-collection throughout this document from time import sleep -import pytest from nailgun import entities +import pytest from robottelo import constants -from robottelo.cli.factory import setup_org_for_a_custom_repo -from robottelo.cli.factory import setup_org_for_a_rh_repo +from robottelo.cli.factory import setup_org_for_a_custom_repo, setup_org_for_a_rh_repo from robottelo.cli.host import Host from robottelo.config import settings from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME diff --git a/tests/foreman/api/test_filter.py b/tests/foreman/api/test_filter.py index 98cf6c26f51..75d42707e4a 100644 --- a/tests/foreman/api/test_filter.py +++ b/tests/foreman/api/test_filter.py @@ -20,8 +20,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_foremantask.py b/tests/foreman/api/test_foremantask.py index 6ddcc3c0884..f7e8377e82f 100644 --- a/tests/foreman/api/test_foremantask.py +++ b/tests/foreman/api/test_foremantask.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError diff --git a/tests/foreman/api/test_host.py b/tests/foreman/api/test_host.py index e43c2f7669e..8393dd5ecf0 100644 --- a/tests/foreman/api/test_host.py +++ b/tests/foreman/api/test_host.py @@ -22,19 +22,13 @@ """ import http +from fauxfactory import gen_choice, gen_integer, gen_ipaddr, gen_mac, gen_string +from nailgun import client, entities import pytest -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_string -from nailgun import client -from nailgun import entities from requests.exceptions import HTTPError from robottelo.config import get_credentials -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT +from robottelo.constants import DEFAULT_CV, ENVIRONMENT from robottelo.utils import datafactory diff --git a/tests/foreman/api/test_hostcollection.py b/tests/foreman/api/test_hostcollection.py index 5484dfd4ea9..0b5c0147ead 100644 --- a/tests/foreman/api/test_hostcollection.py +++ b/tests/foreman/api/test_hostcollection.py @@ -16,18 +16,19 @@ :Upstream: No """ -from random import choice -from random import randint +from random import choice, randint -import pytest from broker import Broker from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.hosts import ContentHost -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/api/test_hostgroup.py b/tests/foreman/api/test_hostgroup.py index 405ed180dea..9e3c3aa0c21 100644 --- a/tests/foreman/api/test_hostgroup.py +++ b/tests/foreman/api/test_hostgroup.py @@ -18,17 +18,17 @@ """ from random import randint -import pytest from fauxfactory import gen_string -from nailgun import client -from nailgun import entities -from nailgun import entity_fields +from nailgun import client, entities, entity_fields +import pytest from requests.exceptions import HTTPError from robottelo.config import get_credentials -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_hostgroups_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_hostgroups_list, +) @pytest.fixture diff --git a/tests/foreman/api/test_http_proxy.py b/tests/foreman/api/test_http_proxy.py index 5244450d409..f9c3023c77e 100644 --- a/tests/foreman/api/test_http_proxy.py +++ b/tests/foreman/api/test_http_proxy.py @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo import constants from robottelo.config import settings diff --git a/tests/foreman/api/test_ldapauthsource.py b/tests/foreman/api/test_ldapauthsource.py index e896397c4eb..10b9851b3d6 100644 --- a/tests/foreman/api/test_ldapauthsource.py +++ b/tests/foreman/api/test_ldapauthsource.py @@ -16,12 +16,11 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE +from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE from robottelo.utils.datafactory import generate_strings_list diff --git a/tests/foreman/api/test_lifecycleenvironment.py b/tests/foreman/api/test_lifecycleenvironment.py index 57effa04b1a..b8e7b3ef347 100644 --- a/tests/foreman/api/test_lifecycleenvironment.py +++ b/tests/foreman/api/test_lifecycleenvironment.py @@ -20,15 +20,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.constants import ENVIRONMENT -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/api/test_location.py b/tests/foreman/api/test_location.py index 22546cd06cd..ad226389c57 100644 --- a/tests/foreman/api/test_location.py +++ b/tests/foreman/api/test_location.py @@ -21,15 +21,16 @@ """ from random import randint +from fauxfactory import gen_integer, gen_string import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string from requests.exceptions import HTTPError from robottelo.constants import DEFAULT_LOC -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, +) @filtered_datapoint diff --git a/tests/foreman/api/test_media.py b/tests/foreman/api/test_media.py index 1f2abbbdefe..e5524d914fd 100644 --- a/tests/foreman/api/test_media.py +++ b/tests/foreman/api/test_media.py @@ -18,16 +18,17 @@ """ import random -import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url +from fauxfactory import gen_string, gen_url from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.constants import OPERATING_SYSTEMS -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) class TestMedia: diff --git a/tests/foreman/api/test_multiple_paths.py b/tests/foreman/api/test_multiple_paths.py index bf975ce7f58..66b4bc7ea9a 100644 --- a/tests/foreman/api/test_multiple_paths.py +++ b/tests/foreman/api/test_multiple_paths.py @@ -18,17 +18,13 @@ """ import http +from nailgun import client, entities, entity_fields import pytest -from nailgun import client -from nailgun import entities -from nailgun import entity_fields -from robottelo.config import get_credentials -from robottelo.config import user_nailgun_config +from robottelo.config import get_credentials, user_nailgun_config from robottelo.logging import logger from robottelo.utils.datafactory import parametrized - VALID_ENTITIES = { entities.ActivationKey, entities.Architecture, @@ -92,7 +88,7 @@ def _get_readable_attributes(entity): for field_name in list(attributes.keys()): if isinstance( entity.get_fields()[field_name], - (entity_fields.OneToOneField, entity_fields.OneToManyField), + entity_fields.OneToOneField | entity_fields.OneToManyField, ): del attributes[field_name] diff --git a/tests/foreman/api/test_notifications.py b/tests/foreman/api/test_notifications.py index c832bfd0990..a8b4c24ebf8 100644 --- a/tests/foreman/api/test_notifications.py +++ b/tests/foreman/api/test_notifications.py @@ -20,14 +20,12 @@ from re import findall from tempfile import mkstemp -import pytest from fauxfactory import gen_string -from wait_for import TimedOutError -from wait_for import wait_for +import pytest +from wait_for import TimedOutError, wait_for from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import DEFAULT_ORG +from robottelo.constants import DEFAULT_LOC, DEFAULT_ORG from robottelo.utils.issue_handlers import is_open diff --git a/tests/foreman/api/test_operatingsystem.py b/tests/foreman/api/test_operatingsystem.py index 722362063a3..4cdb27a04a2 100644 --- a/tests/foreman/api/test_operatingsystem.py +++ b/tests/foreman/api/test_operatingsystem.py @@ -16,17 +16,19 @@ :Upstream: No """ -import random from http.client import NOT_FOUND +import random -import pytest from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError from robottelo.constants import OPERATING_SYSTEMS -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) class TestOperatingSystemParameter: diff --git a/tests/foreman/api/test_organization.py b/tests/foreman/api/test_organization.py index 4fa1c5f6397..692504faf79 100644 --- a/tests/foreman/api/test_organization.py +++ b/tests/foreman/api/test_organization.py @@ -23,17 +23,19 @@ import json from random import randint -import pytest from fauxfactory import gen_string -from nailgun import client -from nailgun import entities +from nailgun import client, entities +import pytest from requests.exceptions import HTTPError from robottelo.config import get_credentials from robottelo.constants import DEFAULT_ORG -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, +) +from robottelo.utils.issue_handlers import is_open @filtered_datapoint @@ -77,7 +79,10 @@ def test_positive_create(self): headers={'content-type': 'text/plain'}, verify=False, ) - assert http.client.UNSUPPORTED_MEDIA_TYPE == response.status_code + if is_open('BZ:2228820'): + assert response.status_code in [http.client.UNSUPPORTED_MEDIA_TYPE, 500] + else: + assert http.client.UNSUPPORTED_MEDIA_TYPE == response.status_code @pytest.mark.tier1 @pytest.mark.build_sanity diff --git a/tests/foreman/api/test_oscap_tailoringfiles.py b/tests/foreman/api/test_oscap_tailoringfiles.py index 039754324cc..d29eed1ca95 100644 --- a/tests/foreman/api/test_oscap_tailoringfiles.py +++ b/tests/foreman/api/test_oscap_tailoringfiles.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/api/test_oscappolicy.py b/tests/foreman/api/test_oscappolicy.py index 3f1d0269326..1efdd3e3779 100644 --- a/tests/foreman/api/test_oscappolicy.py +++ b/tests/foreman/api/test_oscappolicy.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest class TestOscapPolicy: diff --git a/tests/foreman/api/test_partitiontable.py b/tests/foreman/api/test_partitiontable.py index a8046111449..b1f64b8f5ac 100644 --- a/tests/foreman/api/test_partitiontable.py +++ b/tests/foreman/api/test_partitiontable.py @@ -22,16 +22,17 @@ """ import random +from fauxfactory import gen_integer, gen_string import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string from requests.exceptions import HTTPError from robottelo.constants import OPERATING_SYSTEMS -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + generate_strings_list, + invalid_values_list, + parametrized, + valid_data_list, +) class TestPartitionTable: diff --git a/tests/foreman/api/test_permission.py b/tests/foreman/api/test_permission.py index 68068453295..f8eb16a1500 100644 --- a/tests/foreman/api/test_permission.py +++ b/tests/foreman/api/test_permission.py @@ -20,14 +20,14 @@ :Upstream: No """ +from itertools import chain import json import re -from itertools import chain -import pytest from fauxfactory import gen_alphanumeric from nailgun import entities from nailgun.entity_fields import OneToManyField +import pytest from requests.exceptions import HTTPError from robottelo.config import user_nailgun_config @@ -367,8 +367,18 @@ def test_positive_check_update(self, entity_cls, class_org, class_location): new_entity = new_entity.create() name = new_entity.get_fields()['name'].gen_value() with pytest.raises(HTTPError): - entity_cls(self.cfg, id=new_entity.id, name=name).update(['name']) + if entity_cls is entities.ActivationKey: + entity_cls(self.cfg, id=new_entity.id, name=name, organization=class_org).update( + ['name'] + ) + else: + entity_cls(self.cfg, id=new_entity.id, name=name).update(['name']) self.give_user_permission(_permission_name(entity_cls, 'update')) # update() calls read() under the hood, which triggers # permission error - entity_cls(self.cfg, id=new_entity.id, name=name).update_json(['name']) + if entity_cls is entities.ActivationKey: + entity_cls(self.cfg, id=new_entity.id, name=name, organization=class_org).update_json( + ['name'] + ) + else: + entity_cls(self.cfg, id=new_entity.id, name=name).update_json(['name']) diff --git a/tests/foreman/api/test_product.py b/tests/foreman/api/test_product.py index 47010338795..84b6d78f866 100644 --- a/tests/foreman/api/test_product.py +++ b/tests/foreman/api/test_product.py @@ -19,19 +19,23 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import DataFile -from robottelo.constants import REPO_TYPE -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + REPO_TYPE, + DataFile, +) +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) @pytest.mark.tier1 diff --git a/tests/foreman/api/test_provisioning.py b/tests/foreman/api/test_provisioning.py index 30fd3587c66..3b4ded29dc8 100644 --- a/tests/foreman/api/test_provisioning.py +++ b/tests/foreman/api/test_provisioning.py @@ -16,11 +16,13 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string -from packaging.version import Version +import pytest from wait_for import wait_for +from robottelo.config import settings +from robottelo.utils.installer import InstallerCommand + @pytest.mark.e2e @pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) @@ -64,10 +66,6 @@ def test_rhel_pxe_provisioning( hostgroup=provisioning_hostgroup, organization=module_sca_manifest_org, location=module_location, - content_facet_attributes={ - 'content_view_id': module_provisioning_rhel_content.cv.id, - 'lifecycle_environment_id': module_lce_library.id, - }, name=gen_string('alpha').lower(), mac=host_mac_addr, operatingsystem=module_provisioning_rhel_content.os, @@ -106,11 +104,25 @@ def test_rhel_pxe_provisioning( # Wait for the host to be rebooted and SSH daemon to be started. provisioning_host.wait_for_connection() - # Perform version check + # Perform version check and check if root password is properly updated host_os = host.operatingsystem.read() - expected_rhel_version = Version(f'{host_os.major}.{host_os.minor}') + expected_rhel_version = f'{host_os.major}.{host_os.minor}' + + if int(host_os.major) >= 9: + assert ( + provisioning_host.execute( + 'echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config; systemctl restart sshd' + ).status + == 0 + ) + host_ssh_os = sat.execute( + f'sshpass -p {settings.provisioning.host_root_password} ' + 'ssh -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -o PasswordAuthentication=yes ' + f'-o UserKnownHostsFile=/dev/null root@{provisioning_host.hostname} cat /etc/redhat-release' + ) + assert host_ssh_os.status == 0 assert ( - provisioning_host.os_version == expected_rhel_version + expected_rhel_version in host_ssh_os.stdout ), 'Different than the expected OS version was installed' # Verify provisioning log exists on host at correct path @@ -136,3 +148,131 @@ def test_rhel_pxe_provisioning( # assert that the host is subscribed and consumes # subsctiption provided by the activation key assert provisioning_host.subscribed, 'Host is not subscribed' + + +@pytest.mark.e2e +@pytest.mark.parametrize('pxe_loader', ['ipxe'], indirect=True) +@pytest.mark.on_premises_provisioning +@pytest.mark.rhel_ver_match('[^6]') +def test_rhel_ipxe_provisioning( + request, + module_provisioning_sat, + module_sca_manifest_org, + module_location, + provisioning_host, + pxe_loader, + module_provisioning_rhel_content, + provisioning_hostgroup, + module_lce_library, + module_default_org_view, +): + """Provision a host using iPXE workflow + + :id: 9e016e1d-757a-48e7-9159-131bb65dc4ed + + :steps: + 1. Configure satellite for provisioning + 2. provision a host + 3. Check that resulting host is registered to Satellite + 4. Check host is subscribed to Satellite + + :expectedresults: + 1. Provisioning via iPXE is successful + 2. Host installs right version of RHEL + 3. Satellite is able to run REX job on the host + 4. Host is registered to Satellite and subscription status is 'Success' + + :parametrized: yes + """ + # TODO: parametrize iPXE Chain BIOS as pxe loader after #BZ:2171172 is fixed + sat = module_provisioning_sat.sat + # set http url + ipxe_http_url = sat.install( + InstallerCommand( + f'foreman-proxy-dhcp-ipxefilename "http://{sat.hostname}/unattended/iPXE?bootstrap=1"' + ) + ) + assert ipxe_http_url.status == 0 + host_mac_addr = provisioning_host._broker_args['provisioning_nic_mac_addr'] + host = sat.api.Host( + hostgroup=provisioning_hostgroup, + organization=module_sca_manifest_org, + location=module_location, + name=gen_string('alpha').lower(), + mac=host_mac_addr, + operatingsystem=module_provisioning_rhel_content.os, + subnet=module_provisioning_sat.subnet, + host_parameters_attributes=[ + {'name': 'remote_execution_connect_by_ip', 'value': 'true', 'parameter_type': 'boolean'} + ], + build=True, # put the host in build mode + ).create(create_missing=False) + # Clean up the host to free IP leases on Satellite. + # broker should do that as a part of the teardown, putting here just to make sure. + request.addfinalizer(host.delete) + # Start the VM, do not ensure that we can connect to SSHD + provisioning_host.power_control(ensure=False) + + # TODO: Implement Satellite log capturing logic to verify that + # all the events are captured in the logs. + + # Host should do call back to the Satellite reporting + # the result of the installation. Wait until Satellite reports that the host is installed. + wait_for( + lambda: host.read().build_status_label != 'Pending installation', + timeout=1500, + delay=10, + ) + host = host.read() + assert host.build_status_label == 'Installed' + + # Change the hostname of the host as we know it already. + # In the current infra environment we do not support + # addressing hosts using FQDNs, falling back to IP. + provisioning_host.hostname = host.ip + # Host is not blank anymore + provisioning_host.blank = False + + # Wait for the host to be rebooted and SSH daemon to be started. + provisioning_host.wait_for_connection() + + # Perform version check and check if root password is properly updated + host_os = host.operatingsystem.read() + expected_rhel_version = f'{host_os.major}.{host_os.minor}' + + if int(host_os.major) >= 9: + assert ( + provisioning_host.execute( + 'echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config; systemctl restart sshd' + ).status + == 0 + ) + host_ssh_os = sat.execute( + f'sshpass -p {settings.provisioning.host_root_password} ' + 'ssh -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -o PasswordAuthentication=yes ' + f'-o UserKnownHostsFile=/dev/null root@{provisioning_host.hostname} cat /etc/redhat-release' + ) + assert host_ssh_os.status == 0 + assert ( + expected_rhel_version in host_ssh_os.stdout + ), f'The installed OS version differs from the expected version {expected_rhel_version}' + + # Run a command on the host using REX to verify that Satellite's SSH key is present on the host + template_id = ( + sat.api.JobTemplate().search(query={'search': 'name="Run Command - Script Default"'})[0].id + ) + job = sat.api.JobInvocation().run( + data={ + 'job_template_id': template_id, + 'inputs': { + 'command': f'subscription-manager config | grep "hostname = {sat.hostname}"' + }, + 'search_query': f"name = {host.name}", + 'targeting_type': 'static_query', + }, + ) + assert job['result'] == 'success', 'Job invocation failed' + + # assert that the host is subscribed and consumes + # subsctiption provided by the activation key + assert provisioning_host.subscribed, 'Host is not subscribed' diff --git a/tests/foreman/api/test_provisioning_puppet.py b/tests/foreman/api/test_provisioning_puppet.py index 195f458b3b9..a32d542abb3 100644 --- a/tests/foreman/api/test_provisioning_puppet.py +++ b/tests/foreman/api/test_provisioning_puppet.py @@ -16,10 +16,10 @@ :Upstream: No """ -import pytest -import requests from fauxfactory import gen_string from packaging.version import Version +import pytest +import requests from wait_for import wait_for diff --git a/tests/foreman/api/test_provisioningtemplate.py b/tests/foreman/api/test_provisioningtemplate.py index cf8225bb933..ac0567181c5 100644 --- a/tests/foreman/api/test_provisioningtemplate.py +++ b/tests/foreman/api/test_provisioningtemplate.py @@ -21,17 +21,13 @@ """ from random import choice -import pytest -from fauxfactory import gen_choice -from fauxfactory import gen_mac -from fauxfactory import gen_string +from fauxfactory import gen_choice, gen_integer, gen_mac, gen_string from nailgun import client +import pytest from requests.exceptions import HTTPError -from robottelo.config import settings -from robottelo.config import user_nailgun_config -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import valid_data_list +from robottelo.config import settings, user_nailgun_config +from robottelo.utils.datafactory import invalid_names_list, valid_data_list @pytest.fixture(scope='module') @@ -474,3 +470,94 @@ def test_positive_template_subnet_with_boot_mode( for template in pxe_templates: rendered = host.read_template(data={'template_kind': f'{template}'})['template'] assert f'ks={ks_param}' in rendered + + def test_positive_template_use_graphical_installer( + self, module_target_sat, module_sca_manifest_org, module_location, default_os + ): + """Check whether use_graphical_installer paremeter is properly rendered + in the provisioning templates + + :id: 2decc787-59b0-41e6-96be-5dd9371c8967 + + :expectedresults: Rendered template should contain value set as per use_graphical_installer + host parameter for respective rhel hosts. + + :BZ: 2106753 + + :customerscenario: true + """ + host = module_target_sat.api.Host( + name=gen_string('alpha'), + organization=module_sca_manifest_org, + location=module_location, + operatingsystem=default_os, + ).create() + # Host will default boot into text mode with kickstart's skipx command + render = host.read_template(data={'template_kind': 'provision'})['template'] + assert 'skipx' in render + assert 'text' in render + # Using use_graphical_installer host param to override and use graphical mode to boot + host.host_parameters_attributes = [ + {'name': 'use_graphical_installer', 'value': 'true', 'parameter_type': 'boolean'} + ] + host.update(['host_parameters_attributes']) + render = host.read_template(data={'template_kind': 'provision'})['template'] + assert 'graphical' in render + assert 'skipx' not in render + + @pytest.mark.parametrize('module_sync_kickstart_content', [8], indirect=True) + def test_positive_template_check_aap_snippet( + self, + module_sync_kickstart_content, + module_target_sat, + module_sca_manifest_org, + module_location, + module_default_org_view, + module_lce_library, + default_architecture, + default_partitiontable, + ): + """Read the kickstart default template and verify ansible_provisioning_callback + snippet is rendered correctly + + :id: 065ef48f-bec5-4535-8be7-d8527fa21564 + + :expectedresults: Rendered template should contain values set for AAP snippet + host parameter for respective rhel hosts. + + :BZ: 2024175 + + :customerscenario: true + """ + aap_fqdn = 'env-aap.example.com' + template_id = gen_integer(1, 10) + extra_vars_dict = '{"package_install": "zsh"}' + config_key = gen_string('alpha') + host_params = [ + {'name': 'ansible_tower_provisioning', 'value': 'true', 'parameter_type': 'boolean'}, + {'name': 'ansible_tower_fqdn', 'value': aap_fqdn, 'parameter_type': 'string'}, + {'name': 'ansible_host_config_key', 'value': config_key, 'parameter_type': 'string'}, + {'name': 'ansible_job_template_id', 'value': template_id, 'parameter_type': 'integer'}, + {'name': 'ansible_extra_vars', 'value': extra_vars_dict, 'parameter_type': 'string'}, + ] + host = module_target_sat.api.Host( + organization=module_sca_manifest_org, + location=module_location, + name=gen_string('alpha').lower(), + operatingsystem=module_sync_kickstart_content.os, + architecture=default_architecture, + domain=module_sync_kickstart_content.domain, + root_pass=settings.provisioning.host_root_password, + ptable=default_partitiontable, + content_facet_attributes={ + 'content_source_id': module_target_sat.nailgun_smart_proxy.id, + 'content_view_id': module_default_org_view.id, + 'lifecycle_environment_id': module_lce_library.id, + }, + host_parameters_attributes=host_params, + ).create() + render = host.read_template(data={'template_kind': 'provision'})['template'] + assert f'https://{aap_fqdn}/api/v2/job_templates/{template_id}/callback/' in render + assert 'systemctl enable ansible-callback' in render + assert f'"host_config_key":"{config_key}"' in render + assert '{"package_install": "zsh"}' in render diff --git a/tests/foreman/api/test_reporttemplates.py b/tests/foreman/api/test_reporttemplates.py index c3f88b952f7..5047a9a616c 100644 --- a/tests/foreman/api/test_reporttemplates.py +++ b/tests/foreman/api/test_reporttemplates.py @@ -16,26 +16,25 @@ :Upstream: No """ -from datetime import datetime - -import pytest from broker import Broker from fauxfactory import gen_string from nailgun import entities +import pytest from requests import HTTPError from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import ( + DEFAULT_SUBSCRIPTION_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE_NAME, + FAKE_2_CUSTOM_PACKAGE, + PRDS, + REPOS, + REPOSET, +) from robottelo.hosts import ContentHost -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import parametrized, valid_data_list from robottelo.utils.issue_handlers import is_open @@ -378,7 +377,7 @@ def test_negative_create_report_without_name(): @pytest.mark.rhel_ver_match(r'^(?!6$)\d+$') @pytest.mark.no_containers def test_positive_applied_errata( - module_org, module_location, module_cv, module_lce, rhel_contenthost, target_sat + function_org, function_location, function_lce, rhel_contenthost, target_sat ): """Generate an Applied Errata report @@ -395,21 +394,25 @@ def test_positive_applied_errata( :CaseImportance: Medium """ activation_key = target_sat.api.ActivationKey( - environment=module_lce, organization=module_org + environment=function_lce, organization=function_org ).create() + cv = target_sat.api.ContentView(organization=function_org).create() ERRATUM_ID = str(settings.repos.yum_6.errata[2]) target_sat.cli_factory.setup_org_for_a_custom_repo( { 'url': settings.repos.yum_9.url, - 'organization-id': module_org.id, - 'content-view-id': module_cv.id, - 'lifecycle-environment-id': module_lce.id, + 'organization-id': function_org.id, + 'content-view-id': cv.id, + 'lifecycle-environment-id': function_lce.id, 'activationkey-id': activation_key.id, } ) - result = rhel_contenthost.register(module_org, module_location, activation_key.name, target_sat) + result = rhel_contenthost.register( + function_org, function_location, activation_key.name, target_sat + ) assert f'The registered system name is: {rhel_contenthost.hostname}' in result.stdout assert rhel_contenthost.subscribed + rhel_contenthost.execute(r'subscription-manager repos --enable \*') assert rhel_contenthost.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 assert rhel_contenthost.execute(f'rpm -q {FAKE_1_CUSTOM_PACKAGE}').status == 0 task_id = target_sat.api.JobInvocation().run( @@ -418,7 +421,7 @@ def test_positive_applied_errata( 'inputs': {'errata': ERRATUM_ID}, 'targeting_type': 'static_query', 'search_query': f'name = {rhel_contenthost.hostname}', - 'organization_id': module_org.id, + 'organization_id': function_org.id, }, )['id'] target_sat.wait_for_tasks( @@ -433,7 +436,7 @@ def test_positive_applied_errata( ) res = rt.generate( data={ - 'organization_id': module_org.id, + 'organization_id': function_org.id, 'report_format': 'json', 'input_values': { 'Filter Errata Type': 'all', @@ -717,18 +720,21 @@ def test_positive_generate_job_report(setup_content, target_sat, rhel7_contentho @pytest.mark.no_containers @pytest.mark.rhel_ver_match(r'^(?!6$)\d+$') def test_positive_installable_errata( - module_org, module_target_sat, module_location, module_cv, module_lce, rhel_contenthost + target_sat, function_org, function_lce, function_location, rhel_contenthost ): - """Generate an Installable Errata report + """Generate an Installable Errata report using the Report Template - Available Errata, + with the option of 'Installable'. :id: 6263a0fa-5021-4553-939b-84fb71c81d59 :setup: A Host with some applied errata :steps: - 1. Downgrade a package contained within the applied errata - 2. Perform a search for any applicable Erratum - 3. Generate an Installable Errata report + 1. Install an outdated package version + 2. Apply some errata which updates the package + 3. Downgrade the package impacted by the erratum + 4. Perform a search for any Available Errata + 5. Generate an Installable Report from the Available Errata :expectedresults: A report is generated with the installable errata listed @@ -738,68 +744,88 @@ def test_positive_installable_errata( :BZ: 1726504 """ - activation_key = module_target_sat.api.ActivationKey( - environment=module_lce, organization=module_org + activation_key = target_sat.api.ActivationKey( + environment=function_lce, organization=function_org ).create() - ERRATUM_ID = str(settings.repos.yum_9.errata[0]) - module_target_sat.cli_factory.setup_org_for_a_custom_repo( + custom_cv = target_sat.api.ContentView(organization=function_org).create() + ERRATUM_ID = str(settings.repos.yum_6.errata[2]) + target_sat.cli_factory.setup_org_for_a_custom_repo( { - 'url': settings.repos.yum_9.url, - 'organization-id': module_org.id, - 'content-view-id': module_cv.id, - 'lifecycle-environment-id': module_lce.id, + 'url': settings.repos.yum_6.url, + 'organization-id': function_org.id, + 'content-view-id': custom_cv.id, + 'lifecycle-environment-id': function_lce.id, 'activationkey-id': activation_key.id, } ) result = rhel_contenthost.register( - module_org, module_location, activation_key.name, module_target_sat + function_org, function_location, activation_key.name, target_sat ) assert f'The registered system name is: {rhel_contenthost.hostname}' in result.stdout assert rhel_contenthost.subscribed - result = rhel_contenthost.run(f'yum install -y {FAKE_2_CUSTOM_PACKAGE}') - assert result.status == 0 + + # Remove package if already installed on this host + rhel_contenthost.execute(f'yum remove -y {FAKE_1_CUSTOM_PACKAGE_NAME}') + # Install the outdated package version + rhel_contenthost.execute(r'subscription-manager repos --enable \*') + assert rhel_contenthost.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 + assert ( + rhel_contenthost.execute(f'rpm -q {FAKE_1_CUSTOM_PACKAGE_NAME}').stdout.strip() + == FAKE_1_CUSTOM_PACKAGE + ) + # Install/Apply the errata - task_id = module_target_sat.api.JobInvocation().run( + task_id = target_sat.api.JobInvocation().run( data={ 'feature': 'katello_errata_install', 'inputs': {'errata': ERRATUM_ID}, 'targeting_type': 'static_query', 'search_query': f'name = {rhel_contenthost.hostname}', - 'organization_id': module_org.id, + 'organization_id': function_org.id, }, )['id'] - module_target_sat.wait_for_tasks( + target_sat.wait_for_tasks( search_query=(f'label = Actions::RemoteExecution::RunHostsJob and id = {task_id}'), search_rate=15, max_tries=10, ) - # Downgrade package impacted by the erratum - result = rhel_contenthost.run(f'yum downgrade -y {FAKE_1_CUSTOM_PACKAGE}') - assert result.status == 0 + # Check that applying erratum updated the package + assert ( + rhel_contenthost.execute(f'rpm -q {FAKE_1_CUSTOM_PACKAGE_NAME}').stdout.strip() + == FAKE_2_CUSTOM_PACKAGE + ) + # Downgrade the package + assert rhel_contenthost.execute(f'yum downgrade -y {FAKE_1_CUSTOM_PACKAGE}').status == 0 - _data_for_generate = { - 'organization_id': module_org.id, + # Data to generate Installable Errata report + _rt_input_data = { + 'organization_id': function_org.id, 'report_format': "json", 'input_values': { - 'Filter Errata Type': 'all', - 'Include Last Reboot': 'no', - 'Status': 'all', + 'Installability': 'installable', }, } - search_query = {'search': 'name="Host - Applicable Errata"'} - template = module_target_sat.api.ReportTemplate() - # Allow search to collect results, it may take some time - # Wait until a generated report is populated + + # Gather Errata using the template 'Available Errata', may take some time + # When condition is met, newest Report Template will have Errata entries wait_for( lambda: ( - [] != template.search(query=search_query)[0].read().generate(data=_data_for_generate) + target_sat.api.ReportTemplate() + .search(query={'search': 'name="Host - Available Errata"'})[0] + .read() + .generate(data=_rt_input_data) + != [] ), timeout=120, delay=10, ) - # Now that a populated report is ready, generate a final time - report = template.search(query=search_query)[0].read().generate(data=_data_for_generate) - assert report != [] - assert datetime.now().strftime("%Y-%m-%d") in report[0]['Available since'] - assert FAKE_1_CUSTOM_PACKAGE_NAME in report[0]['Packages'] - assert report[0]['Erratum'] == ERRATUM_ID + report = ( + target_sat.api.ReportTemplate() + .search(query={'search': 'name="Host - Available Errata"'})[0] + .read() + .generate(data=_rt_input_data) + ) + assert report + installable_errata = report[0] + assert FAKE_1_CUSTOM_PACKAGE_NAME in installable_errata['Packages'] + assert installable_errata['Erratum'] == ERRATUM_ID diff --git a/tests/foreman/api/test_repositories.py b/tests/foreman/api/test_repositories.py index 29675dfa2eb..58cbd9792b2 100644 --- a/tests/foreman/api/test_repositories.py +++ b/tests/foreman/api/test_repositories.py @@ -16,16 +16,16 @@ :Upstream: No """ -import pytest from manifester import Manifester from nailgun import entities from nailgun.entity_mixins import call_entity_method_with_timeout +import pytest from requests.exceptions import HTTPError from robottelo import constants from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings -from robottelo.constants import MIRRORING_POLICIES +from robottelo.constants import DEFAULT_ARCHITECTURE, MIRRORING_POLICIES, REPOS from robottelo.utils.datafactory import parametrized @@ -243,3 +243,51 @@ def test_positive_multiple_orgs_with_same_repo(target_sat): repo_counts = target_sat.api.Repository(id=repo.id).read().content_counts repos.append(repo_counts) assert repos[0] == repos[1] == repos[2] + + +def test_positive_sync_mulitple_large_repos(module_target_sat, module_entitlement_manifest_org): + """Enable and bulk sync multiple large repositories + + :id: b51c4a3d-d532-4342-be61-e868f7c3a723 + + :Steps: + 1. Enabled multiple large Repositories + Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8 + Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8 + Red Hat Enterprise Linux 8 for x86_64 - AppStream Kickstart 8 + Red Hat Enterprise Linux 8 for x86_64 - BaseOS Kickstart 8 + 2. Sync all four repositories at the same time + 3. Assert that the bulk sync succeeds + + :expectedresults: All repositories should sync with no errors + + :BZ: 2224031 + """ + repo_names = ['rhel8_bos', 'rhel8_aps'] + kickstart_names = ['rhel8_bos', 'rhel8_aps'] + for name in repo_names: + rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=DEFAULT_ARCHITECTURE, + org_id=module_entitlement_manifest_org.id, + product=REPOS[name]['product'], + repo=REPOS[name]['name'], + reposet=REPOS[name]['reposet'], + releasever=REPOS[name]['releasever'], + ) + + for name in kickstart_names: + rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=constants.DEFAULT_ARCHITECTURE, + org_id=module_entitlement_manifest_org.id, + product=constants.REPOS['kickstart'][name]['product'], + repo=constants.REPOS['kickstart'][name]['name'], + reposet=constants.REPOS['kickstart'][name]['reposet'], + releasever=constants.REPOS['kickstart'][name]['version'], + ) + rh_repos = module_target_sat.api.Repository(id=rh_repo_id).read() + rh_products = module_target_sat.api.Product(id=rh_repos.product.id).read() + assert len(rh_products.repository) == 4 + res = module_target_sat.api.ProductBulkAction().sync( + data={'ids': [rh_products.id]}, timeout=2000 + ) + assert res['result'] == 'success' diff --git a/tests/foreman/api/test_repository.py b/tests/foreman/api/test_repository.py index b12c7389cc3..e6f03383dc2 100644 --- a/tests/foreman/api/test_repository.py +++ b/tests/foreman/api/test_repository.py @@ -17,25 +17,20 @@ :Upstream: No """ import re +from string import punctuation import tempfile import time -from string import punctuation -from urllib.parse import urljoin -from urllib.parse import urlparse -from urllib.parse import urlunparse +from urllib.parse import urljoin, urlparse, urlunparse -import pytest from fauxfactory import gen_string -from nailgun import client -from nailgun import entities -from nailgun.entity_mixins import call_entity_method_with_timeout -from nailgun.entity_mixins import TaskFailedError +from nailgun import client, entities +from nailgun.entity_mixins import TaskFailedError, call_entity_method_with_timeout +import pytest from requests.exceptions import HTTPError from robottelo import constants from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import repos as repo_constants +from robottelo.constants import DataFile, repos as repo_constants from robottelo.content_info import get_repo_files_by_url from robottelo.logging import logger from robottelo.utils import datafactory @@ -1554,6 +1549,40 @@ def test_positive_sync_kickstart_check_os( ) assert len(os) + @pytest.mark.tier2 + @pytest.mark.parametrize( + 'repo_options', + **datafactory.parametrized( + {'yum': {'content_type': 'yum', 'unprotected': True, 'url': 'http://example.com'}} + ), + indirect=True, + ) + def test_missing_content_id(self, repo): + """Handle several cases of missing content ID correctly + + :id: f507790a-933b-4b3f-ac93-cade6967fbd2 + + :parametrized: yes + + :expectedresults: Repository URL can be set to something new and the repo can be deleted + + :BZ:2032040 + """ + # Wait for async metadata generate task to finish + time.sleep(5) + # Get rid of the URL + repo.url = '' + repo = repo.update(['url']) + assert repo.url is None + # Now change the URL back + repo.url = 'http://example.com' + repo = repo.update(['url']) + assert repo.url == 'http://example.com' + # Now delete the Repo + repo.delete() + with pytest.raises(HTTPError): + repo.read() + class TestDockerRepository: """Tests specific to using ``Docker`` repositories.""" diff --git a/tests/foreman/api/test_repository_set.py b/tests/foreman/api/test_repository_set.py index 7dd560c9cb9..449bb1be33c 100644 --- a/tests/foreman/api/test_repository_set.py +++ b/tests/foreman/api/test_repository_set.py @@ -19,11 +19,10 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest -from robottelo.constants import PRDS -from robottelo.constants import REPOSET +from robottelo.constants import PRDS, REPOSET pytestmark = [pytest.mark.run_in_one_thread, pytest.mark.tier1] diff --git a/tests/foreman/api/test_rhc.py b/tests/foreman/api/test_rhc.py index abc35f87744..992d1017c77 100644 --- a/tests/foreman/api/test_rhc.py +++ b/tests/foreman/api/test_rhc.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.utils.issue_handlers import is_open diff --git a/tests/foreman/api/test_rhcloud_inventory.py b/tests/foreman/api/test_rhcloud_inventory.py index 57af28af261..de1fe67d8cb 100644 --- a/tests/foreman/api/test_rhcloud_inventory.py +++ b/tests/foreman/api/test_rhcloud_inventory.py @@ -16,14 +16,11 @@ :Upstream: No """ +from fauxfactory import gen_alphanumeric, gen_string import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string from robottelo.config import robottelo_tmp_dir -from robottelo.utils.io import get_local_file_data -from robottelo.utils.io import get_report_data -from robottelo.utils.io import get_report_metadata +from robottelo.utils.io import get_local_file_data, get_report_data, get_report_metadata def common_assertion(report_path): @@ -66,10 +63,11 @@ def test_rhcloud_inventory_api_e2e( 8. metadata contains source and foreman_rh_cloud_version keys. 9. Assert Hostnames, IP addresses, infrastructure type, and installed packages are present in report. + 10. Assert that system_purpose_sla field is present in the inventory report. :CaseImportance: Critical - :BZ: 1807829, 1926100, 1965234, 1824183, 1879453 + :BZ: 1807829, 1926100, 1965234, 1824183, 1879453, 1845113 :customerscenario: true """ @@ -83,18 +81,20 @@ def test_rhcloud_inventory_api_e2e( destination=local_report_path ) common_assertion(local_report_path) - # Assert Hostnames, IP addresses, and installed packages are present in report. json_data = get_report_data(local_report_path) json_meta_data = get_report_metadata(local_report_path) + # Verify that metadata contains source and foreman_rh_cloud_version keys. prefix = 'tfm-' if module_target_sat.os_version.major < 8 else '' package_version = module_target_sat.run( f'rpm -qa --qf "%{{VERSION}}" {prefix}rubygem-foreman_rh_cloud' ).stdout.strip() assert json_meta_data['source_metadata']['foreman_rh_cloud_version'] == str(package_version) assert json_meta_data['source'] == 'Satellite' + # Verify Hostnames are present in report. hostnames = [host['fqdn'] for host in json_data['hosts']] assert virtual_host.hostname in hostnames assert baremetal_host.hostname in hostnames + # Verify IP addresses are present in report. ip_addresses = [ host['system_profile']['network_interfaces'][0]['ipv4_addresses'][0] for host in json_data['hosts'] @@ -104,16 +104,21 @@ def test_rhcloud_inventory_api_e2e( assert baremetal_host.ip_addr in ip_addresses assert virtual_host.ip_addr in ipv4_addresses assert baremetal_host.ip_addr in ipv4_addresses - + # Verify infrastructure type. infrastructure_type = [ host['system_profile']['infrastructure_type'] for host in json_data['hosts'] ] assert 'physical' and 'virtual' in infrastructure_type - + # Verify installed packages are present in report. all_host_profiles = [host['system_profile'] for host in json_data['hosts']] for host_profiles in all_host_profiles: assert 'installed_packages' in host_profiles assert len(host_profiles['installed_packages']) > 1 + # Verify that system_purpose_sla field is present in the inventory report. + for host in json_data['hosts']: + assert host['facts'][0]['facts']['system_purpose_role'] == 'test-role' + assert host['facts'][0]['facts']['system_purpose_sla'] == 'Self-Support' + assert host['facts'][0]['facts']['system_purpose_usage'] == 'test-usage' @pytest.mark.e2e @@ -136,7 +141,7 @@ def test_rhcloud_inventory_api_hosts_synchronization( 5. Assert inventory status for the host. :expectedresults: - 1. Task detail should contain should contain number of hosts + 1. Task detail should contain number of hosts synchronized and disconnected. :BZ: 1970223 @@ -157,81 +162,6 @@ def test_rhcloud_inventory_api_hosts_synchronization( # To Do: Add support in Nailgun to get Insights and Inventory host properties. -@pytest.mark.stubbed -def test_rhcloud_inventory_mtu_field(): - """Verify that the hosts having mtu field value as string in foreman's Nic object - is present in the inventory report. - - :id: df6d5f4f-5ee1-4f34-bf24-b93fbd089322 - - :customerscenario: true - - :Steps: - 1. Register a content host. - 2. If value of mtu field is not a string then use foreman-rake to change it. - 3. Generate inventory report. - 4. Assert that host is listed in the inventory report. - 5. Assert that value of mtu field in generated report is a number. - - :CaseImportance: Medium - - :expectedresults: - 1. Host having string mtu field value is present in the inventory report. - 2. Value of mtu field in generated inventory report is a number. - - :BZ: 1893439 - - :CaseAutomation: ManualOnly - """ - - -@pytest.mark.run_in_one_thread -@pytest.mark.tier2 -def test_system_purpose_sla_field( - inventory_settings, - rhcloud_manifest_org, - rhcloud_registered_hosts, - module_target_sat, -): - """Verify that system_purpose_sla field is present in the inventory report - for the host subscribed using Activation key with service level set in it. - - :id: 3974338c-3a66-41ac-af32-ee76e3c37aef - - :customerscenario: true - - :Steps: - 1. Create an activation key with service level set in it. - 2. Register a content host using the created activation key. - 3. Generate inventory report. - 4. Assert that host is listed in the inventory report. - 5. Assert that system_purpose_sla field is present in the inventory report. - - :CaseImportance: Medium - - :expectedresults: - 1. Host is present in the inventory report. - 2. system_purpose_sla field is present in the inventory report. - - :BZ: 1845113 - - :CaseAutomation: Automated - """ - org = rhcloud_manifest_org - virtual_host, baremetal_host = rhcloud_registered_hosts - local_report_path = robottelo_tmp_dir.joinpath(f'{gen_alphanumeric()}_{org.id}.tar.xz') - module_target_sat.generate_inventory_report(org) - # Download report - module_target_sat.api.Organization(id=org.id).rh_cloud_download_report( - destination=local_report_path - ) - json_data = get_report_data(local_report_path) - for host in json_data['hosts']: - assert host['facts'][0]['facts']['system_purpose_role'] == 'test-role' - assert host['facts'][0]['facts']['system_purpose_sla'] == 'Self-Support' - assert host['facts'][0]['facts']['system_purpose_usage'] == 'test-usage' - - @pytest.mark.stubbed def test_rhcloud_inventory_auto_upload_setting(): """Verify that Automatic inventory upload setting works as expected. @@ -255,7 +185,7 @@ def test_rhcloud_inventory_auto_upload_setting(): 2. If "Automatic inventory upload" setting is disable then satellite does not generate and upload inventory report automatically. - :BZ: 1793017 + :BZ: 1793017, 1865879 :CaseAutomation: ManualOnly """ @@ -272,8 +202,8 @@ def test_inventory_upload_with_http_proxy(): :Steps: 1. Create a http proxy which is using port 80. - 2. Register a content host with satellite. - 3. Set Default HTTP Proxy setting. + 2. Update general and content proxy in Satellite settings. + 3. Register a content host with satellite. 4. Generate and upload inventory report. 5. Assert that host is listed in the inventory report. 6. Assert that upload process finished successfully. @@ -304,14 +234,20 @@ def test_include_parameter_tags_setting( :Steps: 1. Enable include_parameter_tags setting. 2. Register a content host with satellite. - 3. Generate inventory report. - 4. Assert that generated report contains valid json file. + 3. Create a host parameter with long text value. + 4. Create Hostcollection with name containing double quotes. + 5. Generate inventory report. + 6. Assert that generated report contains valid json file. + 7. Observe the tag generated from the parameter. :expectedresults: 1. Valid json report is created. 2. satellite_parameter values are string. + 3. Parameter tag value must not be created after the + allowed length. + 4. Tag value is escaped properly. - :BZ: 1981869, 1967438 + :BZ: 1981869, 1967438, 2035204, 1874587, 1874619 :customerscenario: true @@ -319,113 +255,21 @@ def test_include_parameter_tags_setting( """ org = rhcloud_manifest_org virtual_host, baremetal_host = rhcloud_registered_hosts - local_report_path = robottelo_tmp_dir.joinpath(f'{gen_alphanumeric()}_{org.id}.tar.xz') - module_target_sat.update_setting('include_parameter_tags', True) - module_target_sat.generate_inventory_report(org) - # Download report - module_target_sat.api.Organization(id=org.id).rh_cloud_download_report( - destination=local_report_path - ) - json_data = get_report_data(local_report_path) - common_assertion(local_report_path) - for host in json_data['hosts']: - for tag in host['tags']: - if tag['namespace'] == 'satellite_parameter': - assert type(tag['value']) is str - break - - -@pytest.mark.tier3 -def test_rh_cloud_tag_values( - inventory_settings, - rhcloud_manifest_org, - module_target_sat, - rhcloud_registered_hosts, -): - """Verify that tag values are escaped properly when hostgroup name - contains " (double quote) in it. - - :id: ea7cd7ca-4157-4aac-ad8e-e66b88740ce3 - - :customerscenario: true - - :Steps: - 1. Create Hostcollection with name containing double quotes. - 2. Register a content host with satellite. - 3. Add a content host to hostgroup. - 4. Generate inventory report. - 5. Assert that generated report contains valid json file. - 6. Assert that hostcollection tag value is escaped properly. - - :expectedresults: - 1. Valid json report is created. - 2. Tag value is escaped properly. - - :BZ: 1874587, 1874619 - - :CaseAutomation: Automated - """ - org = rhcloud_manifest_org - + # Create a host parameter with long text value. + param_name = gen_string('alpha') + param_value = gen_string('alpha', length=260) + module_target_sat.api.CommonParameter(name=param_name, value=param_value).create() + # Create Hostcollection with name containing double quotes. host_col_name = gen_string('alpha') host_name = rhcloud_registered_hosts[0].hostname host = module_target_sat.api.Host().search(query={'search': host_name})[0] host_collection = module_target_sat.api.HostCollection( organization=org, name=f'"{host_col_name}"', host=[host] ).create() - assert len(host_collection.host) == 1 + # Generate inventory report local_report_path = robottelo_tmp_dir.joinpath(f'{gen_alphanumeric()}_{org.id}.tar.xz') - # Generate report - module_target_sat.generate_inventory_report(org) - module_target_sat.api.Organization(id=org.id).rh_cloud_download_report( - destination=local_report_path - ) - common_assertion(local_report_path) - json_data = get_report_data(local_report_path) - for host in json_data['hosts']: - if host['fqdn'] == host_name: - for tag in host['tags']: - if tag['key'] == 'host_collection': - assert tag['value'] == f'"{host_col_name}"' - break - - -@pytest.mark.run_in_one_thread -@pytest.mark.tier2 -def test_positive_tag_values_max_length( - inventory_settings, - rhcloud_manifest_org, - rhcloud_registered_hosts, - module_target_sat, - target_sat, -): - """Verify that tags values are truncated properly for the host parameter - with max length. - - :id: dbcc7245-88af-4c35-87b8-92de01030cb5 - - :Steps: - 1. Enable include_parameter_tags setting - 2. Create a host parameter with long text value. - 3. Generate a rh_cloud report. - 4. Observe the tag generated from the parameter. - - :expectedresults: - 1. Parameter tag value must not be created after the - allowed length. - - :BZ: 2035204 - - :CaseAutomation: Automated - """ - - param_name = gen_string('alpha') - param_value = gen_string('alpha', length=260) - target_sat.api.CommonParameter(name=param_name, value=param_value).create() - - org = rhcloud_manifest_org - local_report_path = robottelo_tmp_dir.joinpath(f'{gen_alphanumeric()}_{org.id}.tar.xz') + # Enable include_parameter_tags setting module_target_sat.update_setting('include_parameter_tags', True) module_target_sat.generate_inventory_report(org) # Download report @@ -434,8 +278,16 @@ def test_positive_tag_values_max_length( ) json_data = get_report_data(local_report_path) common_assertion(local_report_path) + # Verify that parameter tag value is not be created. for host in json_data['hosts']: for tag in host['tags']: if tag['key'] == param_name: assert tag['value'] == "Original value exceeds 250 characters" break + # Verify that hostcollection tag value is escaped properly. + for host in json_data['hosts']: + if host['fqdn'] == host_name: + for tag in host['tags']: + if tag['key'] == 'host_collection': + assert tag['value'] == f'"{host_col_name}"' + break diff --git a/tests/foreman/api/test_rhsm.py b/tests/foreman/api/test_rhsm.py index 9229fb355df..2ebd5b517e0 100644 --- a/tests/foreman/api/test_rhsm.py +++ b/tests/foreman/api/test_rhsm.py @@ -22,11 +22,10 @@ """ import http -import pytest from nailgun import client +import pytest -from robottelo.config import get_credentials -from robottelo.config import get_url +from robottelo.config import get_credentials, get_url @pytest.mark.tier1 diff --git a/tests/foreman/api/test_role.py b/tests/foreman/api/test_role.py index e669dd9d19b..d75ff03e84b 100644 --- a/tests/foreman/api/test_role.py +++ b/tests/foreman/api/test_role.py @@ -20,17 +20,14 @@ :Upstream: No """ -import pytest from nailgun import entities from nailgun.config import ServerConfig +import pytest from requests.exceptions import HTTPError from robottelo.cli.ldapauthsource import LDAPAuthSource -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE -from robottelo.utils.datafactory import gen_string -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import parametrized +from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE +from robottelo.utils.datafactory import gen_string, generate_strings_list, parametrized from robottelo.utils.issue_handlers import is_open @@ -186,7 +183,7 @@ def create_ldap(self, ad_data, target_sat, module_location, module_org): ldap_user_passwd=ad_data['ldap_user_passwd'], authsource=entities.AuthSourceLDAP( onthefly_register=True, - account=ad_data['ldap_user_name'], + account=fr"{ad_data['workgroup']}\{ad_data['ldap_user_name']}", account_password=ad_data['ldap_user_passwd'], base_dn=ad_data['base_dn'], groups_base=ad_data['group_base_dn'], diff --git a/tests/foreman/api/test_settings.py b/tests/foreman/api/test_settings.py index e9dd50f25ff..b5d0542d35d 100644 --- a/tests/foreman/api/test_settings.py +++ b/tests/foreman/api/test_settings.py @@ -18,14 +18,16 @@ """ import random -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + filtered_datapoint, + generate_strings_list, + parametrized, + valid_data_list, +) @filtered_datapoint diff --git a/tests/foreman/api/test_smartproxy.py b/tests/foreman/api/test_smartproxy.py deleted file mode 100644 index a18634c45d2..00000000000 --- a/tests/foreman/api/test_smartproxy.py +++ /dev/null @@ -1,377 +0,0 @@ -"""Tests for the ``smart_proxies`` paths. - -:Requirement: Smartproxy - -:CaseAutomation: Automated - -:CaseLevel: Component - -:CaseComponent: Capsule - -:Team: Endeavour - -:TestType: Functional - -:CaseImportance: Critical - -:Upstream: No -""" -import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url -from requests import HTTPError - -from robottelo.config import user_nailgun_config -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.issue_handlers import is_open - - -pytestmark = [pytest.mark.run_in_one_thread] - - -@pytest.fixture(scope='module') -def module_proxy_attrs(module_target_sat): - """Find a ``SmartProxy``. - - Every Satellite has a built-in smart proxy, so searching for an - existing smart proxy should always succeed. - """ - smart_proxy = module_target_sat.api.SmartProxy().search( - query={'search': f'url = {module_target_sat.url}:9090'} - ) - # Check that proxy is found and unpack it from the list - assert len(smart_proxy) > 0, "No smart proxy is found" - smart_proxy = smart_proxy[0] - return set(smart_proxy.update_json([]).keys()) - - -def _create_smart_proxy(request, target_sat, **kwargs): - """Create a Smart Proxy and add the finalizer""" - proxy = target_sat.api.SmartProxy(**kwargs).create() - - @request.addfinalizer - def _cleanup(): - target_sat.api.SmartProxy(id=proxy.id).delete() - - return proxy - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_negative_create_with_url(target_sat): - """Proxy creation with random URL - - :id: e48a6260-97e0-4234-a69c-77bbbcde85d6 - - :expectedresults: Proxy is not created - - :CaseLevel: Component - - """ - # Create a random proxy - with pytest.raises(HTTPError) as context: - target_sat.api.SmartProxy(url=gen_url(scheme='https')).create() - assert 'Unable to communicate' in context.value.response.text - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -@pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_create_with_name(request, target_sat, name): - """Proxy creation with valid name - - :id: 0ffe0dc5-675e-45f4-b7e1-a14d3dd81f6e - - :expectedresults: Proxy is created - - :CaseLevel: Component - - :Parametrized: Yes - - :BZ: 2084661 - """ - if is_open('BZ:2084661') and 'html' in request.node.name: - pytest.skip() - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy = _create_smart_proxy(request, target_sat, name=name, url=url) - assert proxy.name == name - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -@pytest.mark.upgrade -def test_positive_delete(target_sat): - """Proxy deletion - - :id: 872bf12e-736d-43d1-87cf-2923966b59d0 - - :expectedresults: Proxy is deleted - - :CaseLevel: Component - - :BZ: 1398695 - """ - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy = target_sat.api.SmartProxy(url=url).create() - proxy.delete() - with pytest.raises(HTTPError): - proxy.read() - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_update_name(request, target_sat): - """Proxy name update - - :id: f279640e-d7e9-48a3-aed8-7bf406e9d6f2 - - :expectedresults: Proxy has the name updated - - :CaseLevel: Component - - """ - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy = _create_smart_proxy(request, target_sat, url=url) - for new_name in valid_data_list(): - proxy.name = new_name - proxy = proxy.update(['name']) - assert proxy.name == new_name - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_update_url(request, target_sat): - """Proxy url update - - :id: 0305fd54-4e0c-4dd9-a537-d342c3dc867e - - :expectedresults: Proxy has the url updated - - :CaseLevel: Component - - """ - # Create fake capsule - port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, port) as url: - proxy = _create_smart_proxy(request, target_sat, url=url) - # Open another tunnel to update url - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy.url = url - proxy = proxy.update(['url']) - assert proxy.url == url - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_update_organization(request, target_sat): - """Proxy name update with the home proxy - - :id: 62631275-7a92-4d34-a949-c56e0c4063f1 - - :expectedresults: Proxy has the name updated - - :CaseLevel: Component - - """ - organizations = [target_sat.api.Organization().create() for _ in range(2)] - newport = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, newport) as url: - proxy = _create_smart_proxy(request, target_sat, url=url) - proxy.organization = organizations - proxy = proxy.update(['organization']) - assert {org.id for org in proxy.organization} == {org.id for org in organizations} - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_update_location(request, target_sat): - """Proxy name update with the home proxy - - :id: e08eaaa9-7c11-4cda-bbe7-6d1f7c732569 - - :expectedresults: Proxy has the name updated - - :CaseLevel: Component - - """ - locations = [target_sat.api.Location().create() for _ in range(2)] - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy = _create_smart_proxy(request, target_sat, url=url) - proxy.location = locations - proxy = proxy.update(['location']) - assert {loc.id for loc in proxy.location} == {loc.id for loc in locations} - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier2 -@pytest.mark.upgrade -def test_positive_refresh_features(request, target_sat): - """Refresh smart proxy features, search for proxy by id - - :id: d0237546-702e-4d1a-9212-8391295174da - - :expectedresults: Proxy features are refreshed - - :CaseLevel: Integration - - """ - # Since we want to run multiple commands against our fake capsule, we - # need the tunnel kept open in order not to allow different concurrent - # test to claim it. Thus we want to manage the tunnel manually. - - # get an available port for our fake capsule - new_port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, new_port) as url: - proxy = _create_smart_proxy(request, target_sat, url=url) - proxy.refresh() - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier2 -def test_positive_import_puppet_classes( - request, - session_puppet_enabled_sat, - puppet_proxy_port_range, - module_puppet_org, - module_puppet_loc, -): - """Import puppet classes from proxy for admin and non-admin user - - :id: 385efd1b-6146-47bf-babf-0127ce5955ed - - :expectedresults: Puppet classes are imported from proxy - - :CaseLevel: Integration - - :BZ: 1398695, 2142555 - - :customerscenario: true - """ - puppet_sat = session_puppet_enabled_sat - update_msg = ( - 'Successfully updated environment and puppetclasses from the on-disk puppet installation' - ) - no_update_msg = 'No changes to your environments detected' - # Create role, add permissions and create non-admin user - user_login = gen_string('alpha') - user_password = gen_string('alpha') - role = puppet_sat.api.Role().create() - puppet_sat.api_factory.create_role_permissions( - role, - { - 'ForemanPuppet::Puppetclass': [ - 'view_puppetclasses', - 'create_puppetclasses', - 'import_puppetclasses', - ] - }, - ) - user = puppet_sat.api.User( - role=[role], - admin=True, - login=user_login, - password=user_password, - organization=[module_puppet_org], - location=[module_puppet_loc], - ).create() - request.addfinalizer(user.delete) - request.addfinalizer(role.delete) - - new_port = puppet_sat.available_capsule_port - with puppet_sat.default_url_on_new_port(9090, new_port) as url: - proxy = puppet_sat.api.SmartProxy(url=url).create() - - result = proxy.import_puppetclasses() - assert result['message'] in [update_msg, no_update_msg] - # Import puppetclasses with environment - result = proxy.import_puppetclasses(environment='production') - assert result['message'] in [update_msg, no_update_msg] - - # Non-Admin user with access to import_puppetclasses - user_cfg = user_nailgun_config(user_login, user_password) - user_cfg.url = f'https://{puppet_sat.hostname}' - user_proxy = puppet_sat.api.SmartProxy(server_config=user_cfg, id=proxy.id).read() - - result = user_proxy.import_puppetclasses() - assert result['message'] in [update_msg, no_update_msg] - # Import puppetclasses with environment - result = user_proxy.import_puppetclasses(environment='production') - assert result['message'] in [update_msg, no_update_msg] - - request.addfinalizer(puppet_sat.api.SmartProxy(id=proxy.id).delete) - - -"""Tests to see if the server returns the attributes it should. - -Satellite should return a full description of an entity each time an entity -is created, read or updated. These tests verify that certain attributes -really are returned. The ``one_to_*_names`` functions know what names -Satellite may assign to fields. -""" - - -@pytest.mark.tier1 -def test_positive_update_loc(module_proxy_attrs): - """Update a smart proxy. Inspect the server's response. - - :id: 42d6b749-c047-4fd2-90ee-ffab7be558f9 - - :expectedresults: The response contains some value for the ``location`` - field. - - :BZ: 1262037 - - :CaseImportance: High - - :CaseLevel: Component - - """ - names = {'location', 'location_ids', 'locations'} - assert len(names & module_proxy_attrs) >= 1, f'None of {names} are in {module_proxy_attrs}' - - -@pytest.mark.tier1 -def test_positive_update_org(module_proxy_attrs): - """Update a smart proxy. Inspect the server's response. - - :id: fbde9f87-33db-4b95-a5f7-71a618460c84 - - :expectedresults: The response contains some value for the - ``organization`` field. - - :BZ: 1262037 - - :CaseImportance: High - - :CaseLevel: Component - - """ - names = {'organization', 'organization_ids', 'organizations'} - assert len(names & module_proxy_attrs) >= 1, f'None of {names} are in {module_proxy_attrs}' - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_search_nondefault_proxy(request, target_sat): - """Search non-default proxy with id!=1 - - :id: caf51662-6b4e-11ed-baba-2b9d7b368002 - - :expectedresults: Non-default proxy can be searched - - :BZ: 2077824 - - :customerscenario: true - """ - with target_sat.default_url_on_new_port(9090, target_sat.available_capsule_port) as url: - proxy = _create_smart_proxy(request, target_sat, name=gen_string('alpha'), url=url) - capsules = target_sat.api.Capsule().search(query={'search': 'id != 1'}) - assert len(capsules) == 1 - assert capsules[0].url == proxy.url - assert capsules[0].name == proxy.name diff --git a/tests/foreman/api/test_subnet.py b/tests/foreman/api/test_subnet.py index 10390260db5..c5188d12808 100644 --- a/tests/foreman/api/test_subnet.py +++ b/tests/foreman/api/test_subnet.py @@ -23,14 +23,16 @@ """ import re -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import gen_string -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import ( + gen_string, + generate_strings_list, + invalid_values_list, + parametrized, +) @pytest.mark.tier1 diff --git a/tests/foreman/api/test_subscription.py b/tests/foreman/api/test_subscription.py index 85b19bd8a85..8b1da648d81 100644 --- a/tests/foreman/api/test_subscription.py +++ b/tests/foreman/api/test_subscription.py @@ -20,19 +20,15 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities from nailgun.config import ServerConfig from nailgun.entity_mixins import TaskFailedError +import pytest from requests.exceptions import HTTPError from robottelo.cli.subscription import Subscription -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET - +from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME, PRDS, REPOS, REPOSET pytestmark = [pytest.mark.run_in_one_thread] diff --git a/tests/foreman/api/test_syncplan.py b/tests/foreman/api/test_syncplan.py index 8719c0629b6..9653322bd55 100644 --- a/tests/foreman/api/test_syncplan.py +++ b/tests/foreman/api/test_syncplan.py @@ -20,30 +20,24 @@ :Upstream: No """ -from datetime import datetime -from datetime import timedelta +from datetime import datetime, timedelta from time import sleep +from fauxfactory import gen_choice, gen_string +from nailgun import client, entities import pytest -from fauxfactory import gen_choice -from fauxfactory import gen_string -from nailgun import client -from nailgun import entities from requests.exceptions import HTTPError -from robottelo.config import get_credentials -from robottelo.config import get_url -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants import SYNC_INTERVAL +from robottelo.config import get_credentials, get_url +from robottelo.constants import PRDS, REPOS, REPOSET, SYNC_INTERVAL from robottelo.logging import logger -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_cron_expressions -from robottelo.utils.datafactory import valid_data_list - +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, + valid_cron_expressions, + valid_data_list, +) sync_date_deltas = { # Today @@ -220,7 +214,7 @@ def test_positive_create_with_interval(module_org, interval): @pytest.mark.parametrize('sync_delta', **parametrized(sync_date_deltas)) @pytest.mark.tier1 -def test_positive_create_with_sync_date(module_org, sync_delta): +def test_positive_create_with_sync_date(module_org, sync_delta, target_sat): """Create a sync plan and update its sync date. :id: bdb6e0a9-0d3b-4811-83e2-2140b7bb62e3 @@ -232,11 +226,11 @@ def test_positive_create_with_sync_date(module_org, sync_delta): :CaseImportance: Critical """ sync_date = datetime.now() + timedelta(seconds=sync_delta) - sync_plan = entities.SyncPlan( + sync_plan = target_sat.api.SyncPlan( enabled=False, organization=module_org, sync_date=sync_date ).create() sync_plan = sync_plan.read() - assert sync_date.strftime('%Y-%m-%d %H:%M:%S UTC') == sync_plan.sync_date + assert sync_date.strftime('%Y-%m-%d %H:%M:%S +0000') == sync_plan.sync_date @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) @@ -419,7 +413,7 @@ def test_positive_update_interval_custom_cron(module_org, interval): @pytest.mark.parametrize('sync_delta', **parametrized(sync_date_deltas)) @pytest.mark.tier1 -def test_positive_update_sync_date(module_org, sync_delta): +def test_positive_update_sync_date(module_org, sync_delta, target_sat): """Updated sync plan's sync date. :id: fad472c7-01b4-453b-ae33-0845c9e0dfd4 @@ -431,13 +425,13 @@ def test_positive_update_sync_date(module_org, sync_delta): :CaseImportance: Critical """ sync_date = datetime.now() + timedelta(seconds=sync_delta) - sync_plan = entities.SyncPlan( + sync_plan = target_sat.api.SyncPlan( enabled=False, organization=module_org, sync_date=datetime.now() + timedelta(days=10) ).create() sync_plan.sync_date = sync_date sync_plan.update(['sync_date']) sync_plan = sync_plan.read() - assert sync_date.strftime('%Y-%m-%d %H:%M:%S UTC') == sync_plan.sync_date + assert sync_date.strftime('%Y-%m-%d %H:%M:%S +0000') == sync_plan.sync_date @pytest.mark.parametrize('name', **parametrized(invalid_values_list())) @@ -481,7 +475,7 @@ def test_negative_update_interval(module_org, interval): @pytest.mark.tier2 -def test_positive_add_product(module_org): +def test_positive_add_product(module_org, target_sat): """Create a sync plan and add one product to it. :id: 036dea02-f73d-4fc1-9c41-5515b6659c79 @@ -493,8 +487,9 @@ def test_positive_add_product(module_org): :CaseImportance: Critical """ - sync_plan = entities.SyncPlan(enabled=False, organization=module_org).create() - product = entities.Product(organization=module_org).create() + sync_plan = target_sat.api.SyncPlan(enabled=False, organization=module_org).create() + product = target_sat.api.Product(organization=module_org).create() + target_sat.api.Repository(product=product).create() sync_plan.add_products(data={'product_ids': [product.id]}) sync_plan = sync_plan.read() assert len(sync_plan.product) == 1 @@ -502,7 +497,7 @@ def test_positive_add_product(module_org): @pytest.mark.tier2 -def test_positive_add_products(module_org): +def test_positive_add_products(module_org, target_sat): """Create a sync plan and add two products to it. :id: 2a80ecad-2245-46d8-bbc6-0b802e68d50c @@ -512,8 +507,9 @@ def test_positive_add_products(module_org): :CaseLevel: Integration """ - sync_plan = entities.SyncPlan(enabled=False, organization=module_org).create() - products = [entities.Product(organization=module_org).create() for _ in range(2)] + sync_plan = target_sat.api.SyncPlan(enabled=False, organization=module_org).create() + products = [target_sat.api.Product(organization=module_org).create() for _ in range(2)] + [target_sat.api.Repository(product=product).create() for product in products] sync_plan.add_products(data={'product_ids': [product.id for product in products]}) sync_plan = sync_plan.read() assert len(sync_plan.product) == 2 @@ -521,7 +517,7 @@ def test_positive_add_products(module_org): @pytest.mark.tier2 -def test_positive_remove_product(module_org): +def test_positive_remove_product(module_org, target_sat): """Create a sync plan with two products and then remove one product from it. @@ -534,8 +530,9 @@ def test_positive_remove_product(module_org): :BZ: 1199150 """ - sync_plan = entities.SyncPlan(enabled=False, organization=module_org).create() - products = [entities.Product(organization=module_org).create() for _ in range(2)] + sync_plan = target_sat.api.SyncPlan(enabled=False, organization=module_org).create() + products = [target_sat.api.Product(organization=module_org).create() for _ in range(2)] + [target_sat.api.Repository(product=product).create() for product in products] sync_plan.add_products(data={'product_ids': [product.id for product in products]}) assert len(sync_plan.read().product) == 2 sync_plan.remove_products(data={'product_ids': [products[0].id]}) @@ -546,7 +543,7 @@ def test_positive_remove_product(module_org): @pytest.mark.tier2 @pytest.mark.upgrade -def test_positive_remove_products(module_org): +def test_positive_remove_products(module_org, target_sat): """Create a sync plan with two products and then remove both products from it. @@ -557,8 +554,9 @@ def test_positive_remove_products(module_org): :CaseLevel: Integration """ - sync_plan = entities.SyncPlan(enabled=False, organization=module_org).create() - products = [entities.Product(organization=module_org).create() for _ in range(2)] + sync_plan = target_sat.api.SyncPlan(enabled=False, organization=module_org).create() + products = [target_sat.api.Product(organization=module_org).create() for _ in range(2)] + [target_sat.api.Repository(product=product).create() for product in products] sync_plan.add_products(data={'product_ids': [product.id for product in products]}) assert len(sync_plan.read().product) == 2 sync_plan.remove_products(data={'product_ids': [product.id for product in products]}) @@ -578,9 +576,10 @@ def test_positive_repeatedly_add_remove(module_org, request, target_sat): :BZ: 1199150 """ - sync_plan = entities.SyncPlan(organization=module_org).create() + sync_plan = target_sat.api.SyncPlan(organization=module_org).create() request.addfinalizer(lambda: target_sat.api_factory.disable_syncplan(sync_plan)) - product = entities.Product(organization=module_org).create() + product = target_sat.api.Product(organization=module_org).create() + target_sat.api.Repository(product=product).create() for _ in range(5): sync_plan.add_products(data={'product_ids': [product.id]}) assert len(sync_plan.read().product) == 1 @@ -602,11 +601,12 @@ def test_positive_add_remove_products_custom_cron(module_org, request, target_sa """ cron_expression = gen_choice(valid_cron_expressions()) - sync_plan = entities.SyncPlan( + sync_plan = target_sat.api.SyncPlan( organization=module_org, interval='custom cron', cron_expression=cron_expression ).create() request.addfinalizer(lambda: target_sat.api_factory.disable_syncplan(sync_plan)) - products = [entities.Product(organization=module_org).create() for _ in range(2)] + products = [target_sat.api.Product(organization=module_org).create() for _ in range(2)] + [target_sat.api.Repository(product=product).create() for product in products] sync_plan.add_products(data={'product_ids': [product.id for product in products]}) assert len(sync_plan.read().product) == 2 sync_plan.remove_products(data={'product_ids': [product.id for product in products]}) @@ -1020,7 +1020,7 @@ def test_positive_synchronize_custom_product_weekly_recurrence(module_org, reque @pytest.mark.tier2 -def test_positive_delete_one_product(module_org): +def test_positive_delete_one_product(module_org, target_sat): """Create a sync plan with one product and delete it. :id: e565c464-33e2-4bca-8eca-15d5a7d4b155 @@ -1030,8 +1030,9 @@ def test_positive_delete_one_product(module_org): :CaseLevel: Integration """ - sync_plan = entities.SyncPlan(organization=module_org).create() - product = entities.Product(organization=module_org).create() + sync_plan = target_sat.api.SyncPlan(organization=module_org).create() + product = target_sat.api.Product(organization=module_org).create() + target_sat.api.Repository(product=product).create() sync_plan.add_products(data={'product_ids': [product.id]}) sync_plan.delete() with pytest.raises(HTTPError): @@ -1039,7 +1040,7 @@ def test_positive_delete_one_product(module_org): @pytest.mark.tier2 -def test_positive_delete_products(module_org): +def test_positive_delete_products(module_org, target_sat): """Create a sync plan with two products and delete them. :id: f21bd57f-369e-4acd-a492-5532349a3804 @@ -1049,8 +1050,9 @@ def test_positive_delete_products(module_org): :CaseLevel: Integration """ - sync_plan = entities.SyncPlan(organization=module_org).create() - products = [entities.Product(organization=module_org).create() for _ in range(2)] + sync_plan = target_sat.api.SyncPlan(organization=module_org).create() + products = [target_sat.api.Product(organization=module_org).create() for _ in range(2)] + [target_sat.api.Repository(product=product).create() for product in products] sync_plan.add_products(data={'product_ids': [product.id for product in products]}) sync_plan.delete() with pytest.raises(HTTPError): diff --git a/tests/foreman/api/test_templatesync.py b/tests/foreman/api/test_templatesync.py index de0ba3b4175..061b8db1dd1 100644 --- a/tests/foreman/api/test_templatesync.py +++ b/tests/foreman/api/test_templatesync.py @@ -18,19 +18,20 @@ import json import time -import pytest -import requests from fauxfactory import gen_string from nailgun import entities +import pytest +import requests from robottelo.config import settings -from robottelo.constants import FOREMAN_TEMPLATE_IMPORT_API_URL -from robottelo.constants import FOREMAN_TEMPLATE_IMPORT_URL -from robottelo.constants import FOREMAN_TEMPLATE_ROOT_DIR -from robottelo.constants import FOREMAN_TEMPLATE_TEST_TEMPLATE +from robottelo.constants import ( + FOREMAN_TEMPLATE_IMPORT_API_URL, + FOREMAN_TEMPLATE_IMPORT_URL, + FOREMAN_TEMPLATE_ROOT_DIR, + FOREMAN_TEMPLATE_TEST_TEMPLATE, +) from robottelo.logging import logger - git = settings.git diff --git a/tests/foreman/api/test_user.py b/tests/foreman/api/test_user.py index bc2dfe83c14..cab7b49d653 100644 --- a/tests/foreman/api/test_user.py +++ b/tests/foreman/api/test_user.py @@ -23,25 +23,25 @@ import json import re -import pytest from nailgun import entities from nailgun.config import ServerConfig +import pytest from requests.exceptions import HTTPError from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE +from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE, DataFile from robottelo.utils import gen_ssh_keypairs -from robottelo.utils.datafactory import gen_string -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import invalid_emails_list -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import invalid_usernames_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_emails_list -from robottelo.utils.datafactory import valid_usernames_list +from robottelo.utils.datafactory import ( + gen_string, + generate_strings_list, + invalid_emails_list, + invalid_names_list, + invalid_usernames_list, + parametrized, + valid_data_list, + valid_emails_list, + valid_usernames_list, +) @pytest.fixture(scope='module') @@ -666,7 +666,7 @@ def create_ldap(self, ad_data, module_target_sat): ldap_user_passwd=ad_data['ldap_user_passwd'], authsource=module_target_sat.api.AuthSourceLDAP( onthefly_register=True, - account=ad_data['ldap_user_name'], + account=fr"{ad_data['workgroup']}\{ad_data['ldap_user_name']}", account_password=ad_data['ldap_user_passwd'], base_dn=ad_data['base_dn'], groups_base=ad_data['group_base_dn'], @@ -733,7 +733,7 @@ def test_positive_ad_basic_no_roles(self, create_ldap): @pytest.mark.tier3 @pytest.mark.upgrade - def test_positive_access_entities_from_ldap_org_admin(self, create_ldap): + def test_positive_access_entities_from_ldap_org_admin(self, create_ldap, module_target_sat): """LDAP User can access resources within its taxonomies if assigned role has permission for same taxonomies @@ -741,7 +741,7 @@ def test_positive_access_entities_from_ldap_org_admin(self, create_ldap): :steps: - 1. Create Org Admin and assign taxonomies to it + 1. Create Org Admin role and assign taxonomies to it 2. Create LDAP user with same taxonomies as role above 3. Assign Org Admin role to user above 4. Login with LDAP user and attempt to access resources @@ -751,6 +751,16 @@ def test_positive_access_entities_from_ldap_org_admin(self, create_ldap): :CaseLevel: System """ + # Workaround issue where, in an upgrade template, there is already + # some auth source present with this user. That auth source instance + # doesn't really run and attempting to login as that user + # leads to ISE 500 (which is itself a bug, the error should be handled, it is + # reported as BZ2240205). + for user in module_target_sat.api.User().search( + query={'search': f'login={create_ldap["ldap_user_name"]}'} + ): + user.delete() + role_name = gen_string('alpha') default_org_admin = entities.Role().search(query={'search': 'name="Organization admin"'}) org_admin = entities.Role(id=default_org_admin[0].id).clone( @@ -862,7 +872,7 @@ def test_positive_access_entities_from_ipa_org_admin(self, create_ldap): :steps: - 1. Create Org Admin and assign taxonomies to it + 1. Create Org Admin role and assign taxonomies to it 2. Create FreeIPA user with same taxonomies as role above 3. Assign Org Admin role to user above 4. Login with FreeIPA user and attempt to access resources diff --git a/tests/foreman/api/test_usergroup.py b/tests/foreman/api/test_usergroup.py index cb9e6477576..01dcef27010 100644 --- a/tests/foreman/api/test_usergroup.py +++ b/tests/foreman/api/test_usergroup.py @@ -21,15 +21,17 @@ """ from random import randint -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from requests.exceptions import HTTPError -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_usernames_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, + valid_usernames_list, +) class TestUserGroup: diff --git a/tests/foreman/api/test_webhook.py b/tests/foreman/api/test_webhook.py index c9a2bd5c60b..b806dbb24c0 100644 --- a/tests/foreman/api/test_webhook.py +++ b/tests/foreman/api/test_webhook.py @@ -18,15 +18,13 @@ """ import re -import pytest from nailgun import entities +import pytest from requests.exceptions import HTTPError -from wait_for import TimedOutError -from wait_for import wait_for +from wait_for import TimedOutError, wait_for from robottelo.config import settings -from robottelo.constants import WEBHOOK_EVENTS -from robottelo.constants import WEBHOOK_METHODS +from robottelo.constants import WEBHOOK_EVENTS, WEBHOOK_METHODS from robottelo.logging import logger from robottelo.utils.datafactory import parametrized diff --git a/tests/foreman/cli/test_acs.py b/tests/foreman/cli/test_acs.py index 941b9d066e4..39ba1701dee 100644 --- a/tests/foreman/cli/test_acs.py +++ b/tests/foreman/cli/test_acs.py @@ -16,12 +16,11 @@ :Upstream: No """ -import pytest from fauxfactory import gen_alphanumeric +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.constants.repos import PULP_FIXTURE_ROOT -from robottelo.constants.repos import PULP_SUBPATHS_COMBINED +from robottelo.constants.repos import PULP_FIXTURE_ROOT, PULP_SUBPATHS_COMBINED ACS_UPDATED = 'Alternate Content Source updated.' ACS_DELETED = 'Alternate Content Source deleted.' diff --git a/tests/foreman/cli/test_activationkey.py b/tests/foreman/cli/test_activationkey.py index 329a57c3558..126b4144d3c 100644 --- a/tests/foreman/cli/test_activationkey.py +++ b/tests/foreman/cli/test_activationkey.py @@ -16,40 +16,41 @@ :Upstream: No """ -import re from random import choice +import re -import pytest from broker import Broker -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string +from fauxfactory import gen_alphanumeric, gen_string +import pytest from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import add_role_permissions -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_activation_key -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_host_collection -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_role -from robottelo.cli.factory import make_user -from robottelo.cli.factory import setup_org_for_a_custom_repo -from robottelo.cli.factory import setup_org_for_a_rh_repo +from robottelo.cli.factory import ( + CLIFactoryError, + add_role_permissions, + make_activation_key, + make_content_view, + make_host_collection, + make_lifecycle_environment, + make_role, + make_user, + setup_org_for_a_custom_repo, + setup_org_for_a_rh_repo, +) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.repository import Repository from robottelo.cli.subscription import Subscription from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import PRDS, REPOS, REPOSET from robottelo.hosts import ContentHost -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) from robottelo.utils.issue_handlers import is_open diff --git a/tests/foreman/cli/test_ansible.py b/tests/foreman/cli/test_ansible.py index 922660d5d5c..a684cdbd440 100644 --- a/tests/foreman/cli/test_ansible.py +++ b/tests/foreman/cli/test_ansible.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings diff --git a/tests/foreman/cli/test_architecture.py b/tests/foreman/cli/test_architecture.py index b68ff28b618..ec212894310 100644 --- a/tests/foreman/cli/test_architecture.py +++ b/tests/foreman/cli/test_architecture.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_choice +import pytest from robottelo.cli.architecture import Architecture from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.factory import make_architecture -from robottelo.utils.datafactory import invalid_id_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_id_list, + invalid_values_list, + parametrized, + valid_data_list, +) class TestArchitecture: diff --git a/tests/foreman/cli/test_auth.py b/tests/foreman/cli/test_auth.py index ddcb174585d..51945a6445a 100644 --- a/tests/foreman/cli/test_auth.py +++ b/tests/foreman/cli/test_auth.py @@ -18,11 +18,10 @@ """ from time import sleep -import pytest from fauxfactory import gen_string +import pytest -from robottelo.cli.auth import Auth -from robottelo.cli.auth import AuthLogin +from robottelo.cli.auth import Auth, AuthLogin from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.factory import make_user from robottelo.cli.org import Org diff --git a/tests/foreman/cli/test_bootdisk.py b/tests/foreman/cli/test_bootdisk.py index 698ebbe1a75..7e8ad4fca9c 100644 --- a/tests/foreman/cli/test_bootdisk.py +++ b/tests/foreman/cli/test_bootdisk.py @@ -16,9 +16,8 @@ :Upstream: No """ +from fauxfactory import gen_mac, gen_string import pytest -from fauxfactory import gen_mac -from fauxfactory import gen_string from robottelo.config import settings from robottelo.constants import HTTPS_MEDIUM_URL diff --git a/tests/foreman/cli/test_capsule.py b/tests/foreman/cli/test_capsule.py index bc47379c515..8dee2e6a3dc 100644 --- a/tests/foreman/cli/test_capsule.py +++ b/tests/foreman/cli/test_capsule.py @@ -8,7 +8,7 @@ :CaseComponent: Capsule -:Team: Endeavour +:Team: Platform :TestType: Functional @@ -17,173 +17,12 @@ :Upstream: No """ import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string -from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.proxy import Proxy -from robottelo.host_helpers.cli_factory import CLIFactoryError -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.issue_handlers import is_open - pytestmark = [pytest.mark.run_in_one_thread] -def _make_proxy(request, target_sat, options=None): - """Create a Proxy and add the finalizer""" - proxy = target_sat.cli_factory.make_proxy(options) - - @request.addfinalizer - def _cleanup(): - target_sat.cli.Proxy.delete({'id': proxy['id']}) - - return proxy - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_negative_create_with_url(target_sat): - """Proxy creation with random URL - - :id: 9050b362-c710-43ba-9d77-7680b8f9ed8c - - :expectedresults: Proxy is not created - - :CaseLevel: Component - - """ - # Create a random proxy - with pytest.raises(CLIFactoryError, match='Could not create the proxy:'): - target_sat.cli_factory.make_proxy( - { - 'url': f"http://{gen_string('alpha', 6)}:{gen_string('numeric', 4)}", - } - ) - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -@pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_create_with_name(request, target_sat, name): - """Proxy creation with the home proxy - - :id: 7decd7a3-2d35-43ff-9a20-de44e83c7389 - - :expectedresults: Proxy is created - - :CaseLevel: Component - - :Parametrized: Yes - - :BZ: 1398695, 2084661 - """ - if is_open('BZ:2084661') and 'html' in request.node.name: - pytest.skip() - proxy = _make_proxy(request, target_sat, options={'name': name}) - assert proxy['name'] == name - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -@pytest.mark.parametrize('name', **parametrized(valid_data_list())) -def test_positive_delete_by_id(request, name, target_sat): - """Proxy deletion with the home proxy - - :id: 1b6973b1-259d-4866-b36f-c2d5fb154035 - - :expectedresults: Proxy is deleted - - :CaseLevel: Component - - :Parametrized: Yes - - :BZ: 1398695, 2084661 - """ - if is_open('BZ:2084661') and 'html' in request.node.name: - pytest.skip() - proxy = target_sat.cli_factory.make_proxy({'name': name}) - Proxy.delete({'id': proxy['id']}) - with pytest.raises(CLIReturnCodeError): - Proxy.info({'id': proxy['id']}) - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier1 -def test_positive_update_name(request, target_sat): - """Proxy name update with the home proxy - - :id: 1a02a06b-e9ab-4b9b-bcb0-ac7060188316 - - :expectedresults: Proxy has the name updated - - :CaseLevel: Component - - :BZ: 1398695, 2084661 - """ - proxy = _make_proxy(request, target_sat, options={'name': gen_alphanumeric()}) - valid_data = valid_data_list() - if is_open('BZ:2084661') and 'html' in valid_data: - del valid_data['html'] - for new_name in valid_data.values(): - newport = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, newport) as url: - Proxy.update({'id': proxy['id'], 'name': new_name, 'url': url}) - proxy = Proxy.info({'id': proxy['id']}) - assert proxy['name'] == new_name - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier2 -def test_positive_refresh_features_by_id(request, target_sat): - """Refresh smart proxy features, search for proxy by id - - :id: d3db63ce-b877-40eb-a863-294c12489ddd - - :expectedresults: Proxy features are refreshed - - :CaseLevel: Integration - - :CaseImportance: High - - """ - # Since we want to run multiple commands against our fake capsule, we - # need the tunnel kept open in order not to allow different concurrent - # test to claim it. Thus we want to manage the tunnel manually. - - # get an available port for our fake capsule - port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, port) as url: - proxy = _make_proxy(request, target_sat, options={'url': url}) - Proxy.refresh_features({'id': proxy['id']}) - - -@pytest.mark.skip_if_not_set('fake_capsules') -@pytest.mark.tier2 -def test_positive_refresh_features_by_name(request, target_sat): - """Refresh smart proxy features, search for proxy by name - - :id: 2ddd0097-8f65-430e-963d-a3b5dcffe86b - - :expectedresults: Proxy features are refreshed - - :CaseLevel: Integration - - :CaseImportance: High - - """ - # Since we want to run multiple commands against our fake capsule, we - # need the tunnel kept open in order not to allow different concurrent - # test to claim it. Thus we want to manage the tunnel manually. - - # get an available port for our fake capsule - port = target_sat.available_capsule_port - with target_sat.default_url_on_new_port(9090, port) as url: - proxy = _make_proxy(request, target_sat, options={'url': url}) - Proxy.refresh_features({'id': proxy['name']}) - - @pytest.mark.skip_if_not_set('fake_capsules') @pytest.mark.tier1 def test_positive_import_puppet_classes(session_puppet_enabled_sat, puppet_proxy_port_range): @@ -194,7 +33,6 @@ def test_positive_import_puppet_classes(session_puppet_enabled_sat, puppet_proxy :expectedresults: Puppet classes are imported from proxy :CaseLevel: Component - """ with session_puppet_enabled_sat as puppet_sat: port = puppet_sat.available_capsule_port @@ -205,188 +43,26 @@ def test_positive_import_puppet_classes(session_puppet_enabled_sat, puppet_proxy @pytest.mark.stubbed -def test_positive_provision(): - """User can provision through a capsule - - :id: 1b91e6ed-56bb-4a21-9b69-8b41242458c5 - - :Setup: Some valid, functional compute resource (perhaps one variation - of this case for each supported compute resource type). Also, - functioning capsule with proxy is required. - - :Steps: - - 1. Attempt to route provisioning content through capsule that is - using a proxy - 2. Attempt to provision instance - - :expectedresults: Instance can be provisioned, with content coming - through proxy-enabled capsule. - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_register(): - """User can register system through proxy-enabled capsule - - :id: dc544ec8-0320-4897-a6ca-ce9ebad27975 - - :Steps: attempt to register a system trhough a proxy-enabled capsule - - :expectedresults: system is successfully registered - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_unregister(): - """User can unregister system through proxy-enabled capsule - - :id: 9b7714da-74be-4c0a-9209-9d15c2c98eaa - - :Steps: attempt to unregister a system through a proxy-enabled capsule - - :expectedresults: system is successfully unregistered - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_subscribe(): - """User can subscribe system to content through proxy-enabled - capsule - - :id: 091bba73-bc78-4b8c-ac27-5c10e9838cfb - - :Setup: Content source types configured/synced for [RH, Custom, Puppet, - Docker] etc. - - :Steps: attempt to subscribe a system to a content type variation, via - a proxy-enabled capsule - - :expectedresults: system is successfully subscribed to each content - type - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_consume_content(): - """User can consume content on system, from a content source, - through proxy-enabled capsule - - :id: a3fb9879-7799-4743-99a8-963701e687c1 - - :Setup: Content source types configured/synced for [RH, Custom, Puppet, - Docker] etc. - - :Steps: - - 1. attempt to subscribe a system to a content type variation, via a - proxy-enabled capsule - 2. Attempt to install content RPMs via - proxy-enabled capsule - - :expectedresults: system successfully consume content - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_unsubscribe(): - """User can unsubscribe system from content through - proxy-enabled capsule - - :id: 0d34713d-3d60-4e5a-ada6-9a24aa865cb4 - - :Setup: Content source types configured/synced for [RH, Custom, Puppet] - etc. - - :Steps: - - 1. attempt to subscribe a system to a content type variation, via a - proxy-enabled capsule - 2. attempt to unsubscribe a system from said content type(s) via a - proxy-enabled capsule - - :expectedresults: system is successfully unsubscribed from each content - type - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_reregister_with_capsule_cert(): - """system can register via capsule using cert provided by - the capsule itself. - - :id: 785b94ea-ffbf-4c18-8160-f705e3d7cbe6 - - :Setup: functional capsule and certs rpm installed on target client. - - :Steps: - - 1. Attempt to register from parent satellite; unregister and remove - cert rpm - 2. Attempt to reregister using same credentials and certs from a - functional capsule. - - :expectedresults: Registration works , and certs RPM installed from - capsule. - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_ssl_capsule(): - """Assure SSL functionality for capsules - - :id: 4d19bee6-15d4-4fd5-b3de-9144608cdba7 - - :Setup: A capsule installed with SSL enabled. - - :Steps: Execute basic steps from above (register, subscribe, consume, - unsubscribe, unregister) while connected to a capsule that is - SSL-enabled - - :expectedresults: No failures executing said test scenarios against - SSL, baseline functionality identical to non-SSL - - :CaseAutomation: NotAutomated - """ - - -@pytest.mark.stubbed -def test_positive_enable_bmc(): - """Enable BMC feature on smart-proxy +@pytest.mark.e2e +@pytest.mark.upgrade +def test_positive_capsule_content(): + """Registered and provisioned hosts can consume content from capsule - :id: 9cc4db2f-3bec-4e51-89a2-18a0a6167012 + :id: 7e5493de-b27b-4adc-ba18-4dc2e94e7305 - :Setup: A capsule installed with SSL enabled. + :Setup: Capsule with some content synced :Steps: - 1. Enable BMC feature on proxy by running installer with: - ``katello-installer --foreman-proxy-bmc 'true'`` - 2. Please make sure to check default values to other BMC options. - Should be like below: ``--foreman-proxy-bmc-default-provider - BMC default provider. (default: "ipmitool")`` - ``--foreman-proxy-bmc-listen-on BMC proxy to listen on https, - http, or both (default: "https")`` - 3. Check if BMC plugin is enabled with: ``#cat - /etc/foreman-proxy/settings.d/bmc.yml | grep enabled`` - 4. Restart foreman-proxy service + 1. Register a host to the capsule + 2. Sync content from capsule to the host + 3. Unregister host from the capsule + 4. Provision host via capsule + 5. Provisioned host syncs content from capsule - :expectedresults: Katello installer should show the options to enable - BMC + :expectedresults: Hosts can be successfully registered to the capsule, + consume content and unregister afterwards. Hosts can be successfully + provisioned via capsule and consume content as well. :CaseAutomation: NotAutomated """ diff --git a/tests/foreman/cli/test_capsule_installer.py b/tests/foreman/cli/test_capsule_installer.py deleted file mode 100644 index 7d619ece0c2..00000000000 --- a/tests/foreman/cli/test_capsule_installer.py +++ /dev/null @@ -1,151 +0,0 @@ -"""Test for capsule installer CLI - -:Requirement: Capsule Installer - -:CaseAutomation: Automated - -:CaseLevel: System - -:CaseComponent: Capsule - -:Team: Endeavour - -:TestType: Functional - -:CaseImportance: High - -:Upstream: No -""" -import pytest - - -@pytest.mark.stubbed -def test_positive_basic(): - """perform a basic install of capsule. - - :id: 47445685-5924-4980-89d0-bbb2fb608f4d - - :Steps: - - 1. Assure your target capsule has ONLY the Capsule repo enabled. In - other words, the Satellite repo itself is not enabled by - default. - 2. attempt to perform a basic, functional install the capsule using - `capsule-installer`. - - :expectedresults: product is installed - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_positive_option_qpid_router(): - """assure the --qpid-router flag can be used in - capsule-installer to enable katello-agent functionality via - remote clients - - :id: d040a72d-72b2-41cf-b14e-a8e37e80200d - - :Steps: Install capsule-installer with the '--qpid-router=true` flag - - :expectedresults: Capsule installs correctly and qpid functionality is - enabled. - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_positive_option_reverse_proxy(): - """assure the --reverse-proxy flag can be used in - capsule-installer to enable katello-agent functionality via - remote clients - - :id: 756fd76a-0183-4637-93c8-fe7c375be751 - - :Steps: Install using the '--reverse-proxy=true' flag - - :expectedresults: Capsule installs correctly and functionality is - enabled. - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_negative_invalid_parameters(): - """invalid (non-boolean) parameters cannot be passed to flag - - :id: f4366c87-e436-42b4-ada4-55f0e66a481e - - :Steps: attempt to provide a variety of invalid parameters to installer - (strings, numerics, whitespace, etc.) - - :expectedresults: user is told that such parameters are invalid and - install aborts. - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_negative_option_parent_reverse_proxy_port(): - """invalid (non-integer) parameters cannot be passed to flag - - :id: a1af16d3-84da-4e94-818e-90bc82cc5698 - - :Setup: na - - :Steps: attempt to provide a variety of invalid parameters to - --parent-reverse-proxy-port flag (strings, numerics, whitespace, - etc.) - - :expectedresults: user told parameters are invalid; install aborts. - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_positive_option_parent_reverse_proxy(): - """valid parameters can be passed to --parent-reverse-proxy - (true) - - :id: a905f4ca-a729-4efb-84fc-43923737f75b - - :Setup: note that this requires an accompanying, valid port value - - :Steps: Attempt to provide a value of "true" to --parent-reverse-proxy - - :expectedresults: Install commences/completes with proxy installed - correctly. - - :CaseAutomation: NotAutomated - - """ - - -@pytest.mark.stubbed -def test_positive_option_parent_reverse_proxy_port(): - """valid parameters can be passed to - --parent-reverse-proxy-port (integer) - - :id: 32238045-53e2-4ed4-ac86-57917e7aedcd - - :Setup: note that this requires an accompanying, valid host for proxy - parameter - - :Steps: Attempt to provide a valid proxy port # to flag - - :expectedresults: Install commences and completes with proxy installed - correctly. - - :CaseAutomation: NotAutomated - - """ diff --git a/tests/foreman/cli/test_computeresource_azurerm.py b/tests/foreman/cli/test_computeresource_azurerm.py index a25ad7761b8..998175e48ed 100644 --- a/tests/foreman/cli/test_computeresource_azurerm.py +++ b/tests/foreman/cli/test_computeresource_azurerm.py @@ -16,18 +16,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.computeresource import ComputeResource from robottelo.cli.host import Host from robottelo.config import settings -from robottelo.constants import AZURERM_FILE_URI -from robottelo.constants import AZURERM_PLATFORM_DEFAULT -from robottelo.constants import AZURERM_PREMIUM_OS_Disk -from robottelo.constants import AZURERM_RHEL7_FT_CUSTOM_IMG_URN -from robottelo.constants import AZURERM_RHEL7_UD_IMG_URN -from robottelo.constants import AZURERM_VM_SIZE_DEFAULT +from robottelo.constants import ( + AZURERM_FILE_URI, + AZURERM_PLATFORM_DEFAULT, + AZURERM_RHEL7_FT_CUSTOM_IMG_URN, + AZURERM_RHEL7_UD_IMG_URN, + AZURERM_VM_SIZE_DEFAULT, + AZURERM_PREMIUM_OS_Disk, +) @pytest.fixture(scope='class') diff --git a/tests/foreman/cli/test_computeresource_ec2.py b/tests/foreman/cli/test_computeresource_ec2.py index 4bbbb5cd77e..e0f3d8cc4c3 100644 --- a/tests/foreman/cli/test_computeresource_ec2.py +++ b/tests/foreman/cli/test_computeresource_ec2.py @@ -13,16 +13,13 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_org +from robottelo.cli.factory import make_compute_resource, make_location, make_org from robottelo.cli.org import Org from robottelo.config import settings -from robottelo.constants import EC2_REGION_CA_CENTRAL_1 -from robottelo.constants import FOREMAN_PROVIDERS +from robottelo.constants import EC2_REGION_CA_CENTRAL_1, FOREMAN_PROVIDERS @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_computeresource_libvirt.py b/tests/foreman/cli/test_computeresource_libvirt.py index 7147844bfb9..e5e1997fa3b 100644 --- a/tests/foreman/cli/test_computeresource_libvirt.py +++ b/tests/foreman/cli/test_computeresource_libvirt.py @@ -35,19 +35,19 @@ """ import random +from fauxfactory import gen_string, gen_url import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url +from wait_for import wait_for from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.computeresource import ComputeResource -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.factory import make_location +from robottelo.cli.factory import make_compute_resource, make_location from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import LIBVIRT_RESOURCE_URL +from robottelo.constants import FOREMAN_PROVIDERS, LIBVIRT_RESOURCE_URL from robottelo.utils.datafactory import parametrized +LIBVIRT_URL = LIBVIRT_RESOURCE_URL % settings.libvirt.libvirt_hostname + def valid_name_desc_data(): """Random data for valid name and description""" @@ -422,3 +422,84 @@ def test_positive_update_console_password(libvirt_url, set_console_password): cr_name = gen_string('utf8') ComputeResource.create({'name': cr_name, 'provider': 'Libvirt', 'url': gen_url()}) ComputeResource.update({'name': cr_name, 'set-console-password': set_console_password}) + + +@pytest.mark.e2e +@pytest.mark.on_premises_provisioning +@pytest.mark.tier3 +@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) +def test_positive_provision_end_to_end( + request, + setting_update, + module_libvirt_provisioning_sat, + module_sca_manifest_org, + module_location, + provisioning_hostgroup, +): + """Provision a host on Libvirt compute resource with the help of hostgroup. + + :id: b003faa9-2810-4176-94d2-ea84bed248ec + + :setup: Hostgroup and provisioning setup like domain, subnet etc. + + :steps: + 1. Create a Libvirt compute resource. + 2. Create a host on Libvirt compute resource using the Hostgroup + 3. Use compute-attributes parameter to specify key-value parameters + regarding the virtual machine. + 4. Provision the host. + + :expectedresults: Host should be provisioned with hostgroup + + :parametrized: yes + """ + sat = module_libvirt_provisioning_sat.sat + cr_name = gen_string('alpha') + hostname = gen_string('alpha').lower() + libvirt_cr = sat.cli.ComputeResource.create( + { + 'name': cr_name, + 'provider': FOREMAN_PROVIDERS['libvirt'], + 'url': LIBVIRT_URL, + 'organizations': module_sca_manifest_org.name, + 'locations': module_location.name, + } + ) + assert libvirt_cr['name'] == cr_name + host = sat.cli.Host.create( + { + 'name': hostname, + 'location': module_location.name, + 'organization': module_sca_manifest_org.name, + 'hostgroup': provisioning_hostgroup.name, + 'compute-resource-id': libvirt_cr['id'], + 'ip': None, + 'mac': None, + 'compute-attributes': 'cpus=1, memory=6442450944, cpu_mode=default, start=1', + 'interface': f'compute_type=bridge,compute_bridge=br-{settings.provisioning.vlan_id}', + 'volume': 'capacity=10', + 'provision-method': 'build', + } + ) + # teardown + request.addfinalizer(lambda: sat.cli.Host.delete({'id': host['id']})) + + # checks + hostname = f'{hostname}.{module_libvirt_provisioning_sat.domain.name}' + assert hostname == host['name'] + host_info = sat.cli.Host.info({'name': hostname}) + # Check on Libvirt, if VM exists + result = sat.execute( + f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + ) + assert hostname in result.stdout + + wait_for( + lambda: sat.cli.Host.info({'name': hostname})['status']['build-status'] + != 'Pending installation', + timeout=1800, + delay=30, + ) + host_info = sat.cli.Host.info({'id': host['id']}) + assert host_info['status']['build-status'] == 'Installed' diff --git a/tests/foreman/cli/test_computeresource_osp.py b/tests/foreman/cli/test_computeresource_osp.py index 170a7410ea9..c9018995dc2 100644 --- a/tests/foreman/cli/test_computeresource_osp.py +++ b/tests/foreman/cli/test_computeresource_osp.py @@ -15,9 +15,9 @@ :Upstream: No """ -import pytest from box import Box from fauxfactory import gen_string +import pytest from robottelo.cli.factory import CLIReturnCodeError from robottelo.config import settings diff --git a/tests/foreman/cli/test_computeresource_rhev.py b/tests/foreman/cli/test_computeresource_rhev.py index 35c60e0860e..12e2fe9b345 100644 --- a/tests/foreman/cli/test_computeresource_rhev.py +++ b/tests/foreman/cli/test_computeresource_rhev.py @@ -15,15 +15,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from wait_for import wait_for from wrapanapi import RHEVMSystem from robottelo.cli.computeresource import ComputeResource -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import CLIReturnCodeError -from robottelo.cli.factory import make_compute_resource +from robottelo.cli.factory import ( + CLIFactoryError, + CLIReturnCodeError, + make_compute_resource, +) from robottelo.cli.host import Host from robottelo.config import settings diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index f093ed84928..ed1164f063c 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -13,8 +13,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.factory import make_compute_resource from robottelo.cli.org import Org diff --git a/tests/foreman/cli/test_container_management.py b/tests/foreman/cli/test_container_management.py index 3574b764165..70de242f8ac 100644 --- a/tests/foreman/cli/test_container_management.py +++ b/tests/foreman/cli/test_container_management.py @@ -12,21 +12,25 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from wait_for import wait_for -from robottelo.cli.factory import ContentView -from robottelo.cli.factory import LifecycleEnvironment -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_product_wait -from robottelo.cli.factory import make_repository -from robottelo.cli.factory import Repository +from robottelo.cli.factory import ( + ContentView, + LifecycleEnvironment, + Repository, + make_content_view, + make_lifecycle_environment, + make_product_wait, + make_repository, +) from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import REPO_TYPE +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + REPO_TYPE, +) from robottelo.logging import logger @@ -322,3 +326,79 @@ def test_positive_container_admin_end_to_end_pull( # 9. Pull in docker image result = container_contenthost.execute(docker_pull_command) assert result.status == 0 + + def test_negative_pull_content_with_longer_name( + self, target_sat, container_contenthost, module_org + ): + """Verify that long name CV publishes when CV & docker repo both have a larger name. + + :id: e0ac0be4-f5ff-4a88-bb29-33aa2d874f46 + + :steps: + + 1. Create Product, docker repo, CV and LCE with a long name + 2. Sync the repos + 3. Add repository to CV, Publish, and then Promote CV to LCE + 4. Pull in docker image + + :expectedresults: + + 1. Long Product, repository, CV and LCE should create successfully + 2. Sync repository successfully + 3. Publish & Promote should success + 4. Can pull in docker images + + :BZ: 2127470 + + :customerscenario: true + """ + pattern_postfix = gen_string('alpha', 10).lower() + + product_name = f'containers-{pattern_postfix}' + repo_name = f'repo-{pattern_postfix}' + lce_name = f'lce-{pattern_postfix}' + cv_name = f'cv-{pattern_postfix}' + + # 1. Create Product, docker repo, CV and LCE with a long name + product = target_sat.cli_factory.make_product_wait( + {'name': product_name, 'organization-id': module_org.id} + ) + + repo = _repo(product['id'], name=repo_name, upstream_name=CONTAINER_UPSTREAM_NAME) + + # 2. Sync the repos + target_sat.cli.Repository.synchronize({'id': repo['id']}) + + lce = target_sat.cli_factory.make_lifecycle_environment( + {'name': lce_name, 'organization-id': module_org.id} + ) + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'composite': False, 'organization-id': module_org.id} + ) + + # 3. Add repository to CV, Publish, and then Promote CV to LCE + target_sat.cli.ContentView.add_repository({'id': cv['id'], 'repository-id': repo['id']}) + + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) + target_sat.cli.ContentView.version_promote( + {'id': cv['versions'][0]['id'], 'to-lifecycle-environment-id': lce['id']} + ) + + podman_pull_command = ( + f"podman pull --tls-verify=false {target_sat.hostname}/{module_org.label.lower()}" + f"-{lce['label'].lower()}-{cv['label'].lower()}-{product['label'].lower()}-{repo_name}" + ) + + # 4. Pull in docker image + assert ( + container_contenthost.execute( + f'podman login -u {settings.server.admin_username}' + f' -p {settings.server.admin_password} {target_sat.hostname}' + ).status + == 0 + ) + + assert container_contenthost.execute(podman_pull_command).status == 0 + + assert container_contenthost.execute(f'podman logout {target_sat.hostname}').status == 0 diff --git a/tests/foreman/cli/test_contentaccess.py b/tests/foreman/cli/test_contentaccess.py index 55b1a933328..fb8aaca5228 100644 --- a/tests/foreman/cli/test_contentaccess.py +++ b/tests/foreman/cli/test_contentaccess.py @@ -16,16 +16,18 @@ """ import time -import pytest from nailgun import entities +import pytest from robottelo.cli.host import Host from robottelo.cli.package import Package from robottelo.config import settings -from robottelo.constants import REAL_0_ERRATA_ID -from robottelo.constants import REAL_RHEL7_0_2_PACKAGE_FILENAME -from robottelo.constants import REAL_RHEL7_0_2_PACKAGE_NAME -from robottelo.constants import REPOS +from robottelo.constants import ( + REAL_0_ERRATA_ID, + REAL_RHEL7_0_2_PACKAGE_FILENAME, + REAL_RHEL7_0_2_PACKAGE_NAME, + REPOS, +) pytestmark = [ pytest.mark.skipif( diff --git a/tests/foreman/cli/test_contentcredentials.py b/tests/foreman/cli/test_contentcredentials.py index 935d41e3e90..269170ffdc1 100644 --- a/tests/foreman/cli/test_contentcredentials.py +++ b/tests/foreman/cli/test_contentcredentials.py @@ -20,18 +20,17 @@ """ from tempfile import mkstemp +from fauxfactory import gen_alphanumeric, gen_choice, gen_integer, gen_string import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_string from robottelo.cli.base import CLIReturnCodeError from robottelo.constants import DataFile from robottelo.host_helpers.cli_factory import CLIFactoryError -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) VALID_GPG_KEY_FILE_PATH = DataFile.VALID_GPG_KEY_FILE diff --git a/tests/foreman/cli/test_contentview.py b/tests/foreman/cli/test_contentview.py index 1b71e7e42cb..4effe29ecf4 100644 --- a/tests/foreman/cli/test_contentview.py +++ b/tests/foreman/cli/test_contentview.py @@ -18,10 +18,9 @@ """ import random -import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string +from fauxfactory import gen_alphanumeric, gen_string from nailgun import entities +import pytest from wrapanapi.entities.vm import VmState from robottelo import constants @@ -42,13 +41,17 @@ from robottelo.cli.role import Role from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE_NAME -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_names_list +from robottelo.constants import ( + FAKE_2_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE_NAME, + DataFile, +) +from robottelo.utils.datafactory import ( + generate_strings_list, + invalid_names_list, + parametrized, + valid_names_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_contentviewfilter.py b/tests/foreman/cli/test_contentviewfilter.py index 40326ad9ba6..c19091df054 100644 --- a/tests/foreman/cli/test_contentviewfilter.py +++ b/tests/foreman/cli/test_contentviewfilter.py @@ -18,19 +18,20 @@ """ import random -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_repository +from robottelo.cli.factory import make_content_view, make_repository from robottelo.cli.repository import Repository from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_discoveryrule.py b/tests/foreman/cli/test_discoveryrule.py index e51468fbbf5..efdc081d79f 100644 --- a/tests/foreman/cli/test_discoveryrule.py +++ b/tests/foreman/cli/test_discoveryrule.py @@ -16,26 +16,24 @@ :Upstream: No """ -import random from functools import partial +import random -import pytest from box import Box -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_string -from nailgun.entities import Role as RoleEntity -from nailgun.entities import User as UserEntity +from fauxfactory import gen_choice, gen_integer, gen_string +from nailgun.entities import Role as RoleEntity, User as UserEntity +import pytest from requests import HTTPError from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_discoveryrule +from robottelo.cli.factory import CLIFactoryError, make_discoveryrule from robottelo.logging import logger -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, + valid_data_list, +) @filtered_datapoint diff --git a/tests/foreman/cli/test_docker.py b/tests/foreman/cli/test_docker.py index 91ac3446a17..9e7ca7b5ed4 100644 --- a/tests/foreman/cli/test_docker.py +++ b/tests/foreman/cli/test_docker.py @@ -12,34 +12,38 @@ :Upstream: No """ -from random import choice -from random import randint +from random import choice, randint +from fauxfactory import gen_string, gen_url import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView from robottelo.cli.docker import Docker -from robottelo.cli.factory import make_activation_key -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_product_wait -from robottelo.cli.factory import make_repository +from robottelo.cli.factory import ( + make_activation_key, + make_content_view, + make_lifecycle_environment, + make_product_wait, + make_repository, +) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_RH_REGISTRY_UPSTREAM_NAME -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import REPO_TYPE -from robottelo.utils.datafactory import invalid_docker_upstream_names -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_docker_repository_names -from robottelo.utils.datafactory import valid_docker_upstream_names +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_RH_REGISTRY_UPSTREAM_NAME, + CONTAINER_UPSTREAM_NAME, + REPO_TYPE, +) +from robottelo.utils.datafactory import ( + invalid_docker_upstream_names, + parametrized, + valid_docker_repository_names, + valid_docker_upstream_names, +) def _repo(product_id, name=None, upstream_name=None, url=None): diff --git a/tests/foreman/cli/test_domain.py b/tests/foreman/cli/test_domain.py index 1da37871243..b0d6aeca207 100644 --- a/tests/foreman/cli/test_domain.py +++ b/tests/foreman/cli/test_domain.py @@ -16,18 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.domain import Domain -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_domain -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_org -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_id_list -from robottelo.utils.datafactory import parametrized +from robottelo.cli.factory import CLIFactoryError, make_domain, make_location, make_org +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_id_list, + parametrized, +) @filtered_datapoint diff --git a/tests/foreman/cli/test_environment.py b/tests/foreman/cli/test_environment.py index d033c952711..ae6e0d7e947 100644 --- a/tests/foreman/cli/test_environment.py +++ b/tests/foreman/cli/test_environment.py @@ -18,15 +18,16 @@ """ from random import choice +from fauxfactory import gen_alphanumeric, gen_string import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string from robottelo.cli.base import CLIReturnCodeError from robottelo.config import settings -from robottelo.utils.datafactory import invalid_id_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import ( + invalid_id_list, + invalid_values_list, + parametrized, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/cli/test_errata.py b/tests/foreman/cli/test_errata.py index 7d8577c3816..988a578ab12 100644 --- a/tests/foreman/cli/test_errata.py +++ b/tests/foreman/cli/test_errata.py @@ -16,26 +16,25 @@ :Upstream: No """ -from datetime import date -from datetime import datetime -from datetime import timedelta +from datetime import date, datetime, timedelta from operator import itemgetter -import pytest from broker import Broker from nailgun import entities +import pytest from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.contentview import ContentView -from robottelo.cli.contentview import ContentViewFilter +from robottelo.cli.contentview import ContentView, ContentViewFilter from robottelo.cli.erratum import Erratum -from robottelo.cli.factory import make_content_view_filter -from robottelo.cli.factory import make_content_view_filter_rule -from robottelo.cli.factory import make_host_collection -from robottelo.cli.factory import make_repository -from robottelo.cli.factory import setup_org_for_a_custom_repo -from robottelo.cli.factory import setup_org_for_a_rh_repo +from robottelo.cli.factory import ( + make_content_view_filter, + make_content_view_filter_rule, + make_host_collection, + make_repository, + setup_org_for_a_custom_repo, + setup_org_for_a_rh_repo, +) from robottelo.cli.host import Host from robottelo.cli.hostcollection import HostCollection from robottelo.cli.job_invocation import JobInvocation @@ -43,21 +42,23 @@ from robottelo.cli.repository import Repository from robottelo.cli.repository_set import RepositorySet from robottelo.config import settings -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_4_CUSTOM_PACKAGE -from robottelo.constants import FAKE_4_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_5_CUSTOM_PACKAGE -from robottelo.constants import PRDS -from robottelo.constants import REAL_0_ERRATA_ID -from robottelo.constants import REAL_4_ERRATA_CVES -from robottelo.constants import REAL_4_ERRATA_ID -from robottelo.constants import REAL_RHEL7_0_2_PACKAGE_NAME -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import ( + DEFAULT_ARCHITECTURE, + DEFAULT_SUBSCRIPTION_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE_NAME, + FAKE_4_CUSTOM_PACKAGE, + FAKE_4_CUSTOM_PACKAGE_NAME, + FAKE_5_CUSTOM_PACKAGE, + PRDS, + REAL_0_ERRATA_ID, + REAL_4_ERRATA_CVES, + REAL_4_ERRATA_ID, + REAL_RHEL7_0_2_PACKAGE_NAME, + REPOS, + REPOSET, +) from robottelo.hosts import ContentHost PER_PAGE = 10 diff --git a/tests/foreman/cli/test_fact.py b/tests/foreman/cli/test_fact.py index 8a484521ea0..96fee50c126 100644 --- a/tests/foreman/cli/test_fact.py +++ b/tests/foreman/cli/test_fact.py @@ -16,12 +16,11 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.fact import Fact - pytestmark = [pytest.mark.tier1] diff --git a/tests/foreman/cli/test_filter.py b/tests/foreman/cli/test_filter.py index ee873349d73..da5eccb86c2 100644 --- a/tests/foreman/cli/test_filter.py +++ b/tests/foreman/cli/test_filter.py @@ -19,10 +19,7 @@ import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_filter -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_role +from robottelo.cli.factory import make_filter, make_location, make_org, make_role from robottelo.cli.filter import Filter from robottelo.cli.role import Role diff --git a/tests/foreman/cli/test_globalparam.py b/tests/foreman/cli/test_globalparam.py index 4f42b83579c..4fb6b1949cb 100644 --- a/tests/foreman/cli/test_globalparam.py +++ b/tests/foreman/cli/test_globalparam.py @@ -18,12 +18,11 @@ """ from functools import partial -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.globalparam import GlobalParameter - pytestmark = [pytest.mark.tier1] diff --git a/tests/foreman/cli/test_hammer.py b/tests/foreman/cli/test_hammer.py index 966c53b2117..8a424bb62ee 100644 --- a/tests/foreman/cli/test_hammer.py +++ b/tests/foreman/cli/test_hammer.py @@ -27,10 +27,9 @@ from robottelo.constants import DataFile from robottelo.logging import logger - HAMMER_COMMANDS = json.loads(DataFile.HAMMER_COMMANDS_JSON.read_text()) -pytestmark = [pytest.mark.tier1, pytest.mark.upgrade] +pytestmark = [pytest.mark.tier1] def fetch_command_info(command): @@ -127,6 +126,7 @@ def test_positive_all_options(target_sat): pytest.fail(format_commands_diff(differences)) +@pytest.mark.upgrade def test_positive_disable_hammer_defaults(request, function_product, target_sat): """Verify hammer disable defaults command. @@ -166,6 +166,7 @@ def _finalize(): assert str(function_product.organization.id) not in result.stdout +@pytest.mark.upgrade def test_positive_check_debug_log_levels(target_sat): """Enabling debug log level in candlepin via hammer logging @@ -193,6 +194,7 @@ def test_positive_check_debug_log_levels(target_sat): @pytest.mark.e2e +@pytest.mark.upgrade def test_positive_hammer_shell(target_sat): """Verify that hammer shell runs a command when input is provided via interactive/bash diff --git a/tests/foreman/cli/test_host.py b/tests/foreman/cli/test_host.py index d94a880f4fa..538c8ebe27a 100644 --- a/tests/foreman/cli/test_host.py +++ b/tests/foreman/cli/test_host.py @@ -16,49 +16,48 @@ :Upstream: No """ -import re from random import choice +import re +from fauxfactory import gen_choice, gen_integer, gen_ipaddr, gen_mac, gen_string import pytest +from wait_for import TimedOutError, wait_for import yaml -from fauxfactory import gen_choice -from fauxfactory import gen_integer -from fauxfactory import gen_ipaddr -from fauxfactory import gen_mac -from fauxfactory import gen_string -from wait_for import TimedOutError -from wait_for import wait_for from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import add_role_permissions -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_fake_host -from robottelo.cli.factory import make_host -from robottelo.cli.factory import setup_org_for_a_rh_repo -from robottelo.cli.host import Host -from robottelo.cli.host import HostInterface -from robottelo.cli.host import HostTraces +from robottelo.cli.factory import ( + CLIFactoryError, + add_role_permissions, + make_fake_host, + make_host, + setup_org_for_a_rh_repo, +) +from robottelo.cli.host import Host, HostInterface, HostTraces from robottelo.cli.job_invocation import JobInvocation from robottelo.cli.package import Package from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_7_CUSTOM_PACKAGE -from robottelo.constants import FAKE_8_CUSTOM_PACKAGE -from robottelo.constants import FAKE_8_CUSTOM_PACKAGE_NAME -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants import SM_OVERALL_STATUS +from robottelo.constants import ( + DEFAULT_SUBSCRIPTION_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE_NAME, + FAKE_2_CUSTOM_PACKAGE, + FAKE_7_CUSTOM_PACKAGE, + FAKE_8_CUSTOM_PACKAGE, + FAKE_8_CUSTOM_PACKAGE_NAME, + PRDS, + REPOS, + REPOSET, + SM_OVERALL_STATUS, +) from robottelo.hosts import ContentHostError from robottelo.logging import logger -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_hosts_list +from robottelo.utils.datafactory import ( + invalid_values_list, + valid_data_list, + valid_hosts_list, +) from robottelo.utils.issue_handlers import is_open @@ -682,45 +681,6 @@ def test_positive_list_infrastructure_hosts( assert target_sat.hostname in hostnames -@pytest.mark.skip_if_not_set('libvirt') -@pytest.mark.cli_host_create -@pytest.mark.libvirt_discovery -@pytest.mark.on_premises_provisioning -@pytest.mark.tier1 -def test_positive_create_using_libvirt_without_mac(target_sat, module_location, module_org): - """Create a libvirt host and not specify a MAC address. - - :id: b003faa9-2810-4176-94d2-ea84bed248eb - - :expectedresults: Host is created - - :CaseImportance: Critical - """ - compute_resource = target_sat.api.LibvirtComputeResource( - url=f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', - organization=[module_org.id], - location=[module_location.id], - ).create() - host = target_sat.api.Host(organization=module_org.id, location=module_location.id) - host.create_missing() - result = make_host( - { - 'architecture-id': host.architecture.id, - 'compute-resource-id': compute_resource.id, - 'domain-id': host.domain.id, - 'location-id': host.location.id, - 'medium-id': host.medium.id, - 'name': host.name, - 'operatingsystem-id': host.operatingsystem.id, - 'organization-id': host.organization.id, - 'partition-table-id': host.ptable.id, - 'root-password': host.root_pass, - } - ) - assert result['name'] == host.name + '.' + host.domain.name - Host.delete({'id': result['id']}) - - @pytest.mark.cli_host_create @pytest.mark.tier2 def test_positive_create_inherit_lce_cv( diff --git a/tests/foreman/cli/test_hostcollection.py b/tests/foreman/cli/test_hostcollection.py index 80b11a56350..fa41aa9067e 100644 --- a/tests/foreman/cli/test_hostcollection.py +++ b/tests/foreman/cli/test_hostcollection.py @@ -16,26 +16,29 @@ :Upstream: No """ -import pytest from broker import Broker from fauxfactory import gen_string +import pytest from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_fake_host -from robottelo.cli.factory import make_host_collection -from robottelo.cli.factory import make_org +from robottelo.cli.factory import ( + CLIFactoryError, + make_fake_host, + make_host_collection, + make_org, +) from robottelo.cli.host import Host from robottelo.cli.hostcollection import HostCollection from robottelo.cli.lifecycleenvironment import LifecycleEnvironment -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT +from robottelo.constants import DEFAULT_CV, ENVIRONMENT from robottelo.hosts import ContentHost -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, +) def _make_fake_host_helper(module_org): diff --git a/tests/foreman/cli/test_hostgroup.py b/tests/foreman/cli/test_hostgroup.py index e5fee3a7738..d1fa7190b5a 100644 --- a/tests/foreman/cli/test_hostgroup.py +++ b/tests/foreman/cli/test_hostgroup.py @@ -16,31 +16,35 @@ :Upstream: No """ -import pytest from fauxfactory import gen_integer from nailgun import entities +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_architecture -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_domain -from robottelo.cli.factory import make_environment -from robottelo.cli.factory import make_hostgroup -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_os -from robottelo.cli.factory import make_partition_table -from robottelo.cli.factory import make_subnet +from robottelo.cli.factory import ( + CLIFactoryError, + make_architecture, + make_content_view, + make_domain, + make_environment, + make_hostgroup, + make_lifecycle_environment, + make_location, + make_medium, + make_os, + make_partition_table, + make_subnet, +) from robottelo.cli.hostgroup import HostGroup from robottelo.cli.proxy import Proxy from robottelo.config import settings -from robottelo.utils.datafactory import invalid_id_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_hostgroups_list +from robottelo.utils.datafactory import ( + invalid_id_list, + invalid_values_list, + parametrized, + valid_hostgroups_list, +) pytestmark = [ pytest.mark.skipif( diff --git a/tests/foreman/cli/test_http_proxy.py b/tests/foreman/cli/test_http_proxy.py index 4f7808e645c..50c71313a89 100644 --- a/tests/foreman/cli/test_http_proxy.py +++ b/tests/foreman/cli/test_http_proxy.py @@ -16,14 +16,11 @@ :Upstream: No """ +from fauxfactory import gen_integer, gen_string, gen_url import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_repository +from robottelo.cli.factory import make_product, make_repository from robottelo.cli.http_proxy import HttpProxy from robottelo.cli.product import Product from robottelo.cli.repository import Repository diff --git a/tests/foreman/cli/test_installer.py b/tests/foreman/cli/test_installer.py index 67d0bf7ad9c..7980f40a385 100644 --- a/tests/foreman/cli/test_installer.py +++ b/tests/foreman/cli/test_installer.py @@ -36,15 +36,3 @@ def test_positive_server_installer_from_iso(): :CaseAutomation: NotAutomated """ - - -def test_positive_disconnected_util_installer(): - """Can install satellite disconnected utility successfully - via RPM - - :id: b738cf2a-9c5f-4865-b134-102a4688534c - - :expectedresults: Install of disconnected utility successful. - - :CaseAutomation: NotAutomated - """ diff --git a/tests/foreman/cli/test_jobtemplate.py b/tests/foreman/cli/test_jobtemplate.py index a90aa0fb6ad..916fdea7a33 100644 --- a/tests/foreman/cli/test_jobtemplate.py +++ b/tests/foreman/cli/test_jobtemplate.py @@ -16,16 +16,14 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo import ssh from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_job_template +from robottelo.cli.factory import CLIFactoryError, make_job_template from robottelo.cli.job_template import JobTemplate -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import invalid_values_list, parametrized TEMPLATE_FILE = 'template_file.txt' TEMPLATE_FILE_EMPTY = 'template_file_empty.txt' diff --git a/tests/foreman/cli/test_ldapauthsource.py b/tests/foreman/cli/test_ldapauthsource.py index e9f299ab213..92d5185cc83 100644 --- a/tests/foreman/cli/test_ldapauthsource.py +++ b/tests/foreman/cli/test_ldapauthsource.py @@ -16,23 +16,22 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.auth import Auth from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_ldap_auth_source -from robottelo.cli.factory import make_usergroup -from robottelo.cli.factory import make_usergroup_external +from robottelo.cli.factory import ( + make_ldap_auth_source, + make_usergroup, + make_usergroup_external, +) from robottelo.cli.ldapauthsource import LDAPAuthSource from robottelo.cli.role import Role -from robottelo.cli.usergroup import UserGroup -from robottelo.cli.usergroup import UserGroupExternal -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import parametrized +from robottelo.cli.usergroup import UserGroup, UserGroupExternal +from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE +from robottelo.utils.datafactory import generate_strings_list, parametrized @pytest.fixture() diff --git a/tests/foreman/cli/test_leapp_client.py b/tests/foreman/cli/test_leapp_client.py new file mode 100644 index 00000000000..37d1784926c --- /dev/null +++ b/tests/foreman/cli/test_leapp_client.py @@ -0,0 +1,293 @@ +"""Tests for leapp upgrade of content hosts with Satellite + +:Requirement: leapp + +:CaseLevel: Integration + +:CaseComponent: Leappintegration + +:Team: Rocket + +:TestType: Functional + +:CaseImportance: High + +:CaseAutomation: Automated + +:Upstream: No +""" +from broker import Broker +import pytest + +from robottelo.config import settings +from robottelo.constants import PRDS +from robottelo.hosts import ContentHost +from robottelo.logging import logger + +synced_repos = pytest.StashKey[dict] + +RHEL7_VER = '7.9' +RHEL8_VER = '8.8' +RHEL9_VER = '9.2' + +RHEL_REPOS = { + 'rhel7_server': { + 'id': 'rhel-7-server-rpms', + 'name': f'Red Hat Enterprise Linux 7 Server RPMs x86_64 {RHEL7_VER}', + 'releasever': RHEL7_VER, + 'reposet': 'Red Hat Enterprise Linux 7 Server (RPMs)', + 'product': 'Red Hat Enterprise Linux Server', + }, + 'rhel7_server_extras': { + 'id': 'rhel-7-server-extras-rpms', + 'name': 'Red Hat Enterprise Linux 7 Server - Extras RPMs x86_64', + 'releasever': '7', + 'reposet': 'Red Hat Enterprise Linux 7 Server - Extras (RPMs)', + 'product': 'Red Hat Enterprise Linux Server', + }, + 'rhel8_bos': { + 'id': 'rhel-8-for-x86_64-baseos-rpms', + 'name': f'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs {RHEL8_VER}', + 'releasever': RHEL8_VER, + 'reposet': 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)', + }, + 'rhel8_aps': { + 'id': 'rhel-8-for-x86_64-appstream-rpms', + 'name': f'Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs {RHEL8_VER}', + 'releasever': RHEL8_VER, + 'reposet': 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)', + }, + 'rhel9_bos': { + 'id': 'rhel-9-for-x86_64-baseos-rpms', + 'name': f'Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs {RHEL9_VER}', + 'releasever': RHEL9_VER, + 'reposet': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)', + }, + 'rhel9_aps': { + 'id': 'rhel-9-for-x86_64-appstream-rpms', + 'name': f'Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs {RHEL9_VER}', + 'releasever': RHEL9_VER, + 'reposet': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)', + }, +} + + +@pytest.fixture(scope='module') +def module_stash(request): + """Module scoped stash for storing data between tests""" + # Please refer the documentation for more details on stash + # https://docs.pytest.org/en/latest/reference/reference.html#stash + request.node.stash[synced_repos] = {} + yield request.node.stash + + +@pytest.fixture(scope='module') +def module_leapp_lce(module_target_sat, module_sca_manifest_org): + return module_target_sat.api.LifecycleEnvironment(organization=module_sca_manifest_org).create() + + +@pytest.fixture +def function_leapp_cv(module_target_sat, module_sca_manifest_org, leapp_repos, module_leapp_lce): + function_leapp_cv = module_target_sat.api.ContentView( + organization=module_sca_manifest_org + ).create() + function_leapp_cv.repository = leapp_repos + function_leapp_cv = function_leapp_cv.update(['repository']) + function_leapp_cv.publish() + cvv = function_leapp_cv.read().version[0] + cvv.promote(data={'environment_ids': module_leapp_lce.id, 'force': True}) + function_leapp_cv = function_leapp_cv.read() + return function_leapp_cv + + +@pytest.fixture +def function_leapp_ak( + module_target_sat, + function_leapp_cv, + module_leapp_lce, + module_sca_manifest_org, +): + return module_target_sat.api.ActivationKey( + content_view=function_leapp_cv, + environment=module_leapp_lce, + organization=module_sca_manifest_org, + ).create() + + +@pytest.fixture +def leapp_repos( + default_architecture, + module_stash, + upgrade_path, + module_target_sat, + module_sca_manifest_org, +): + """Enable and sync RHEL BaseOS, AppStream repositories""" + source = upgrade_path['source_version'] + target = upgrade_path['target_version'] + all_repos = [] + for rh_repo_key in RHEL_REPOS.keys(): + release_version = RHEL_REPOS[rh_repo_key]['releasever'] + if release_version in str(source) or release_version in target: + prod = 'rhel' if 'rhel7' in rh_repo_key else rh_repo_key.split('_')[0] + if module_stash[synced_repos].get(rh_repo_key, None): + logger.info('Repo %s already synced, not syncing it', rh_repo_key) + else: + module_stash[synced_repos][rh_repo_key] = True + repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid( + basearch=default_architecture.name, + org_id=module_sca_manifest_org.id, + product=PRDS[prod], + repo=RHEL_REPOS[rh_repo_key]['name'], + reposet=RHEL_REPOS[rh_repo_key]['reposet'], + releasever=release_version, + ) + rh_repo = module_target_sat.api.Repository(id=repo_id).read() + all_repos.append(rh_repo) + rh_repo.sync(timeout=1800) + return all_repos + + +@pytest.fixture +def verify_target_repo_on_satellite( + module_target_sat, + function_leapp_cv, + module_sca_manifest_org, + module_leapp_lce, + upgrade_path, +): + """Verify target rhel version repositories have been added in correct CV, LCE on Satellite""" + target_rhel_major_ver = upgrade_path['target_version'].split('.')[0] + cmd_out = module_target_sat.cli.Repository.list( + { + 'search': f'content_label ~ rhel-{target_rhel_major_ver}', + 'content-view-id': function_leapp_cv.id, + 'organization-id': module_sca_manifest_org.id, + 'lifecycle-environment-id': module_leapp_lce.id, + } + ) + repo_names = [out['name'] for out in cmd_out] + if target_rhel_major_ver == '9': + assert RHEL_REPOS['rhel9_bos']['name'] in repo_names + assert RHEL_REPOS['rhel9_aps']['name'] in repo_names + else: + assert RHEL_REPOS['rhel8_bos']['name'] in repo_names + assert RHEL_REPOS['rhel8_aps']['name'] in repo_names + + +@pytest.fixture +def custom_leapp_host(upgrade_path, module_target_sat, module_sca_manifest_org, function_leapp_ak): + """Checkout content host and register with satellite""" + deploy_args = {} + deploy_args['deploy_rhel_version'] = upgrade_path['source_version'] + with Broker( + workflow='deploy-rhel', + host_class=ContentHost, + deploy_rhel_version=upgrade_path['source_version'], + deploy_flavor=settings.flavors.default, + ) as chost: + result = chost.register( + module_sca_manifest_org, None, function_leapp_ak.name, module_target_sat + ) + assert result.status == 0, f'Failed to register host: {result.stderr}' + yield chost + + +@pytest.fixture +def precondition_check_upgrade_and_install_leapp_tool(custom_leapp_host): + """Clean-up directory if in-place upgrade already performed, + set rhel release version, update system and install leapp-upgrade""" + source_rhel = custom_leapp_host.os_version.base_version + custom_leapp_host.run('rm -rf /root/tmp_leapp_py3') + custom_leapp_host.run('yum repolist') + custom_leapp_host.run(f'subscription-manager release --set {source_rhel}') + assert custom_leapp_host.run('yum update -y').status == 0 + assert custom_leapp_host.run('yum install leapp-upgrade -y').status == 0 + if custom_leapp_host.run('needs-restarting -r').status == 1: + custom_leapp_host.power_control(state='reboot', ensure=True) + + +@pytest.mark.parametrize( + 'upgrade_path', + [ + # {'source_version': RHEL7_VER, 'target_version': RHEL8_VER}, + {'source_version': RHEL8_VER, 'target_version': RHEL9_VER}, + ], + ids=lambda upgrade_path: f'{upgrade_path["source_version"]}' + f'_to_{upgrade_path["target_version"]}', +) +def test_leapp_upgrade_rhel( + module_target_sat, + custom_leapp_host, + upgrade_path, + verify_target_repo_on_satellite, + precondition_check_upgrade_and_install_leapp_tool, +): + """Test to upgrade RHEL host to next major RHEL release using leapp preupgrade and leapp upgrade + job templates + + :id: 8eccc689-3bea-4182-84f3-c121e95d54c3 + + :Steps: + 1. Import a subscription manifest and enable, sync source & target repositories + 2. Create LCE, Create CV, add repositories to it, publish and promote CV, Create AK, etc. + 3. Register content host with AK + 4. Verify that target rhel repositories are enabled on Satellite + 5. Update all packages, install leapp tool and fix inhibitors + 6. Run Leapp Preupgrade and Leapp Upgrade job template + + :expectedresults: + 1. Update RHEL OS major version to another major version + """ + # Fixing known inhibitors for source rhel version 8 + if custom_leapp_host.os_version.major == 8: + # Inhibitor - Firewalld Configuration AllowZoneDrifting Is Unsupported + custom_leapp_host.run( + 'sed -i "s/^AllowZoneDrifting=.*/AllowZoneDrifting=no/" /etc/firewalld/firewalld.conf' + ) + # Run LEAPP-PREUPGRADE Job Template- + template_id = ( + module_target_sat.api.JobTemplate() + .search(query={'search': 'name="Run preupgrade via Leapp"'})[0] + .id + ) + job = module_target_sat.api.JobInvocation().run( + synchronous=False, + data={ + 'job_template_id': template_id, + 'targeting_type': 'static_query', + 'search_query': f'name = {custom_leapp_host.hostname}', + }, + ) + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1800 + ) + result = module_target_sat.api.JobInvocation(id=job['id']).read() + assert result.succeeded == 1 + + # Run LEAPP-UPGRADE Job Template- + template_id = ( + module_target_sat.api.JobTemplate() + .search(query={'search': 'name="Run upgrade via Leapp"'})[0] + .id + ) + job = module_target_sat.api.JobInvocation().run( + synchronous=False, + data={ + 'job_template_id': template_id, + 'targeting_type': 'static_query', + 'search_query': f'name = {custom_leapp_host.hostname}', + 'inputs': {'Reboot': 'true'}, + }, + ) + module_target_sat.wait_for_tasks( + f'resource_type = JobInvocation and resource_id = {job["id"]}', poll_timeout=1800 + ) + result = module_target_sat.api.JobInvocation(id=job['id']).read() + assert result.succeeded == 1 + # Wait for the host to be rebooted and SSH daemon to be started. + custom_leapp_host.wait_for_connection() + + custom_leapp_host.clean_cached_properties() + new_ver = str(custom_leapp_host.os_version) + assert new_ver == upgrade_path['target_version'] diff --git a/tests/foreman/cli/test_lifecycleenvironment.py b/tests/foreman/cli/test_lifecycleenvironment.py index fc05395c79c..b9a77b5220f 100644 --- a/tests/foreman/cli/test_lifecycleenvironment.py +++ b/tests/foreman/cli/test_lifecycleenvironment.py @@ -18,12 +18,11 @@ """ from math import ceil -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_org +from robottelo.cli.factory import make_lifecycle_environment, make_org from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.constants import ENVIRONMENT diff --git a/tests/foreman/cli/test_location.py b/tests/foreman/cli/test_location.py index 7baebfb0d1d..ee157c4ef76 100644 --- a/tests/foreman/cli/test_location.py +++ b/tests/foreman/cli/test_location.py @@ -16,23 +16,25 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.computeresource import ComputeResource from robottelo.cli.domain import Domain from robottelo.cli.environment import Environment -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.factory import make_domain -from robottelo.cli.factory import make_environment -from robottelo.cli.factory import make_hostgroup -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_subnet -from robottelo.cli.factory import make_template -from robottelo.cli.factory import make_user +from robottelo.cli.factory import ( + CLIFactoryError, + make_compute_resource, + make_domain, + make_environment, + make_hostgroup, + make_location, + make_medium, + make_subnet, + make_template, + make_user, +) from robottelo.cli.hostgroup import HostGroup from robottelo.cli.location import Location from robottelo.cli.medium import Medium diff --git a/tests/foreman/cli/test_logging.py b/tests/foreman/cli/test_logging.py index f926d96a7c8..45692e2e2a2 100644 --- a/tests/foreman/cli/test_logging.py +++ b/tests/foreman/cli/test_logging.py @@ -18,12 +18,11 @@ """ import re -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_repository +from robottelo.cli.factory import make_product, make_repository from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings diff --git a/tests/foreman/cli/test_medium.py b/tests/foreman/cli/test_medium.py index 8f3d7ad2400..d9f835fdb0b 100644 --- a/tests/foreman/cli/test_medium.py +++ b/tests/foreman/cli/test_medium.py @@ -16,17 +16,13 @@ :Upstream: No """ -import pytest from fauxfactory import gen_alphanumeric +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_os +from robottelo.cli.factory import make_location, make_medium, make_org, make_os from robottelo.cli.medium import Medium -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import parametrized, valid_data_list URL = "http://mirror.fakeos.org/%s/$major.$minor/os/$arch" OSES = ['Archlinux', 'Debian', 'Gentoo', 'Redhat', 'Solaris', 'Suse', 'Windows'] diff --git a/tests/foreman/cli/test_model.py b/tests/foreman/cli/test_model.py index aa2d5c8f704..fe8050d13e9 100644 --- a/tests/foreman/cli/test_model.py +++ b/tests/foreman/cli/test_model.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.factory import make_model from robottelo.cli.model import Model -from robottelo.utils.datafactory import invalid_id_list -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + invalid_id_list, + invalid_values_list, + parametrized, + valid_data_list, +) class TestModel: diff --git a/tests/foreman/cli/test_operatingsystem.py b/tests/foreman/cli/test_operatingsystem.py index eeb5394cba2..587ceeb67a0 100644 --- a/tests/foreman/cli/test_operatingsystem.py +++ b/tests/foreman/cli/test_operatingsystem.py @@ -16,20 +16,23 @@ :Upstream: No """ +from fauxfactory import gen_alphanumeric, gen_string import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_string from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_architecture -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_partition_table -from robottelo.cli.factory import make_template +from robottelo.cli.factory import ( + make_architecture, + make_medium, + make_partition_table, + make_template, +) from robottelo.constants import DEFAULT_ORG -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, + valid_data_list, +) @filtered_datapoint diff --git a/tests/foreman/cli/test_organization.py b/tests/foreman/cli/test_organization.py index d0095c1974e..2d4a8b8b8b8 100644 --- a/tests/foreman/cli/test_organization.py +++ b/tests/foreman/cli/test_organization.py @@ -16,31 +16,35 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.factory import make_domain -from robottelo.cli.factory import make_hostgroup -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_subnet -from robottelo.cli.factory import make_template -from robottelo.cli.factory import make_user +from robottelo.cli.factory import ( + CLIFactoryError, + make_compute_resource, + make_domain, + make_hostgroup, + make_lifecycle_environment, + make_location, + make_medium, + make_org, + make_subnet, + make_template, + make_user, +) from robottelo.cli.lifecycleenvironment import LifecycleEnvironment from robottelo.cli.org import Org from robottelo.cli.user import User from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_org_names_list +from robottelo.utils.datafactory import ( + filtered_datapoint, + invalid_values_list, + parametrized, + valid_data_list, + valid_org_names_list, +) @filtered_datapoint diff --git a/tests/foreman/cli/test_oscap.py b/tests/foreman/cli/test_oscap.py index f5e442476aa..5088d25fb60 100644 --- a/tests/foreman/cli/test_oscap.py +++ b/tests/foreman/cli/test_oscap.py @@ -6,7 +6,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,26 +16,28 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_hostgroup -from robottelo.cli.factory import make_scap_policy -from robottelo.cli.factory import make_scapcontent -from robottelo.cli.factory import make_tailoringfile +from robottelo.cli.factory import ( + CLIFactoryError, + make_hostgroup, + make_scap_policy, + make_scapcontent, + make_tailoringfile, +) from robottelo.cli.host import Host from robottelo.cli.scap_policy import Scappolicy from robottelo.cli.scapcontent import Scapcontent from robottelo.config import settings -from robottelo.constants import OSCAP_DEFAULT_CONTENT -from robottelo.constants import OSCAP_PERIOD -from robottelo.constants import OSCAP_WEEKDAY -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.constants import OSCAP_DEFAULT_CONTENT, OSCAP_PERIOD, OSCAP_WEEKDAY +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) class TestOpenScap: diff --git a/tests/foreman/cli/test_oscap_tailoringfiles.py b/tests/foreman/cli/test_oscap_tailoringfiles.py index cb3c4f697bb..285a907df3b 100644 --- a/tests/foreman/cli/test_oscap_tailoringfiles.py +++ b/tests/foreman/cli/test_oscap_tailoringfiles.py @@ -6,7 +6,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,18 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_tailoringfile +from robottelo.cli.factory import CLIFactoryError, make_tailoringfile from robottelo.cli.scap_tailoring_files import TailoringFiles -from robottelo.constants import DataFile -from robottelo.constants import SNIPPET_DATA_FILE -from robottelo.utils.datafactory import invalid_names_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.constants import SNIPPET_DATA_FILE, DataFile +from robottelo.utils.datafactory import ( + invalid_names_list, + parametrized, + valid_data_list, +) class TestTailoringFiles: diff --git a/tests/foreman/cli/test_ostreebranch.py b/tests/foreman/cli/test_ostreebranch.py index 9f44e365e3a..23516360e48 100644 --- a/tests/foreman/cli/test_ostreebranch.py +++ b/tests/foreman/cli/test_ostreebranch.py @@ -18,14 +18,16 @@ """ import random -import pytest from nailgun import entities +import pytest from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_org_with_credentials -from robottelo.cli.factory import make_product_with_credentials -from robottelo.cli.factory import make_repository_with_credentials +from robottelo.cli.factory import ( + make_content_view, + make_org_with_credentials, + make_product_with_credentials, + make_repository_with_credentials, +) from robottelo.cli.ostreebranch import OstreeBranch from robottelo.cli.repository import Repository from robottelo.config import settings diff --git a/tests/foreman/cli/test_partitiontable.py b/tests/foreman/cli/test_partitiontable.py index 95854b1f0f1..6540a5d755b 100644 --- a/tests/foreman/cli/test_partitiontable.py +++ b/tests/foreman/cli/test_partitiontable.py @@ -18,15 +18,13 @@ """ from random import randint -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_os -from robottelo.cli.factory import make_partition_table +from robottelo.cli.factory import make_os, make_partition_table from robottelo.cli.partitiontable import PartitionTable -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import parametrized +from robottelo.utils.datafactory import generate_strings_list, parametrized class TestPartitionTable: diff --git a/tests/foreman/cli/test_product.py b/tests/foreman/cli/test_product.py index be4eedbdf50..e11b09f6367 100644 --- a/tests/foreman/cli/test_product.py +++ b/tests/foreman/cli/test_product.py @@ -16,29 +16,30 @@ :Upstream: No """ +from fauxfactory import gen_alphanumeric, gen_integer, gen_string, gen_url import pytest -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.defaults import Defaults -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_content_credential -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_repository -from robottelo.cli.factory import make_sync_plan +from robottelo.cli.factory import ( + CLIFactoryError, + make_content_credential, + make_org, + make_product, + make_repository, + make_sync_plan, +) from robottelo.cli.package import Package from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.config import settings from robottelo.constants import FAKE_0_YUM_REPO_PACKAGES_COUNT -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_labels_list +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, + valid_labels_list, +) @pytest.mark.tier1 diff --git a/tests/foreman/cli/test_provisioningtemplate.py b/tests/foreman/cli/test_provisioningtemplate.py index db2cca0dcda..71214e84615 100644 --- a/tests/foreman/cli/test_provisioningtemplate.py +++ b/tests/foreman/cli/test_provisioningtemplate.py @@ -19,8 +19,8 @@ import random from random import randint -import pytest from fauxfactory import gen_string +import pytest from robottelo import constants from robottelo.cli.base import CLIReturnCodeError diff --git a/tests/foreman/cli/test_realm.py b/tests/foreman/cli/test_realm.py index 1d7eb9c4b20..595a123e9e8 100644 --- a/tests/foreman/cli/test_realm.py +++ b/tests/foreman/cli/test_realm.py @@ -18,12 +18,11 @@ """ import random -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_realm +from robottelo.cli.factory import CLIFactoryError, make_realm from robottelo.cli.realm import Realm diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index 9de5569c81b..d360f1be8f7 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -17,22 +17,24 @@ :Upstream: No """ from calendar import monthrange -from datetime import datetime -from datetime import timedelta +from datetime import datetime, timedelta +import random from time import sleep -import pytest from broker import Broker -from dateutil.relativedelta import FR -from dateutil.relativedelta import relativedelta +from dateutil.relativedelta import FR, relativedelta from fauxfactory import gen_string +import pytest -from robottelo.cli.factory import make_filter -from robottelo.cli.factory import make_job_invocation -from robottelo.cli.factory import make_job_invocation_with_credentials -from robottelo.cli.factory import make_job_template -from robottelo.cli.factory import make_role -from robottelo.cli.factory import make_user +from robottelo import constants +from robottelo.cli.factory import ( + make_filter, + make_job_invocation, + make_job_invocation_with_credentials, + make_job_template, + make_role, + make_user, +) from robottelo.cli.filter import Filter from robottelo.cli.globalparam import GlobalParameter from robottelo.cli.host import Host @@ -43,11 +45,24 @@ from robottelo.cli.task import Task from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import PRDS, REPOS, REPOSET from robottelo.hosts import ContentHost from robottelo.utils import ohsnap +from robottelo.utils.datafactory import filtered_datapoint, parametrized + + +@filtered_datapoint +def valid_feature_names(): + """Returns a list of valid features and their descriptions""" + return [ + {'label': 'katello_package_install', 'jt_name': 'Install Package - Katello Script Default'}, + {'label': 'katello_package_update', 'jt_name': 'Update Package - Katello Script Default'}, + {'label': 'katello_package_remove', 'jt_name': 'Remove Package - Katello Script Default'}, + {'label': 'katello_group_install', 'jt_name': 'Install Group - Katello Script Default'}, + {'label': 'katello_group_update', 'jt_name': 'Update Group - Katello Script Default'}, + {'label': 'katello_group_remove', 'jt_name': 'Remove Group - Katello Script Default'}, + {'label': 'katello_errata_install', 'jt_name': 'Install Errata - Katello Script Default'}, + ] @pytest.fixture() @@ -113,8 +128,8 @@ class TestRemoteExecution: @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.rhel_ver_list([8]) - def test_positive_run_default_job_template_by_ip(self, module_org, rex_contenthost): - """Run default template on host connected by ip and list task + def test_positive_run_default_job_template(self, module_org, rex_contenthost): + """Run default template on host connected and list task :id: 811c7747-bec6-4a2d-8e5c-b5045d3fbc0d @@ -154,8 +169,8 @@ def test_positive_run_default_job_template_by_ip(self, module_org, rex_contentho @pytest.mark.pit_client @pytest.mark.pit_server @pytest.mark.rhel_ver_list([7, 8, 9]) - def test_positive_run_job_effective_user_by_ip(self, rex_contenthost): - """Run default job template as effective user on a host by ip + def test_positive_run_job_effective_user(self, rex_contenthost): + """Run default job template as effective user on a host :id: 0cd75cab-f699-47e6-94d3-4477d2a94bb7 @@ -198,8 +213,8 @@ def test_positive_run_job_effective_user_by_ip(self, rex_contenthost): @pytest.mark.tier3 @pytest.mark.e2e @pytest.mark.rhel_ver_match('[^6].*') - def test_positive_run_custom_job_template_by_ip(self, rex_contenthost, module_org, target_sat): - """Run custom template on host connected by ip + def test_positive_run_custom_job_template(self, rex_contenthost, module_org, target_sat): + """Run custom template on host connected :id: 9740eb1d-59f5-42b2-b3ab-659ca0202c74 @@ -230,10 +245,8 @@ def test_positive_run_custom_job_template_by_ip(self, rex_contenthost, module_or @pytest.mark.upgrade @pytest.mark.no_containers @pytest.mark.rhel_ver_list([8]) - def test_positive_run_default_job_template_multiple_hosts_by_ip( - self, registered_hosts, module_org - ): - """Run default job template against multiple hosts by ip + def test_positive_run_default_job_template_multiple_hosts(self, registered_hosts, module_org): + """Run default job template against multiple hosts :id: 694a21d3-243b-4296-8bd0-4bad9663af15 @@ -271,15 +284,15 @@ def test_positive_run_default_job_template_multiple_hosts_by_ip( @pytest.mark.skipif( (not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url' ) - def test_positive_install_multiple_packages_with_a_job_by_ip( + def test_positive_install_remove_multiple_packages_with_a_job( self, rhel_contenthost, module_org, module_ak_with_cv, target_sat ): - """Run job to install several packages on host by ip + """Run job to install and remove several packages on host :id: 8b73033f-83c9-4024-83c3-5e442a79d320 :expectedresults: Verify the packages were successfully installed - on host + and removed on a host :parametrized: yes """ @@ -292,21 +305,150 @@ def test_positive_install_multiple_packages_with_a_job_by_ip( target_sat, repo=settings.repos.yum_3.url, ) + # Install packages invocation_command = make_job_invocation( { 'job-template': 'Install Package - Katello Script Default', - 'inputs': 'package={} {} {}'.format(*packages), + 'inputs': f'package={" ".join(packages)}', 'search-query': f'name ~ {client.hostname}', } ) assert_job_invocation_result(invocation_command['id'], client.hostname) result = client.run(f'rpm -q {" ".join(packages)}') assert result.status == 0 + # Update packages + pre_versions = result.stdout.splitlines() + result = client.run(f'dnf -y downgrade {" ".join(packages)}') + assert result.status == 0 + invocation_command = make_job_invocation( + { + 'job-template': 'Update Package - Katello Script Default', + 'inputs': f'package={" ".join(packages)}', + 'search-query': f'name ~ {client.hostname}', + } + ) + assert_job_invocation_result(invocation_command['id'], client.hostname) + post_versions = client.run(f'rpm -q {" ".join(packages)}').stdout.splitlines() + assert set(pre_versions) == set(post_versions) + # Remove packages + invocation_command = make_job_invocation( + { + 'job-template': 'Remove Package - Katello Script Default', + 'inputs': f'package={" ".join(packages)}', + 'search-query': f'name ~ {client.hostname}', + } + ) + assert_job_invocation_result(invocation_command['id'], client.hostname) + result = client.run(f'rpm -q {" ".join(packages)}') + assert result.status == len(packages) @pytest.mark.tier3 + @pytest.mark.no_containers @pytest.mark.rhel_ver_list([8]) - def test_positive_run_recurring_job_with_max_iterations_by_ip(self, rex_contenthost): - """Run default job template multiple times with max iteration by ip + @pytest.mark.skipif( + (not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url' + ) + def test_positive_install_remove_packagegroup_with_a_job( + self, rhel_contenthost, module_org, module_ak_with_cv, target_sat + ): + """Run job to install and remove several package groups on host + + :id: 5be2a5c0-199a-4655-9784-e95c7ef151f5 + + :expectedresults: Verify the package groups were successfully installed + and removed on a host + + :parametrized: yes + """ + client = rhel_contenthost + groups = ['birds', 'mammals'] + client.register( + module_org, + None, + module_ak_with_cv.name, + target_sat, + repo=settings.repos.yum_1.url, + ) + # Install the package groups + invocation_command = make_job_invocation( + { + 'job-template': 'Install Group - Katello Script Default', + 'inputs': f'package={" ".join(groups)}', + 'search-query': f'name ~ {client.hostname}', + } + ) + assert_job_invocation_result(invocation_command['id'], client.hostname) + result = client.run('dnf grouplist --installed') + assert all(item in result.stdout for item in groups) + # Remove one of the installed package groups + remove = random.choice(groups) + invocation_command = make_job_invocation( + { + 'job-template': 'Remove Group - Katello Script Default', + 'inputs': f'package={remove}', + 'search-query': f'name ~ {client.hostname}', + } + ) + assert_job_invocation_result(invocation_command['id'], client.hostname) + result = client.run('dnf grouplist --installed') + assert remove not in result.stdout + + @pytest.mark.tier3 + @pytest.mark.no_containers + @pytest.mark.rhel_ver_list([8]) + @pytest.mark.skipif( + (not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url' + ) + def test_positive_install_errata_with_a_job( + self, rhel_contenthost, module_org, module_ak_with_cv, target_sat + ): + """Run job to install errata on host + + :id: d906a884-9fd7-48dc-a91b-fa6e8c3311c1 + + :expectedresults: Verify the errata was successfully installed on a host + + :parametrized: yes + """ + client = rhel_contenthost + client.register( + module_org, + None, + module_ak_with_cv.name, + target_sat, + repo=settings.repos.yum_1.url, + ) + client.run(f'dnf install -y {constants.FAKE_1_CUSTOM_PACKAGE}') + # Install errata + invocation_command = make_job_invocation( + { + 'job-template': 'Install Errata - Katello Script Default', + 'inputs': f'errata={settings.repos.yum_0.errata[1]}', + 'search-query': f'name ~ {client.hostname}', + } + ) + assert_job_invocation_result(invocation_command['id'], client.hostname) + result = client.run(f'rpm -q {constants.FAKE_2_CUSTOM_PACKAGE}') + assert result.status == 0 + + @pytest.mark.tier3 + @pytest.mark.parametrize('feature', **parametrized(valid_feature_names())) + def test_positive_match_feature_templates(self, target_sat, feature): + """Verify the `feature` names match the correct templates + + :id: a7cf23fe-4d3b-4bd2-b921-d31ad3e4d7e9 + + :expectedresults: All features exist and match the expected templates + + :parametrized: yes + """ + result = target_sat.cli.RemoteExecutionFeature.info({'id': feature['label']}) + assert result['job-template-name'] == feature['jt_name'] + + @pytest.mark.tier3 + @pytest.mark.rhel_ver_list([8]) + def test_positive_run_recurring_job_with_max_iterations(self, rex_contenthost): + """Run default job template multiple times with max iteration :id: 0a3d1627-95d9-42ab-9478-a908f2a7c509 @@ -417,7 +559,7 @@ def test_positive_time_expressions(self, rex_contenthost): @pytest.mark.tier3 @pytest.mark.rhel_ver_list([8]) - def test_positive_run_scheduled_job_template_by_ip(self, rex_contenthost, target_sat): + def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat): """Schedule a job to be ran against a host :id: 0407e3de-ef59-4706-ae0d-b81172b81e5c @@ -431,14 +573,6 @@ def test_positive_run_scheduled_job_template_by_ip(self, rex_contenthost, target system_current_time = target_sat.execute('date --utc +"%b %d %Y %I:%M%p"').stdout current_time_object = datetime.strptime(system_current_time.strip('\n'), '%b %d %Y %I:%M%p') plan_time = (current_time_object + timedelta(seconds=30)).strftime("%Y-%m-%d %H:%M") - Host.set_parameter( - { - 'host': client.hostname, - 'name': 'remote_execution_connect_by_ip', - 'value': 'True', - 'parameter-type': 'boolean', - } - ) invocation_command = make_job_invocation( { 'job-template': 'Run Command - Script Default', diff --git a/tests/foreman/cli/test_reporttemplates.py b/tests/foreman/cli/test_reporttemplates.py index 151312a72a7..8f2729046b3 100644 --- a/tests/foreman/cli/test_reporttemplates.py +++ b/tests/foreman/cli/test_reporttemplates.py @@ -15,32 +15,33 @@ :Upstream: No """ -import pytest from broker import Broker from fauxfactory import gen_alpha +import pytest from robottelo.cli.activationkey import ActivationKey -from robottelo.cli.base import Base -from robottelo.cli.base import CLIReturnCodeError +from robottelo.cli.base import Base, CLIReturnCodeError from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_activation_key -from robottelo.cli.factory import make_architecture -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_fake_host -from robottelo.cli.factory import make_filter -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_medium -from robottelo.cli.factory import make_os -from robottelo.cli.factory import make_partition_table -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_report_template -from robottelo.cli.factory import make_repository -from robottelo.cli.factory import make_role -from robottelo.cli.factory import make_template_input -from robottelo.cli.factory import make_user -from robottelo.cli.factory import setup_org_for_a_custom_repo -from robottelo.cli.factory import setup_org_for_a_rh_repo +from robottelo.cli.factory import ( + CLIFactoryError, + make_activation_key, + make_architecture, + make_content_view, + make_fake_host, + make_filter, + make_lifecycle_environment, + make_medium, + make_os, + make_partition_table, + make_product, + make_report_template, + make_repository, + make_role, + make_template_input, + make_user, + setup_org_for_a_custom_repo, + setup_org_for_a_rh_repo, +) from robottelo.cli.filter import Filter from robottelo.cli.host import Host from robottelo.cli.location import Location @@ -51,17 +52,19 @@ from robottelo.cli.subscription import Subscription from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import DEFAULT_ORG -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import PRDS -from robottelo.constants import REPORT_TEMPLATE_FILE -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import ( + DEFAULT_LOC, + DEFAULT_ORG, + DEFAULT_SUBSCRIPTION_NAME, + FAKE_0_CUSTOM_PACKAGE_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE_NAME, + FAKE_2_CUSTOM_PACKAGE, + PRDS, + REPORT_TEMPLATE_FILE, + REPOS, + REPOSET, +) from robottelo.hosts import ContentHost diff --git a/tests/foreman/cli/test_repository.py b/tests/foreman/cli/test_repository.py index 46e0e849a47..42fd08f4f8a 100644 --- a/tests/foreman/cli/test_repository.py +++ b/tests/foreman/cli/test_repository.py @@ -19,30 +19,29 @@ from random import choice from string import punctuation +from fauxfactory import gen_alphanumeric, gen_integer, gen_string, gen_url +from nailgun import entities import pytest import requests -from fauxfactory import gen_alphanumeric -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url -from nailgun import entities from wait_for import wait_for from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.content_export import ContentExport from robottelo.cli.content_import import ContentImport from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_content_credential -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_filter -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_repository -from robottelo.cli.factory import make_role -from robottelo.cli.factory import make_user +from robottelo.cli.factory import ( + CLIFactoryError, + make_content_credential, + make_content_view, + make_filter, + make_lifecycle_environment, + make_location, + make_org, + make_product, + make_repository, + make_role, + make_user, +) from robottelo.cli.file import File from robottelo.cli.filter import Filter from robottelo.cli.module_stream import ModuleStream @@ -57,31 +56,37 @@ from robottelo.cli.task import Task from robottelo.cli.user import User from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import CUSTOM_FILE_REPO_FILES_COUNT -from robottelo.constants import CUSTOM_LOCAL_FOLDER -from robottelo.constants import DataFile -from robottelo.constants import DOWNLOAD_POLICIES -from robottelo.constants import MIRRORING_POLICIES -from robottelo.constants import OS_TEMPLATE_DATA_FILE -from robottelo.constants import REPO_TYPE -from robottelo.constants import RPM_TO_UPLOAD -from robottelo.constants import SRPM_TO_UPLOAD -from robottelo.constants.repos import ANSIBLE_GALAXY -from robottelo.constants.repos import CUSTOM_3RD_PARTY_REPO -from robottelo.constants.repos import CUSTOM_FILE_REPO -from robottelo.constants.repos import CUSTOM_RPM_SHA -from robottelo.constants.repos import FAKE_5_YUM_REPO -from robottelo.constants.repos import FAKE_YUM_DRPM_REPO -from robottelo.constants.repos import FAKE_YUM_MD5_REPO -from robottelo.constants.repos import FAKE_YUM_SRPM_REPO +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + CUSTOM_FILE_REPO_FILES_COUNT, + CUSTOM_LOCAL_FOLDER, + DOWNLOAD_POLICIES, + MIRRORING_POLICIES, + OS_TEMPLATE_DATA_FILE, + REPO_TYPE, + RPM_TO_UPLOAD, + SRPM_TO_UPLOAD, + DataFile, +) +from robottelo.constants.repos import ( + ANSIBLE_GALAXY, + CUSTOM_3RD_PARTY_REPO, + CUSTOM_FILE_REPO, + CUSTOM_RPM_SHA, + FAKE_5_YUM_REPO, + FAKE_YUM_DRPM_REPO, + FAKE_YUM_MD5_REPO, + FAKE_YUM_SRPM_REPO, +) from robottelo.logging import logger -from robottelo.utils.datafactory import invalid_values_list -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list -from robottelo.utils.datafactory import valid_docker_repository_names -from robottelo.utils.datafactory import valid_http_credentials +from robottelo.utils.datafactory import ( + invalid_values_list, + parametrized, + valid_data_list, + valid_docker_repository_names, + valid_http_credentials, +) # from robottelo.constants.repos import FEDORA_OSTREE_REPO diff --git a/tests/foreman/cli/test_repository_set.py b/tests/foreman/cli/test_repository_set.py index cf9f991991a..0be98f8e32d 100644 --- a/tests/foreman/cli/test_repository_set.py +++ b/tests/foreman/cli/test_repository_set.py @@ -20,8 +20,7 @@ from robottelo.cli.product import Product from robottelo.cli.repository_set import RepositorySet -from robottelo.constants import PRDS -from robottelo.constants import REPOSET +from robottelo.constants import PRDS, REPOSET pytestmark = [pytest.mark.run_in_one_thread, pytest.mark.tier1] diff --git a/tests/foreman/cli/test_rhcloud_insights.py b/tests/foreman/cli/test_rhcloud_insights.py deleted file mode 100644 index 9682fc0d86c..00000000000 --- a/tests/foreman/cli/test_rhcloud_insights.py +++ /dev/null @@ -1,60 +0,0 @@ -"""CLI tests for Insights part of RH Cloud - Inventory plugin. - -:Requirement: RH Cloud - Inventory - -:CaseAutomation: Automated - -:CaseLevel: System - -:CaseComponent: RHCloud-Inventory - -:Team: Platform - -:TestType: Functional - -:CaseImportance: High - -:Upstream: No -""" -import pytest -from broker import Broker - -from robottelo.hosts import ContentHost - - -@pytest.mark.e2e -@pytest.mark.tier4 -@pytest.mark.parametrize('distro', ['rhel7', 'rhel8']) -def test_positive_connection_option( - rhcloud_activation_key, rhcloud_manifest_org, module_target_sat, distro -): - """Verify that 'insights-client --test-connection' successfully tests the proxy connection via - the Satellite. - - :id: 61a4a39e-b484-49f4-a6fd-46ffc7736e50 - - :customerscenario: true - - :Steps: - - 1. Create RHEL7 and RHEL8 VM and register to insights within org having manifest. - - 2. Run 'insights-client --test-connection'. - - :expectedresults: 'insights-client --test-connection' should return 0. - - :BZ: 1976754 - - :CaseImportance: Critical - """ - org = rhcloud_manifest_org - ak = rhcloud_activation_key - with Broker(nick=distro, host_class=ContentHost) as vm: - vm.configure_rhai_client(module_target_sat, ak.name, org.label, distro) - result = vm.run('insights-client --test-connection') - assert result.status == 0, ( - 'insights-client --test-connection failed.\n' - f'status: {result.status}\n' - f'stdout: {result.stdout}\n' - f'stderr: {result.stderr}' - ) diff --git a/tests/foreman/cli/test_rhcloud_inventory.py b/tests/foreman/cli/test_rhcloud_inventory.py index 0330420dd45..cdbf63c2d2f 100644 --- a/tests/foreman/cli/test_rhcloud_inventory.py +++ b/tests/foreman/cli/test_rhcloud_inventory.py @@ -16,15 +16,14 @@ :Upstream: No """ -import time from datetime import datetime +import time import pytest from wait_for import wait_for from robottelo.config import robottelo_tmp_dir -from robottelo.utils.io import get_local_file_data -from robottelo.utils.io import get_remote_report_checksum +from robottelo.utils.io import get_local_file_data, get_remote_report_checksum inventory_sync_task = 'InventorySync::Async::InventoryFullSync' generate_report_jobs = 'ForemanInventoryUpload::Async::GenerateAllReportsJob' @@ -209,7 +208,7 @@ def test_max_org_size_variable(): 1. Register few content hosts with satellite. 2. Change value of max_org_size for testing purpose(See BZ#1962694#c2). 3. Start report generation and upload using - ForemanInventoryUpload::Async::GenerateAllReportsJob.perform_now + ForemanTasks.sync_task(ForemanInventoryUpload::Async::GenerateAllReportsJob) :expectedresults: If organization had more hosts than specified by max_org_size variable then report won't be uploaded. diff --git a/tests/foreman/cli/test_role.py b/tests/foreman/cli/test_role.py index 67c96671ef5..feeb1c928be 100644 --- a/tests/foreman/cli/test_role.py +++ b/tests/foreman/cli/test_role.py @@ -16,28 +16,27 @@ :Upstream: No """ -import re from math import ceil from random import choice +import re -import pytest from fauxfactory import gen_string +import pytest -from robottelo.cli.base import CLIDataBaseError -from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.factory import make_filter -from robottelo.cli.factory import make_location -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_role -from robottelo.cli.factory import make_user +from robottelo.cli.base import CLIDataBaseError, CLIReturnCodeError +from robottelo.cli.factory import ( + make_filter, + make_location, + make_org, + make_role, + make_user, +) from robottelo.cli.filter import Filter from robottelo.cli.role import Role from robottelo.cli.settings import Settings from robottelo.cli.user import User -from robottelo.constants import PERMISSIONS -from robottelo.constants import ROLES -from robottelo.utils.datafactory import generate_strings_list -from robottelo.utils.datafactory import parametrized +from robottelo.constants import PERMISSIONS, ROLES +from robottelo.utils.datafactory import generate_strings_list, parametrized class TestRole: diff --git a/tests/foreman/cli/test_satellitesync.py b/tests/foreman/cli/test_satellitesync.py index 4d47712da50..d5a5cfdf9f6 100644 --- a/tests/foreman/cli/test_satellitesync.py +++ b/tests/foreman/cli/test_satellitesync.py @@ -16,31 +16,37 @@ :Upstream: No """ -import pytest +import os + from fauxfactory import gen_string +from manifester import Manifester +import pytest from robottelo.cli.base import CLIReturnCodeError from robottelo.cli.content_export import ContentExport from robottelo.cli.content_import import ContentImport from robottelo.cli.contentview import ContentView -from robottelo.cli.factory import make_content_view -from robottelo.cli.factory import make_lifecycle_environment -from robottelo.cli.factory import make_org -from robottelo.cli.factory import make_product -from robottelo.cli.factory import make_repository -from robottelo.cli.file import File +from robottelo.cli.factory import ( + make_content_view, + make_org, + make_product, + make_repository, +) from robottelo.cli.package import Package from robottelo.cli.product import Product from robottelo.cli.repository import Repository from robottelo.cli.settings import Settings from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_CV -from robottelo.constants import PULP_EXPORT_DIR -from robottelo.constants import PULP_IMPORT_DIR -from robottelo.constants import REPO_TYPE -from robottelo.constants import REPOS +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + DEFAULT_ARCHITECTURE, + DEFAULT_CV, + EXPORT_LIBRARY_NAME, + PULP_EXPORT_DIR, + PULP_IMPORT_DIR, + REPO_TYPE, + REPOS, +) from robottelo.constants.repos import ANSIBLE_GALAXY @@ -77,6 +83,21 @@ def export_import_cleanup_module(target_sat, module_org): ) +@pytest.fixture(scope='function') +def function_import_org(target_sat): + """Creates an Organization for content import.""" + org = target_sat.api.Organization().create() + yield org + + +@pytest.fixture(scope='function') +def function_import_org_with_manifest(target_sat, function_import_org): + """Creates and sets an Organization with a brand-new manifest for content import.""" + with Manifester(manifest_category=settings.manifest.golden_ticket) as manifest: + target_sat.upload_manifest(function_import_org.id, manifest) + yield function_import_org + + @pytest.fixture(scope='class') def docker_repo(module_target_sat, module_org): product = make_product({'organization-id': module_org.id}) @@ -95,7 +116,7 @@ def docker_repo(module_target_sat, module_org): @pytest.fixture(scope='module') -def module_synced_repo(module_target_sat, module_org, module_product): +def module_synced_custom_repo(module_target_sat, module_org, module_product): repo = module_target_sat.cli_factory.make_repository( { 'content-type': 'yum', @@ -109,7 +130,7 @@ def module_synced_repo(module_target_sat, module_org, module_product): @pytest.fixture(scope='function') -def function_synced_repo(target_sat, function_org, function_product): +def function_synced_custom_repo(target_sat, function_org, function_product): repo = target_sat.cli_factory.make_repository( { 'content-type': 'yum', @@ -122,13 +143,50 @@ def function_synced_repo(target_sat, function_org, function_product): yield repo +@pytest.fixture(scope='function') +def function_synced_rhel_repo(request, target_sat, function_sca_manifest_org): + """Enable and synchronize rhel content with immediate policy""" + repo_dict = ( + REPOS['kickstart'][request.param.replace('kickstart', '')[1:]] + if 'kickstart' in request.param + else REPOS[request.param] + ) + target_sat.cli.RepositorySet.enable( + { + 'organization-id': function_sca_manifest_org.id, + 'name': repo_dict['reposet'], + 'product': repo_dict['product'], + 'releasever': repo_dict.get('releasever', None) or repo_dict.get('version', None), + 'basearch': DEFAULT_ARCHITECTURE, + } + ) + repo = target_sat.cli.Repository.info( + { + 'organization-id': function_sca_manifest_org.id, + 'name': repo_dict['name'], + 'product': repo_dict['product'], + } + ) + # Update the download policy to 'immediate' and sync + target_sat.cli.Repository.update({'download-policy': 'immediate', 'id': repo['id']}) + target_sat.cli.Repository.synchronize({'id': repo['id']}, timeout=7200000) + repo = target_sat.cli.Repository.info( + { + 'organization-id': function_sca_manifest_org.id, + 'name': repo_dict['name'], + 'product': repo_dict['product'], + } + ) + return repo + + @pytest.mark.run_in_one_thread class TestRepositoryExport: """Tests for exporting a repository via CLI""" @pytest.mark.tier3 def test_positive_export_version_custom_repo( - self, target_sat, export_import_cleanup_module, module_org, module_synced_repo + self, target_sat, export_import_cleanup_module, module_org, module_synced_custom_repo ): """Export custom repo via complete and incremental CV version export. @@ -162,7 +220,7 @@ def test_positive_export_version_custom_repo( { 'id': cv['id'], 'organization-id': module_org.id, - 'repository-id': module_synced_repo['id'], + 'repository-id': module_synced_custom_repo['id'], } ) target_sat.cli.ContentView.publish({'id': cv['id']}) @@ -188,7 +246,7 @@ def test_positive_export_version_custom_repo( @pytest.mark.tier3 def test_positive_export_library_custom_repo( - self, target_sat, export_import_cleanup_function, function_org, function_synced_repo + self, target_sat, export_import_cleanup_function, function_org, function_synced_custom_repo ): """Export custom repo via complete and incremental library export. @@ -217,7 +275,7 @@ def test_positive_export_library_custom_repo( { 'id': cv['id'], 'organization-id': function_org.id, - 'repository-id': function_synced_repo['id'], + 'repository-id': function_synced_custom_repo['id'], } ) target_sat.cli.ContentView.publish({'id': cv['id']}) @@ -232,100 +290,53 @@ def test_positive_export_library_custom_repo( @pytest.mark.tier3 @pytest.mark.upgrade - def test_positive_export_complete_version_rh_repo( - self, target_sat, export_import_cleanup_module, module_entitlement_manifest_org - ): - """Export RedHat repo via complete version - - :id: e17898db-ca92-4121-a723-0d4b3cf120eb - - :expectedresults: Repository was successfully exported, exported files are - present on satellite machine - - :CaseLevel: System - """ - # Enable and sync RH repository - repo = _enable_rhel_content( - sat=target_sat, - org=module_entitlement_manifest_org, - repo_dict=REPOS['rhae2'], - ) - # Create cv and publish - cv_name = gen_string('alpha') - cv = make_content_view( - {'name': cv_name, 'organization-id': module_entitlement_manifest_org.id} - ) - ContentView.add_repository( - { - 'id': cv['id'], - 'organization-id': module_entitlement_manifest_org.id, - 'repository-id': repo['id'], - } - ) - ContentView.publish({'id': cv['id']}) - cv = ContentView.info({'id': cv['id']}) - assert len(cv['versions']) == 1 - cvv = cv['versions'][0] - # Verify export directory is empty - assert ( - target_sat.validate_pulp_filepath(module_entitlement_manifest_org, PULP_EXPORT_DIR) - == '' - ) - # Export content view - ContentExport.completeVersion( - {'id': cvv['id'], 'organization-id': module_entitlement_manifest_org.id} - ) - # Verify export directory is not empty - assert ( - target_sat.validate_pulp_filepath(module_entitlement_manifest_org, PULP_EXPORT_DIR) - != '' - ) - - @pytest.mark.tier3 - @pytest.mark.upgrade + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['rhae2'], + indirect=True, + ) def test_positive_export_complete_library_rh_repo( - self, export_import_cleanup_function, function_entitlement_manifest_org, target_sat + self, + target_sat, + export_import_cleanup_function, + function_sca_manifest_org, + function_synced_rhel_repo, ): """Export RedHat repo via complete library :id: ffae18bf-6536-4f11-8002-7bf1568bf7f1 + :parametrized: yes + + :setup: + 1. Enabled and synced RH repository. + + :steps: + 1. Create CV with the RH repo and publish. + 2. Export CV version contents to a directory. + :expectedresults: 1. Repository was successfully exported, exported files are present on satellite machine :CaseLevel: System """ - # Enable and sync RH repository - repo = _enable_rhel_content( - sat=target_sat, - org=function_entitlement_manifest_org, - repo_dict=REPOS['rhae2'], - ) # Create cv and publish cv_name = gen_string('alpha') - cv = make_content_view( - {'name': cv_name, 'organization-id': function_entitlement_manifest_org.id} - ) + cv = make_content_view({'name': cv_name, 'organization-id': function_sca_manifest_org.id}) ContentView.add_repository( { 'id': cv['id'], - 'organization-id': function_entitlement_manifest_org.id, - 'repository-id': repo['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], } ) ContentView.publish({'id': cv['id']}) # Verify export directory is empty - assert ( - target_sat.validate_pulp_filepath(function_entitlement_manifest_org, PULP_EXPORT_DIR) - == '' - ) + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' # Export content view - ContentExport.completeLibrary({'organization-id': function_entitlement_manifest_org.id}) + ContentExport.completeLibrary({'organization-id': function_sca_manifest_org.id}) # Verify export directory is not empty - assert ( - target_sat.validate_pulp_filepath(function_entitlement_manifest_org, PULP_EXPORT_DIR) - != '' - ) + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) != '' @pytest.mark.tier3 @pytest.mark.upgrade @@ -475,45 +486,6 @@ def _create_cv(cv_name, repo, module_org, publish=True): return content_view, cvv_id -def _enable_rhel_content(sat, org, repo_dict, ver=None, sync=True): - """Enable (and synchronize) rhel content - - :param sat: Satellite instance to work with - :param org: The organization directory into which the rhel contents will be enabled - :param repo_dict: The repository dict as defined in consts REPOS - :param bool sync: Syncs contents to repository if true else doesn't - :return: Repository cli object - """ - sat.cli.RepositorySet.enable( - { - 'organization-id': org.id, - 'name': repo_dict['reposet'], - 'product': repo_dict['product'], - 'releasever': ver or repo_dict.get('releasever', None), - 'basearch': DEFAULT_ARCHITECTURE, - } - ) - repo = sat.cli.Repository.info( - { - 'organization-id': org.id, - 'name': repo_dict['name'], - 'product': repo_dict['product'], - } - ) - # Update the download policy to 'immediate' and sync if required - sat.cli.Repository.update({'download-policy': 'immediate', 'id': repo['id']}) - if sync: - sat.cli.Repository.synchronize({'id': repo['id']}, timeout=7200000) - repo = sat.cli.Repository.info( - { - 'organization-id': org.id, - 'name': repo_dict['name'], - 'product': repo_dict['product'], - } - ) - return repo - - def _import_entities(product, repo, cv, mos='no'): """Sets same CV, product and repository in importing organization as exporting organization @@ -556,30 +528,28 @@ class TestContentViewSync: @pytest.mark.e2e def test_positive_export_import_cv_end_to_end( self, + target_sat, class_export_entities, config_export_import_settings, export_import_cleanup_module, - target_sat, module_org, + function_import_org, ): - """Export the CV and import it. Ensure that all content is same from - export to import + """Export the CV and import it. Ensure that all content is same from export to import. :id: b4fb9386-9b6a-4fc5-a8bf-96d7c80af93e - :steps: + :setup: + 1. Product with synced custom repository, published in a CV. - 1. Create product and repository with custom contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export CV version via complete version - 5. Import the exported files to satellite - 6. Check that content of export and import matches + :steps: + 1. Export CV version via complete version + 2. Import the exported files to satellite + 3. Check that content of export and import matches :expectedresults: - - 1. CV version custom contents has been exported to directory - 2. All The exported custom contents has been imported in org/satellite + 1. CV version custom contents has been exported to directory. + 2. All The exported custom contents has been imported in org/satellite. :CaseImportance: High @@ -594,47 +564,46 @@ def test_positive_export_import_cv_end_to_end( export_cvv_id = class_export_entities['exporting_cvv_id'] export_cv_description = class_export_entities['exporting_cv']['description'] import_cv_name = class_export_entities['exporting_cv_name'] - # check packages - exported_packages = Package.list({'content-view-version-id': export_cvv_id}) + # Check packages + exported_packages = target_sat.cli.Package.list({'content-view-version-id': export_cvv_id}) assert len(exported_packages) # Verify export directory is empty assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( + export = target_sat.cli.ContentExport.completeVersion( {'id': export_cvv_id, 'organization-id': module_org.id} ) import_path = target_sat.move_pulp_archive(module_org, export['message']) - - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # check that files are present in import_path + # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import files and verify content - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) - importing_cv = ContentView.info( - {'name': import_cv_name, 'organization-id': importing_org['id']} + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) + importing_cv = target_sat.cli.ContentView.info( + {'name': import_cv_name, 'organization-id': function_import_org.id} ) importing_cvv = importing_cv['versions'] assert importing_cv['description'] == export_cv_description assert len(importing_cvv) >= 1 - imported_packages = Package.list({'content-view-version-id': importing_cvv[0]['id']}) + imported_packages = target_sat.cli.Package.list( + {'content-view-version-id': importing_cvv[0]['id']} + ) assert len(imported_packages) assert len(exported_packages) == len(imported_packages) - exported_repo = Repository.info( + exported_repo = target_sat.cli.Repository.info( { 'name': export_repo_name, 'product': export_prod_name, 'organization-id': module_org.id, } ) - imported_repo = Repository.info( + imported_repo = target_sat.cli.Repository.info( { 'name': import_repo_name, 'product': import_prod_name, - 'organization-id': importing_org['id'], + 'organization-id': function_import_org.id, } ) for item in ['packages', 'source-rpms', 'package-groups', 'errata', 'module-streams']: @@ -642,102 +611,108 @@ def test_positive_export_import_cv_end_to_end( @pytest.mark.upgrade @pytest.mark.tier3 + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['rhae2'], + indirect=True, + ) def test_positive_export_import_default_org_view( self, + target_sat, export_import_cleanup_function, - function_org, config_export_import_settings, - target_sat, + function_sca_manifest_org, + function_import_org_with_manifest, + function_synced_custom_repo, + function_synced_rhel_repo, ): """Export Default Organization View version contents in directory and Import them. :id: b8a2c878-cfc2-491c-a71f-74108d6bc247 - :bz: 1671319 + :parametrized: yes - :customerscenario: true + :setup: + 1. Product with synced custom repository. + 2. Enabled and synced RH repository. :steps: - - 1. Create product and repository with custom contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export `Default Organization View version` contents to a directory - using complete library - 5. Import those contents from some other org/satellite. + 1. Create CV with the custom and RH repository. + 2. Export `Default Organization View version` contents using complete library. + 3. Import those contents from some other org/satellite. :expectedresults: + 1. Default Organization View version custom contents has been exported. + 2. All the exported custom contents has been imported in org/satellite. - 1. Default Organization View version custom contents has been exported to directory - 2. All The exported custom contents has been imported in org/satellite + :CaseLevel: System - :CaseImportance: High + :BZ: 1671319 - :CaseLevel: System + :customerscenario: true """ - importing_cv_name = DEFAULT_CV + # Create cv and publish cv_name = gen_string('alpha') - export_library = 'Export-Library' - # Create custom repo - product = make_product({'organization-id': function_org.id}) - repo = make_repository( + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} + ) + target_sat.cli.ContentView.add_repository( { - 'download-policy': 'immediate', - 'organization-id': function_org.id, - 'product-id': product['id'], + 'id': cv['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_custom_repo['id'], } ) - Repository.synchronize({'id': repo['id']}) - # Create cv and publish - cv = make_content_view({'name': cv_name, 'organization-id': function_org.id}) - ContentView.add_repository( + target_sat.cli.ContentView.add_repository( { 'id': cv['id'], - 'organization-id': function_org.id, - 'repository-id': repo['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], } ) - ContentView.publish({'id': cv['id']}) - content_view = ContentView.info( + target_sat.cli.ContentView.publish({'id': cv['id']}) + content_view = target_sat.cli.ContentView.info( { 'name': cv_name, - 'organization-id': function_org.id, + 'organization-id': function_sca_manifest_org.id, } ) # Verify packages default_cvv_id = content_view['versions'][0]['id'] - cv_packages = Package.list({'content-view-version-id': default_cvv_id}) + cv_packages = target_sat.cli.Package.list({'content-view-version-id': default_cvv_id}) assert len(cv_packages) # Verify export directory is empty - assert target_sat.validate_pulp_filepath(function_org, PULP_EXPORT_DIR) == '' + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' # Export complete library - export = ContentExport.completeLibrary({'organization-id': function_org.id}) + export = target_sat.cli.ContentExport.completeLibrary( + {'organization-id': function_sca_manifest_org.id} + ) # Verify 'export-library' is created and packages are there - import_path = target_sat.move_pulp_archive(function_org, export['message']) - export_lib_cv = ContentView.info( + import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message']) + export_lib_cv = target_sat.cli.ContentView.info( { - 'name': export_library, - 'organization-id': function_org.id, + 'name': EXPORT_LIBRARY_NAME, + 'organization-id': function_sca_manifest_org.id, } ) export_lib_cvv_id = export_lib_cv['versions'][0]['id'] - exported_lib_packages = Package.list({'content-view-version-id': export_lib_cvv_id}) - assert len(cv_packages) + exported_lib_packages = target_sat.cli.Package.list( + {'content-view-version-id': export_lib_cvv_id} + ) + assert len(exported_lib_packages) assert exported_lib_packages == cv_packages - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # check that files are present in import_path - result = target_sat.execute(f'ls {import_path}') - assert result.stdout != '' # Import and verify content of library - ContentImport.library({'organization-id': importing_org['id'], 'path': import_path}) - importing_cvv = ContentView.info( - {'name': importing_cv_name, 'organization-id': importing_org['id']} + target_sat.cli.Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) + target_sat.cli.ContentImport.library( + {'organization-id': function_import_org_with_manifest.id, 'path': import_path} + ) + importing_cvv = target_sat.cli.ContentView.info( + {'name': DEFAULT_CV, 'organization-id': function_import_org_with_manifest.id} )['versions'] assert len(importing_cvv) >= 1 - imported_packages = Package.list({'content-view-version-id': importing_cvv[0]['id']}) + imported_packages = target_sat.cli.Package.list( + {'content-view-version-id': importing_cvv[0]['id']} + ) assert len(imported_packages) assert len(cv_packages) == len(imported_packages) @@ -836,71 +811,71 @@ def test_positive_export_import_filtered_cvv( @pytest.mark.upgrade def test_positive_export_import_promoted_cv( self, + target_sat, class_export_entities, export_import_cleanup_module, config_export_import_settings, - target_sat, module_org, + function_import_org, ): """Export promoted CV version contents in directory and Import them. :id: 315ef1f0-e2ad-43ec-adff-453fb71654a7 - :steps: + :setup: + 1. Product with synced custom repository, published in a CV. - 1. Create product and repository with contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Promote the CV. - 5. Export CV version contents to a directory - 6. Import those contents from some other org/satellite. + :steps: + 1. Promote the CV. + 2. Export CV version contents to a directory. + 3. Import those contents from some other org/satellite. :expectedresults: - - 1. Promoted CV version contents has been exported to directory - 2. Promoted CV version contents has been imported successfully - 3. The imported CV should only be published and not promoted + 1. Promoted CV version contents has been exported to directory. + 2. Promoted CV version contents has been imported successfully. + 3. The imported CV should only be published and not promoted. :CaseLevel: System """ import_cv_name = class_export_entities['exporting_cv_name'] export_cv_id = class_export_entities['exporting_cv']['id'] export_cvv_id = class_export_entities['exporting_cvv_id'] - env = make_lifecycle_environment({'organization-id': module_org.id}) - ContentView.version_promote( + env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id}) + target_sat.cli.ContentView.version_promote( { 'id': export_cvv_id, 'to-lifecycle-environment-id': env['id'], } ) - promoted_cvv_id = ContentView.info({'id': export_cv_id})['versions'][-1]['id'] - # check packages - exported_packages = Package.list({'content-view-version-id': promoted_cvv_id}) + promoted_cvv_id = target_sat.cli.ContentView.info({'id': export_cv_id})['versions'][-1][ + 'id' + ] + # Check packages + exported_packages = target_sat.cli.Package.list( + {'content-view-version-id': promoted_cvv_id} + ) assert len(exported_packages) # Verify export directory is empty assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( + export = target_sat.cli.ContentExport.completeVersion( {'id': export_cvv_id, 'organization-id': module_org.id} ) import_path = target_sat.move_pulp_archive(module_org, export['message']) - - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # Move export files to import location and set permission - # Import and verify content - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) - importing_cv_id = ContentView.info( - {'name': import_cv_name, 'organization-id': importing_org['id']} + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} ) - importing_cvv_id = ContentView.info( - {'name': import_cv_name, 'organization-id': importing_org['id']} + importing_cv_id = target_sat.cli.ContentView.info( + {'name': import_cv_name, 'organization-id': function_import_org.id} + ) + importing_cvv_id = target_sat.cli.ContentView.info( + {'name': import_cv_name, 'organization-id': function_import_org.id} )['versions'] assert len(importing_cvv_id) >= 1 - imported_packages = Package.list({'content-view-version-id': importing_cvv_id[0]['id']}) + imported_packages = target_sat.cli.Package.list( + {'content-view-version-id': importing_cvv_id[0]['id']} + ) assert len(imported_packages) assert len(exported_packages) == len(imported_packages) # Verify the LCE is in Library @@ -910,30 +885,37 @@ def test_positive_export_import_promoted_cv( @pytest.mark.tier3 @pytest.mark.upgrade @pytest.mark.e2e + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['kickstart-rhel7', 'kickstart-rhel8_bos', 'rhscl7'], + indirect=True, + ) def test_positive_export_import_redhat_cv( self, + target_sat, export_import_cleanup_function, config_export_import_settings, - function_entitlement_manifest_org, - function_secondary_entitlement_manifest, - target_sat, + function_sca_manifest_org, + function_import_org_with_manifest, + function_synced_rhel_repo, ): - """Export CV version redhat contents in directory and Import them + """Export CV version with RedHat contents in directory and import them. :id: f6bd7fa9-396e-44ac-92a3-ab87ce1a7ef5 - :steps: + :parametrized: yes - 1. Enable product and repository with redhat contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export CV version contents to a directory - 5. Import those contents from some other org/satellite. + :setup: + 1. Enabled and synced RH repository. - :expectedresults: + :steps: + 1. Create CV with the RH repo and publish. + 2. Export CV version contents to a directory. + 3. Import those contents from some other org/satellite. - 1. CV version redhat contents has been exported to directory - 2. All The exported redhat contents has been imported in org/satellite + :expectedresults: + 1. CV version redhat contents has been exported to directory. + 2. All the exported redhat contents has been imported in org/satellite. :BZ: 1655239, 2040870 @@ -943,188 +925,62 @@ def test_positive_export_import_redhat_cv( :CaseLevel: System """ - # Enable and sync RH repository - repo = _enable_rhel_content( - sat=target_sat, - org=function_entitlement_manifest_org, - repo_dict=REPOS['kickstart']['rhel7'], - ver=REPOS['kickstart']['rhel7']['version'], - ) # Create cv and publish cv_name = gen_string('alpha') - cv = make_content_view( - {'name': cv_name, 'organization-id': function_entitlement_manifest_org.id} + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} ) - ContentView.add_repository( + target_sat.cli.ContentView.add_repository( { 'id': cv['id'], - 'organization-id': function_entitlement_manifest_org.id, - 'repository-id': repo['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], } ) - ContentView.publish({'id': cv['id']}) - cv = ContentView.info({'id': cv['id']}) + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) assert len(cv['versions']) == 1 cvv = cv['versions'][0] # Verify export directory is empty - assert ( - target_sat.validate_pulp_filepath(function_entitlement_manifest_org, PULP_EXPORT_DIR) - == '' - ) + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( - {'id': cvv['id'], 'organization-id': function_entitlement_manifest_org.id}, + export = target_sat.cli.ContentExport.completeVersion( + {'id': cvv['id'], 'organization-id': function_sca_manifest_org.id}, timeout=7200000, ) - import_path = target_sat.move_pulp_archive( - function_entitlement_manifest_org, export['message'] - ) - exported_packages = Package.list({'content-view-version-id': cvv['id']}) - assert len(exported_packages) - - # importing portion - importing_org = target_sat.api.Organization().create() - # check that files are present in import_path - result = target_sat.execute(f'ls {import_path}') - assert result.stdout != '' - target_sat.upload_manifest( - importing_org.id, - function_secondary_entitlement_manifest, - interface='CLI', - timeout=7200000, - ) - importing_org.sca_disable() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - ContentImport.version( - {'organization-id': importing_org.id, 'path': import_path}, timeout=7200000 - ) - # Import file and verify content - importing_cvv = ContentView.info({'name': cv_name, 'organization-id': importing_org.id})[ - 'versions' - ] - assert len(importing_cvv) >= 1 - imported_packages = Package.list({'content-view-version-id': importing_cvv[0]['id']}) - assert len(imported_packages) - assert len(exported_packages) == len(imported_packages) - exported_repo = Repository.info( - { - 'name': repo['name'], - 'product': repo['product']['name'], - 'organization-id': function_entitlement_manifest_org.id, - } - ) - imported_repo = Repository.info( - { - 'name': repo['name'], - 'product': repo['product']['name'], - 'organization-id': importing_org.id, - } - ) - for item in ['packages', 'source-rpms', 'package-groups', 'errata', 'module-streams']: - assert exported_repo['content-counts'][item] == imported_repo['content-counts'][item] - - @pytest.mark.tier4 - def test_positive_export_import_redhat_cv_with_huge_contents( - self, - export_import_cleanup_function, - config_export_import_settings, - target_sat, - function_entitlement_manifest_org, - function_secondary_entitlement_manifest, - ): - """Export CV version redhat contents in directory and Import them - - :id: 05eb185f-e526-466c-9c14-702dde1d49de - - :steps: - - 1. Enable product and repository with redhat repository having huge contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export CV version contents to a directory - 5. Import those contents from some other org/satellite. - - :expectedresults: - - 1. CV version redhat contents has been exported to directory - 2. All The exported redhat contents has been imported in org/satellite - - :BZ: 1655239 - - :CaseImportance: Critical + # Verify export directory is not empty + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) != '' - :CaseLevel: Acceptance - """ - # Enable and sync RH repository - repo = _enable_rhel_content( - sat=target_sat, - org=function_entitlement_manifest_org, - repo_dict=REPOS['rhscl7'], - ) - # Create cv and publish - cv_name = gen_string('alpha') - cv = make_content_view( - {'name': cv_name, 'organization-id': function_entitlement_manifest_org.id} - ) - ContentView.add_repository( - { - 'id': cv['id'], - 'organization-id': function_entitlement_manifest_org.id, - 'repository-id': repo['id'], - } - ) - ContentView.publish({'id': cv['id']}) - cv = ContentView.info({'id': cv['id']}) - assert len(cv['versions']) == 1 - cvv = cv['versions'][0] - # Export cv - export = ContentExport.completeVersion( - {'id': cvv['id'], 'organization-id': function_entitlement_manifest_org.id}, - timeout=7200000, - ) - import_path = target_sat.move_pulp_archive( - function_entitlement_manifest_org, export['message'] - ) - exported_packages = Package.list({'content-view-version-id': cvv['id']}) + import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message']) + exported_packages = target_sat.cli.Package.list({'content-view-version-id': cvv['id']}) assert len(exported_packages) - # importing portion - importing_org = target_sat.api.Organization().create() - # check that files are present in import_path - result = target_sat.execute(f'ls {import_path}') - assert result.stdout != '' # Import and verify content - target_sat.upload_manifest( - importing_org.id, - function_secondary_entitlement_manifest, - interface='CLI', + target_sat.cli.Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org_with_manifest.id, 'path': import_path}, timeout=7200000, ) - importing_org.sca_disable() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - ContentImport.version( - {'organization-id': importing_org.id, 'path': import_path}, timeout=7200000 - ) - importing_cvv = ContentView.info({'name': cv_name, 'organization-id': importing_org.id})[ - 'versions' - ] + importing_cvv = target_sat.cli.ContentView.info( + {'name': cv_name, 'organization-id': function_import_org_with_manifest.id} + )['versions'] assert len(importing_cvv) >= 1 - imported_packages = Package.list({'content-view-version-id': importing_cvv[0]['id']}) + imported_packages = target_sat.cli.Package.list( + {'content-view-version-id': importing_cvv[0]['id']} + ) assert len(imported_packages) assert len(exported_packages) == len(imported_packages) - exported_repo = Repository.info( + exported_repo = target_sat.cli.Repository.info( { - 'name': repo['name'], - 'product': repo['product']['name'], - 'organization-id': function_entitlement_manifest_org.id, + 'name': function_synced_rhel_repo['name'], + 'product': function_synced_rhel_repo['product']['name'], + 'organization-id': function_sca_manifest_org.id, } ) - imported_repo = Repository.info( + imported_repo = target_sat.cli.Repository.info( { - 'name': repo['name'], - 'product': repo['product']['name'], - 'organization-id': importing_org.id, + 'name': function_synced_rhel_repo['name'], + 'product': function_synced_rhel_repo['product']['name'], + 'organization-id': function_import_org_with_manifest.id, } ) for item in ['packages', 'source-rpms', 'package-groups', 'errata', 'module-streams']: @@ -1240,51 +1096,49 @@ def test_positive_export_cv_with_on_demand_repo( @pytest.mark.tier2 def test_negative_import_same_cv_twice( self, + target_sat, class_export_entities, export_import_cleanup_module, config_export_import_settings, - target_sat, module_org, + function_import_org, ): - """Import the same cv twice + """Import the same CV twice. :id: 15a7ddd3-c1a5-4b22-8460-6cb2b8ea4ef9 - :steps: + :setup: + 1. Product with synced custom repository, published in a CV. - 1. Create product and repository with custom contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export CV version contents to a directory - 5. Import those contents from some other org/satellite. - 6. Attempt to reimport the same contents + :steps: + 1. Export CV version contents to a directory. + 2. Import those contents from some other org/satellite. + 3. Attempt to reimport the same contents. :expectedresults: - - 1. Reimporting the contents with same version fails - 2. Satellite displays an error message + 1. Reimporting the contents with same version fails. + 2. Satellite displays an error message. """ export_cvv_id = class_export_entities['exporting_cvv_id'] export_cv_name = class_export_entities['exporting_cv_name'] # Verify export directory is empty assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( + export = target_sat.cli.ContentExport.completeVersion( {'id': export_cvv_id, 'organization-id': module_org.id} ) import_path = target_sat.move_pulp_archive(module_org, export['message']) - - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # check that files are present in import_path + # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import section - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) with pytest.raises(CLIReturnCodeError) as error: - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) assert ( f"Content View Version specified in the metadata - '{export_cv_name} 1.0' " 'already exists. If you wish to replace the existing version, ' @@ -1399,23 +1253,27 @@ def test_postive_export_cv_with_mixed_content_repos( assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) != '' @pytest.mark.tier3 - def test_postive_import_export_cv_with_file_content( - self, target_sat, config_export_import_settings, export_import_cleanup_module, module_org + def test_postive_export_import_cv_with_file_content( + self, + target_sat, + config_export_import_settings, + export_import_cleanup_module, + module_org, + function_import_org, ): """Exporting and Importing cv with file content :id: d00739f0-dedf-4303-8929-889dc23260a4 :steps: - 1. Create custom product and custom repo with file type 2. Sync repo 3. Create cv and add file repo created in step 1 and publish - 4. Export cv and import cv into another satellite - 5. Check imported cv has files in it + 4. Export cv and import cv into another satellite. + 5. Check imported cv has files in it. - :expectedresults: Imported cv should have the files present in the cv of - the imported system + :expectedresults: + 1. Imported cv should have the files present in the cv of the imported system. :BZ: 1995827 @@ -1423,8 +1281,8 @@ def test_postive_import_export_cv_with_file_content( """ # setup custom repo cv_name = import_cv_name = gen_string('alpha') - product = make_product({'organization-id': module_org.id}) - file_repo = make_repository( + product = target_sat.cli_factory.make_product({'organization-id': module_org.id}) + file_repo = target_sat.cli_factory.make_repository( { 'organization-id': module_org.id, 'product-id': product['id'], @@ -1432,73 +1290,74 @@ def test_postive_import_export_cv_with_file_content( 'url': settings.repos.file_type_repo.url, } ) - Repository.synchronize({'id': file_repo['id']}) + target_sat.cli.Repository.synchronize({'id': file_repo['id']}) # create cv and publish - cv = make_content_view({'name': cv_name, 'organization-id': module_org.id}) - ContentView.add_repository( + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': module_org.id} + ) + target_sat.cli.ContentView.add_repository( { 'id': cv['id'], 'organization-id': module_org.id, 'repository-id': file_repo['id'], } ) - ContentView.publish({'id': cv['id']}) - exporting_cv_id = ContentView.info({'id': cv['id']}) + target_sat.cli.ContentView.publish({'id': cv['id']}) + exporting_cv_id = target_sat.cli.ContentView.info({'id': cv['id']}) assert len(exporting_cv_id['versions']) == 1 exporting_cvv_id = exporting_cv_id['versions'][0]['id'] # check files - exported_files = File.list({'content-view-version-id': exporting_cvv_id}) + exported_files = target_sat.cli.File.list({'content-view-version-id': exporting_cvv_id}) assert len(exported_files) # Verify export directory is empty assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( + export = target_sat.cli.ContentExport.completeVersion( {'id': exporting_cvv_id, 'organization-id': module_org.id} ) import_path = target_sat.move_pulp_archive(module_org, export['message']) - - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # check that files are present in import_path + # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import files and verify content - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) - importing_cvv = ContentView.info( - {'name': import_cv_name, 'organization-id': importing_org['id']} + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) + importing_cvv = target_sat.cli.ContentView.info( + {'name': import_cv_name, 'organization-id': function_import_org.id} )['versions'] assert len(importing_cvv) >= 1 - imported_files = File.list({'content-view-version-id': importing_cvv[0]['id']}) + imported_files = target_sat.cli.File.list( + {'content-view-version-id': importing_cvv[0]['id']} + ) assert len(imported_files) assert len(exported_files) == len(imported_files) @pytest.mark.tier3 - def test_postive_import_export_ansible_collection_repo( + def test_postive_export_import_ansible_collection_repo( self, target_sat, config_export_import_settings, export_import_cleanup_function, function_org, + function_import_org, ): """Exporting and Importing library with ansible collection :id: 71dd1e1a-caad-48be-a180-206c8aa78639 :steps: + 1. Create custom product and custom repo with ansible collection. + 2. Sync the repo. + 3. Export library and import into another satellite. + 4. Check imported library has ansible collection in it. - 1. Create custom product and custom repo with ansible collection - 2. Sync repo - 3. Export library and import into another satellite - 4. Check imported library has ansible collection in it - - :expectedresults: Imported library should have the ansible collection present in the - imported product + :expectedresults: + 1. Imported library should have the ansible collection present in the imported product. """ # setup ansible_collection product and repo - export_product = make_product({'organization-id': function_org.id}) - ansible_repo = make_repository( + export_product = target_sat.cli_factory.make_product({'organization-id': function_org.id}) + ansible_repo = target_sat.cli_factory.make_repository( { 'organization-id': function_org.id, 'product-id': export_product['id'], @@ -1509,26 +1368,22 @@ def test_postive_import_export_ansible_collection_repo( { name: theforeman.operations, version: "0.1.0"} ]}', } ) - Repository.synchronize({'id': ansible_repo['id']}) + target_sat.cli.Repository.synchronize({'id': ansible_repo['id']}) # Export library - export = ContentExport.completeLibrary({'organization-id': function_org.id}) + export = target_sat.cli.ContentExport.completeLibrary({'organization-id': function_org.id}) import_path = target_sat.move_pulp_archive(function_org, export['message']) - - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - - # check that files are present in import_path + # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import files and verify content - ContentImport.library({'organization-id': importing_org['id'], 'path': import_path}) - assert Product.list({'organization-id': importing_org['id']}) - import_product = Product.info( + target_sat.cli.ContentImport.library( + {'organization-id': function_import_org.id, 'path': import_path} + ) + assert target_sat.cli.Product.list({'organization-id': function_import_org.id}) + import_product = target_sat.cli.Product.info( { - 'organization-id': importing_org['id'], - 'id': Product.list({'organization-id': importing_org['id']})[0]['id'], + 'organization-id': function_import_org.id, + 'id': Product.list({'organization-id': function_import_org.id})[0]['id'], } ) assert import_product['name'] == export_product['name'] @@ -1536,76 +1391,73 @@ def test_postive_import_export_ansible_collection_repo( assert import_product['content'][0]['content-type'] == "ansible_collection" @pytest.mark.tier3 + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['rhae2'], + indirect=True, + ) def test_negative_import_redhat_cv_without_manifest( self, + target_sat, export_import_cleanup_function, config_export_import_settings, - function_entitlement_manifest_org, - target_sat, + function_sca_manifest_org, + function_synced_rhel_repo, ): """Redhat content can't be imported into satellite/organization without manifest :id: b0f5f95b-3f9f-4827-84f1-b66517dc34f1 - :steps: + :parametrized: yes - 1. Enable product and repository with redhat contents. - 2. Sync the repository. - 3. Create CV with above product and publish. - 4. Export CV version contents to a directory - 5. Import those contents to other org without manifest. + :setup: + 1. Enabled and synced RH repository. - :expectedresults: + :steps: + 1. Create CV with the RH repo and publish. + 2. Export CV version contents to a directory. + 3. Import those contents to other org without manifest. + :expectedresults: 1. Import fails with message "Could not import the archive.: No manifest found. Import a manifest with the appropriate subscriptions before importing content." - """ - # Enable and sync RH repository - repo = _enable_rhel_content( - sat=target_sat, - org=function_entitlement_manifest_org, - repo_dict=REPOS['rhae2'], - ) # Create cv and publish cv_name = gen_string('alpha') - cv = make_content_view( - {'name': cv_name, 'organization-id': function_entitlement_manifest_org.id} + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} ) - ContentView.add_repository( + target_sat.cli.ContentView.add_repository( { 'id': cv['id'], - 'organization-id': function_entitlement_manifest_org.id, - 'repository-id': repo['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], } ) - ContentView.publish({'id': cv['id']}) - cv = ContentView.info({'id': cv['id']}) + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) assert len(cv['versions']) == 1 cvv = cv['versions'][0] # Verify export directory is empty - assert ( - target_sat.validate_pulp_filepath(function_entitlement_manifest_org, PULP_EXPORT_DIR) - == '' - ) + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( - {'id': cvv['id'], 'organization-id': function_entitlement_manifest_org.id} - ) - import_path = target_sat.move_pulp_archive( - function_entitlement_manifest_org, export['message'] + export = target_sat.cli.ContentExport.completeVersion( + {'id': cvv['id'], 'organization-id': function_sca_manifest_org.id} ) + import_path = target_sat.move_pulp_archive(function_sca_manifest_org, export['message']) # check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # importing portion - importing_org = make_org() + importing_org = target_sat.cli_factory.make_org() # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) + target_sat.cli.Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) with pytest.raises(CLIReturnCodeError) as error: - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) + target_sat.cli.ContentImport.version( + {'organization-id': importing_org['id'], 'path': import_path} + ) assert ( 'Could not import the archive.:\n No manifest found. Import a manifest with the ' 'appropriate subscriptions before importing content.' @@ -1614,25 +1466,27 @@ def test_negative_import_redhat_cv_without_manifest( @pytest.mark.tier2 def test_positive_import_content_for_disconnected_sat_with_existing_content( self, + target_sat, class_export_entities, config_export_import_settings, - target_sat, module_org, + function_import_org, ): """Import a content view into a disconnected satellite for an existing content view :id: 22c077dc-0041-4c6c-9da5-fd58e5497ae8 - :steps: + :setup: + 1. Product with synced custom repository, published in a CV. - 1. Sync a few repos - 2. Create a cv with the repo from 1 - 3. Run complete export - 4. On Disconnected satellite, create a cv with same name as cv on 2 and with - 'import-only' selected - 5. run import command + :steps: + 1. Run complete export of the CV. + 2. On Disconnected satellite, create a cv with same name as cv on 2 and with + 'import-only' selected. + 3. Run the import command. - :expectedresults: Import should run successfully + :expectedresults: + 1. Import should run successfully :bz: 2030101 @@ -1643,28 +1497,115 @@ def test_positive_import_content_for_disconnected_sat_with_existing_content( # Verify export directory is empty assert target_sat.validate_pulp_filepath(module_org, PULP_EXPORT_DIR) == '' # Export cv - export = ContentExport.completeVersion( + export = target_sat.cli.ContentExport.completeVersion( {'id': export_cvv_id, 'organization-id': module_org.id} ) import_path = target_sat.move_pulp_archive(module_org, export['message']) - # importing portion - importing_org = make_org() - # set disconnected mode - Settings.set({'name': 'subscription_connection_enabled', 'value': "No"}) - # check that files are present in import_path + # Check that files are present in import_path result = target_sat.execute(f'ls {import_path}') assert result.stdout != '' # Import section # Create cv with 'import-only' set to true - make_content_view( - {'name': export_cv_name, 'import-only': True, 'organization-id': importing_org['id']} + target_sat.cli_factory.make_content_view( + {'name': export_cv_name, 'import-only': True, 'organization-id': function_import_org.id} ) - ContentImport.version({'organization-id': importing_org['id'], 'path': import_path}) - importing_cvv = ContentView.info( - {'name': export_cv_name, 'organization-id': importing_org['id']} + target_sat.cli.ContentImport.version( + {'organization-id': function_import_org.id, 'path': import_path} + ) + importing_cvv = target_sat.cli.ContentView.info( + {'name': export_cv_name, 'organization-id': function_import_org.id} )['versions'] assert len(importing_cvv) >= 1 + @pytest.mark.tier3 + @pytest.mark.parametrize( + 'function_synced_rhel_repo', + ['rhae2'], + indirect=True, + ) + def test_positive_export_incremental_syncable_check_content( + self, + target_sat, + export_import_cleanup_function, + config_export_import_settings, + function_sca_manifest_org, + function_synced_rhel_repo, + ): + """Export complete and incremental CV version in syncable format and assert that all + files referenced in the repomd.xml (including productid) are present in the exports. + + :id: 6ff771cd-39ef-4865-8ae8-629f4baf5f98 + + :setup: + 1. Enabled and synced RH repository. + + :steps: + 1. Create a CV, add the product and publish it. + 2. Export complete syncable CV version. + 3. Publish new CV version. + 4. Export incremental syncable CV version. + 5. Verify the exports contain all files listed in the repomd.xml. + + :expectedresults: + 1. Complete and incremental export succeed. + 2. All files referenced in the repomd.xml files are present in the exports. + + :CaseLevel: System + + :BZ: 2212523 + + :customerscenario: true + """ + # Create cv and publish + cv_name = gen_string('alpha') + cv = target_sat.cli_factory.make_content_view( + {'name': cv_name, 'organization-id': function_sca_manifest_org.id} + ) + target_sat.cli.ContentView.add_repository( + { + 'id': cv['id'], + 'organization-id': function_sca_manifest_org.id, + 'repository-id': function_synced_rhel_repo['id'], + } + ) + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) + assert len(cv['versions']) == 1 + cvv = cv['versions'][0] + # Verify export directory is empty + assert target_sat.validate_pulp_filepath(function_sca_manifest_org, PULP_EXPORT_DIR) == '' + # Export complete and check the export directory + target_sat.cli.ContentExport.completeVersion({'id': cvv['id'], 'format': 'syncable'}) + assert '1.0' in target_sat.validate_pulp_filepath( + function_sca_manifest_org, PULP_EXPORT_DIR + ) + # Publish new CV version, export incremental and check the export directory + target_sat.cli.ContentView.publish({'id': cv['id']}) + cv = target_sat.cli.ContentView.info({'id': cv['id']}) + assert len(cv['versions']) == 2 + cvv = max(cv['versions'], key=lambda x: int(x['id'])) + target_sat.cli.ContentExport.incrementalVersion({'id': cvv['id'], 'format': 'syncable'}) + assert '2.0' in target_sat.validate_pulp_filepath( + function_sca_manifest_org, PULP_EXPORT_DIR + ) + # Verify that the content referenced in repomd.xml files is present in both exports + repomd_files = target_sat.execute( + f'find {PULP_EXPORT_DIR}{function_sca_manifest_org.name}/{cv_name}/ -name repomd.xml' + ).stdout.splitlines() + assert len(repomd_files) == 2, 'Unexpected count of exports identified.' + for repomd in repomd_files: + repodata_dir = os.path.split(repomd)[0] + repomd_refs = set( + target_sat.execute( + f'''grep -oP '(?<= Capsules - 2. Add the content view in the capsules - 3. Click on the synchronization and select the optimize sync. - 4. Optimize sync starts successfully - - :expectedresults: - 1. Optimize sync should be start and complete successfully. - 2. All the contents properly populate on the capsule side. - 3. Event of the optimize sync populated in the Monitors--> task section. - 4. Check the events in the log section. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_capsule_complete_sync(): - """ - Check the N-1 Capsule sync operation when the synchronization type is Complete. - - :id: b8f7ecbf-e359-495e-acd9-3e0ba44d8c12 - - :steps: - 1. Go to the infrastructure --> Capsules - 2. Add the content view in the capsules - 3. Click on the synchronization and select the complete sync. - 4. Complete Sync starts successfully - - :expectedresults: - 1. Optimize sync should be start and complete successfully. - 2. All the contents properly populate on the capsule side. - 3. Event of the optimize sync populated in the Monitors--> task section. - 4. Check the events in log section. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_content_update_on_capsule_registered_host(): - """ - Check the packages update on the capsule registered content host. - - :id: d331c36f-f69b-4504-89d7-f87c808b1c16 - - :steps: - 1. Go to the hosts --> Content-hosts - 2. Add the content view in the capsules - 3. Click on "Register Content host" - 4. Select the N-1 capsule and copy the command mentioned like - a. curl --insecure --output katello-ca-consumer-latest.noarch.rpm - https://capsule.com/pub/katello-ca-consumer-latest.noarch.rpm - b. yum localinstall katello-ca-consumer-latest.noarch.rpm - 5. Download the katello-ca-consumer certificate and install it on the content host. - 6. Check the Custom repository's contents. - 7. Check the Red Hat repositories contents. - 8. Install the katello-agent from the custom repo. - 9. Install few packages from Red Hat repository. - - :expectedresults: - 1. Content host should be registered successfully from N-1 Capsule. - 2. All the contents should be properly reflected on the registered host side.. - 3. Katello-agent package should be successfully installed via custom repo. - 4. Few Red Hat Packages should be successfully installed via Red Hat repo. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_provisioning_from_n_1_capsule(): - """ - Check the RHEL7/8 provisioning from N-1 Capsule. - - :id: c65e4812-c461-41b7-975a-6ac34f398232 - - :steps: - 1. Create the activation key of all the required RHEL8 contents. - 2. Create the DNS name, subnet, and hostgroup. - 3. Provision the RHEL8 host from the N-1 Capsule. - - :expectedresults: - 1. Host provisioned successfully. - 2. katello-agent and puppet agent packages should be installed after provisioning - 3. Provisioned host should be registered. - 4. Remote job should be executed on that provisioned host successfully. - 5. Host counts should be updated for the puppet environment. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_puppet_environment_import(): - """ - Check the puppet environment import from satellite and N-1 capsule - - :id: 59facd73-60be-4eb0-b389-4d2ae6886c35 - - :steps: - 1. import the puppet environment from satellite. - 2. import the puppet environment from N-1 capsule. - - :expectedresults: - 1. Puppet environment should be imported successfully from satellite - as well as capsule. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_puppet_fact_update(): - """ - Verify the facts successfully fetched from the N-1 Capsule's provisioned host - - :id: dc15da39-c75d-4f1b-8590-3df36c6531de - - :steps: - 1. Register host with N-1 Capsule content source. - 2. Add the activation key with tool report. - 3. Install the puppte agent on the content host. - 4. Update some puppet facts in the smart class - - :expectedresults: - 1. Changed facts should be reflected on the content host - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def test_ansible_role_import(): - """ - Check the Ansible import operation from N-1 capsule - - :id: 8be51495-2398-45eb-a192-24a4ea09a1d7 - - :steps: - 1. Import ansible roles from N-1 capsule. - - :expectedresults: - 1. Roles import should work from N-1 Capsule. - """ - - -@pytest.mark.stubbed -@pytest.mark.tier3 -def rex_job_execution_from_n_1_capsule(): - """ - Check the updated ansible templates should work as expected from content-host - (part of n-1 capsule). - - :id: d5f4ab23-109f-43f4-934a-cc8f948211f1 - - :steps: - 1. Update the ansible template. - 2. Run the ansible roles on N-1 registered content host - - :expectedresults: - 1. Ansible job should be completed successfully. - """ diff --git a/tests/foreman/longrun/test_oscap.py b/tests/foreman/longrun/test_oscap.py index a7f163c2829..3d292092c86 100644 --- a/tests/foreman/longrun/test_oscap.py +++ b/tests/foreman/longrun/test_oscap.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,28 +16,28 @@ :Upstream: No """ -import pytest from broker import Broker from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.ansible import Ansible from robottelo.cli.arfreport import Arfreport -from robottelo.cli.factory import make_hostgroup -from robottelo.cli.factory import make_scap_policy +from robottelo.cli.factory import make_hostgroup, make_scap_policy from robottelo.cli.host import Host from robottelo.cli.job_invocation import JobInvocation from robottelo.cli.proxy import Proxy from robottelo.cli.scapcontent import Scapcontent from robottelo.config import settings -from robottelo.constants import OSCAP_DEFAULT_CONTENT -from robottelo.constants import OSCAP_PERIOD -from robottelo.constants import OSCAP_PROFILE -from robottelo.constants import OSCAP_WEEKDAY +from robottelo.constants import ( + OSCAP_DEFAULT_CONTENT, + OSCAP_PERIOD, + OSCAP_PROFILE, + OSCAP_WEEKDAY, +) from robottelo.exceptions import ProxyError from robottelo.hosts import ContentHost - rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] rhel8_content = OSCAP_DEFAULT_CONTENT['rhel8_content'] diff --git a/tests/foreman/longrun/test_provisioning_computeresource.py b/tests/foreman/longrun/test_provisioning_computeresource.py index 3825a2c6e93..65444304df0 100644 --- a/tests/foreman/longrun/test_provisioning_computeresource.py +++ b/tests/foreman/longrun/test_provisioning_computeresource.py @@ -11,16 +11,14 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from wrapanapi import VMWareSystem -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.factory import make_host +from robottelo.cli.factory import make_compute_resource, make_host from robottelo.cli.host import Host from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import VMWARE_CONSTANTS +from robottelo.constants import FOREMAN_PROVIDERS, VMWARE_CONSTANTS @pytest.fixture(scope="module") diff --git a/tests/foreman/maintain/test_advanced.py b/tests/foreman/maintain/test_advanced.py index 49faf4e4730..279ce48c4eb 100644 --- a/tests/foreman/maintain/test_advanced.py +++ b/tests/foreman/maintain/test_advanced.py @@ -19,70 +19,25 @@ import pytest import yaml -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings -from robottelo.constants import MAINTAIN_HAMMER_YML - -pytestmark = pytest.mark.destructive - - -# Common repositories for Satellite and Capsule -common_repos = ['rhel-8-for-x86_64-baseos-rpms', 'rhel-8-for-x86_64-appstream-rpms'] - -# Satellite repositories -sat_611_repos = [ - 'satellite-6.11-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.11-for-rhel-8-x86_64-rpms', -] + common_repos - -sat_612_repos = [ - 'satellite-6.12-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.12-for-rhel-8-x86_64-rpms', -] + common_repos - -sat_613_repos = [ - 'satellite-6.13-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.13-for-rhel-8-x86_64-rpms', -] + common_repos - -sat_614_repos = [ - 'satellite-6.14-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.14-for-rhel-8-x86_64-rpms', -] + common_repos - -# Capsule repositories -cap_611_repos = [ - 'satellite-capsule-6.11-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.11-for-rhel-8-x86_64-rpms', -] + common_repos - -cap_612_repos = [ - 'satellite-capsule-6.12-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.12-for-rhel-8-x86_64-rpms', -] + common_repos - -cap_613_repos = [ - 'satellite-capsule-6.13-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.13-for-rhel-8-x86_64-rpms', -] + common_repos - -cap_614_repos = [ - 'satellite-capsule-6.14-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6.14-for-rhel-8-x86_64-rpms', -] + common_repos - -sat_repos = { - '6.11': sat_611_repos, - '6.12': sat_612_repos, - '6.13': sat_613_repos, - '6.14': sat_614_repos, -} -cap_repos = { - '6.11': cap_611_repos, - '6.12': cap_612_repos, - '6.13': cap_613_repos, - '6.14': cap_614_repos, -} +from robottelo.config import robottelo_tmp_dir, settings +from robottelo.constants import MAINTAIN_HAMMER_YML, SAT_NON_GA_VERSIONS +from robottelo.hosts import get_sat_rhel_version, get_sat_version + +sat_x_y_release = f'{get_sat_version().major}.{get_sat_version().minor}' + + +def get_satellite_capsule_repos( + x_y_release=sat_x_y_release, product='satellite', os_major_ver=get_sat_rhel_version().major +): + if product == 'capsule': + product = 'satellite-capsule' + repos = [ + f'{product}-{x_y_release}-for-rhel-{os_major_ver}-x86_64-rpms', + f'satellite-maintenance-{x_y_release}-for-rhel-{os_major_ver}-x86_64-rpms', + f'rhel-{os_major_ver}-for-x86_64-baseos-rpms', + f'rhel-{os_major_ver}-for-x86_64-appstream-rpms', + ] + return repos def test_positive_advanced_run_service_restart(sat_maintain): @@ -299,7 +254,7 @@ def test_positive_sync_plan_with_hammer_defaults(request, sat_maintain, module_o :customerscenario: true """ - sat_maintain.cli.Defaults.add({'param-name': 'organization_id', 'param-value': 1}) + sat_maintain.cli.Defaults.add({'param-name': 'organization_id', 'param-value': module_org.id}) sync_plans = [] for name in ['plan1', 'plan2']: @@ -321,6 +276,11 @@ def test_positive_sync_plan_with_hammer_defaults(request, sat_maintain, module_o def _finalize(): sat_maintain.cli.Defaults.delete({'param-name': 'organization_id'}) sync_plans[1].delete() + sync_plan = sat_maintain.api.SyncPlan(organization=module_org.id).search( + query={'search': f'name="{sync_plans[0]}"'} + ) + if sync_plan: + sync_plans[0].delete() @pytest.mark.e2e @@ -336,21 +296,21 @@ def test_positive_satellite_repositories_setup(sat_maintain): :expectedresults: Required Satellite repositories for install/upgrade should get enabled """ - supported_versions = ['6.11', '6.12', '6.13'] - for ver in supported_versions: - result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': ver}) + sat_version = ".".join(sat_maintain.version.split('.')[0:2]) + result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': sat_version}) + if sat_version not in SAT_NON_GA_VERSIONS: assert result.status == 0 assert 'FAIL' not in result.stdout result = sat_maintain.execute('yum repolist') - for repo in sat_repos[ver]: + for repo in get_satellite_capsule_repos(sat_version): assert repo in result.stdout - # 6.14 till not GA - result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': '6.14'}) - assert result.status == 1 - assert 'FAIL' in result.stdout - for repo in sat_repos['6.14']: - assert repo in result.stdout + # for non-ga versions + else: + assert result.status == 1 + assert 'FAIL' in result.stdout + for repo in get_satellite_capsule_repos(sat_version): + assert repo in result.stdout @pytest.mark.e2e @@ -369,36 +329,17 @@ def test_positive_capsule_repositories_setup(sat_maintain): :expectedresults: Required Capsule repositories should get enabled """ - supported_versions = ['6.11', '6.12'] - for ver in supported_versions: - result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': ver}) + sat_version = ".".join(sat_maintain.version.split('.')[0:2]) + result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': sat_version}) + if sat_version not in SAT_NON_GA_VERSIONS: assert result.status == 0 assert 'FAIL' not in result.stdout result = sat_maintain.execute('yum repolist') - for repo in cap_repos[ver]: + for repo in get_satellite_capsule_repos(sat_version, 'capsule'): + assert repo in result.stdout + # for non-ga versions + else: + assert result.status == 1 + assert 'FAIL' in result.stdout + for repo in get_satellite_capsule_repos(sat_version, 'capsule'): assert repo in result.stdout - - # 6.13 till not GA - result = sat_maintain.cli.Advanced.run_repositories_setup(options={'version': '6.13'}) - assert result.status == 1 - assert 'FAIL' in result.stdout - for repo in cap_repos['6.13']: - assert repo in result.stdout - - # Verify that all required beta repositories gets enabled - # maintain beta repo is unavailable for EL8 https://bugzilla.redhat.com/show_bug.cgi?id=2106750 - cap_beta_repo = common_repos - missing_beta_el8_repos = [ - 'satellite-capsule-6-beta-for-rhel-8-x86_64-rpms', - 'satellite-maintenance-6-beta-for-rhel-8-x86_64-rpms', - ] - result = sat_maintain.cli.Advanced.run_repositories_setup( - options={'version': '6.12'}, env_var='FOREMAN_MAINTAIN_USE_BETA=1' - ) - assert result.status != 0 - assert 'FAIL' in result.stdout - for repo in missing_beta_el8_repos: - assert f"Error: '{repo}' does not match a valid repository ID" in result.stdout - result = sat_maintain.execute('yum repolist') - for repo in cap_beta_repo: - assert repo in result.stdout diff --git a/tests/foreman/maintain/test_backup_restore.py b/tests/foreman/maintain/test_backup_restore.py index 90e4a2c3cf3..473f768fa74 100644 --- a/tests/foreman/maintain/test_backup_restore.py +++ b/tests/foreman/maintain/test_backup_restore.py @@ -18,8 +18,8 @@ """ import re -import pytest from fauxfactory import gen_string +import pytest from robottelo import constants from robottelo.config import settings @@ -33,10 +33,10 @@ BASIC_FILES = {"config_files.tar.gz", ".config.snar", "metadata.yml"} +OFFLINE_FILES = {"pgsql_data.tar.gz", ".postgres.snar"} | BASIC_FILES +ONLINE_SAT_FILES = {"candlepin.dump", "foreman.dump", "pulpcore.dump"} | BASIC_FILES +ONLINE_CAPS_FILES = {"pulpcore.dump"} | BASIC_FILES CONTENT_FILES = {"pulp_data.tar", ".pulp.snar"} -OFFLINE_FILES = {"pgsql_data.tar.gz", ".postgres.snar"} -ONLINE_SAT_FILES = {"candlepin.dump", "foreman.dump", "pulpcore.dump"} -ONLINE_CAPS_FILES = {"pulpcore.dump"} NODIR_MSG = "ERROR: parameter 'BACKUP_DIR': no value provided" @@ -46,22 +46,18 @@ assert_msg = "Some required backup files are missing" -def get_exp_files(sat_maintain, backup_type): +def get_exp_files(sat_maintain, backup_type, skip_pulp=False): if type(sat_maintain) is Satellite: - if sat_maintain.is_remote_db(): - expected_files = BASIC_FILES | ONLINE_SAT_FILES - else: - expected_files = ( - BASIC_FILES | OFFLINE_FILES - if backup_type == 'offline' - else BASIC_FILES | ONLINE_SAT_FILES - ) - else: + # for remote db you get always online backup regardless specified backup type expected_files = ( - BASIC_FILES | OFFLINE_FILES - if backup_type == 'offline' - else BASIC_FILES | ONLINE_CAPS_FILES + ONLINE_SAT_FILES + if backup_type == 'online' or sat_maintain.is_remote_db() + else OFFLINE_FILES ) + else: + expected_files = ONLINE_CAPS_FILES if backup_type == 'online' else OFFLINE_FILES + if not skip_pulp: + expected_files = expected_files | CONTENT_FILES return expected_files @@ -101,7 +97,7 @@ def test_positive_backup_preserve_directory( files = [i for i in files if not re.compile(r'^\.*$').search(i)] expected_files = get_exp_files(sat_maintain, backup_type) - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + assert set(files).issuperset(expected_files), assert_msg @pytest.mark.include_capsule @@ -149,7 +145,7 @@ def test_positive_backup_split_pulp_tar( files = [i for i in files if not re.compile(r'^\.*$').search(i)] expected_files = get_exp_files(sat_maintain, backup_type) - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + assert set(files).issuperset(expected_files), assert_msg # Check the split works result = sat_maintain.execute(f'du {backup_dir}/pulp_data.tar') @@ -193,7 +189,7 @@ def test_positive_backup_capsule_features( files = [i for i in files if not re.compile(r'^\.*$').search(i)] expected_files = get_exp_files(sat_maintain, backup_type) - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + assert set(files).issuperset(expected_files), assert_msg @pytest.mark.include_capsule @@ -276,12 +272,12 @@ def test_positive_backup_offline_logical(sat_maintain, setup_backup_tests, modul if type(sat_maintain) is Satellite: if sat_maintain.is_remote_db(): - expected_files = BASIC_FILES | ONLINE_SAT_FILES + expected_files = ONLINE_SAT_FILES | CONTENT_FILES else: - expected_files = BASIC_FILES | OFFLINE_FILES | ONLINE_SAT_FILES + expected_files = OFFLINE_FILES | ONLINE_SAT_FILES | CONTENT_FILES else: - expected_files = BASIC_FILES | OFFLINE_FILES | ONLINE_CAPS_FILES - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + expected_files = OFFLINE_FILES | ONLINE_CAPS_FILES | CONTENT_FILES + assert set(files).issuperset(expected_files), assert_msg @pytest.mark.include_capsule @@ -448,7 +444,7 @@ def test_positive_puppet_backup_restore( files = [i for i in files if not re.compile(r'^\.*$').search(i)] expected_files = get_exp_files(sat_maintain, backup_type) - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + assert set(files).issuperset(expected_files), assert_msg # Run restore sat_maintain.execute('rm -rf /var/lib/pulp/media/artifact') @@ -523,6 +519,7 @@ def test_positive_backup_restore( backup_dir=subdir, backup_type=backup_type, options={'assumeyes': True, 'plaintext': True, 'skip-pulp-content': skip_pulp}, + timeout='30m', ) assert result.status == 0 assert 'FAIL' not in result.stdout @@ -532,11 +529,8 @@ def test_positive_backup_restore( files = sat_maintain.execute(f'ls -a {backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] - expected_files = get_exp_files(sat_maintain, backup_type) - if not skip_pulp: - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg - else: - assert set(files).issuperset(expected_files), assert_msg + expected_files = get_exp_files(sat_maintain, backup_type, skip_pulp) + assert set(files).issuperset(expected_files), assert_msg # Run restore if not skip_pulp: @@ -638,10 +632,8 @@ def test_positive_backup_restore_incremental( files = sat_maintain.execute(f'ls -a {inc_backup_dir}').stdout.split('\n') files = [i for i in files if not re.compile(r'^\.*$').search(i)] - expected_files = ( - BASIC_FILES | OFFLINE_FILES if backup_type == 'offline' else BASIC_FILES | ONLINE_SAT_FILES - ) - assert set(files).issuperset(expected_files | CONTENT_FILES), assert_msg + expected_files = get_exp_files(sat_maintain, backup_type) + assert set(files).issuperset(expected_files), assert_msg # restore initial backup and check system health result = sat_maintain.cli.Restore.run( diff --git a/tests/foreman/maintain/test_health.py b/tests/foreman/maintain/test_health.py index ae3d45435c1..c1d590546ec 100644 --- a/tests/foreman/maintain/test_health.py +++ b/tests/foreman/maintain/test_health.py @@ -18,11 +18,11 @@ """ import time -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings - +from robottelo.utils.installer import InstallerCommand upstream_url = { 'foreman_repo': 'https://yum.theforeman.org/releases/nightly/el8/x86_64/', @@ -165,7 +165,8 @@ def test_positive_health_check_server_ping(sat_maintain): assert 'FAIL' not in result.stdout -def test_health_check_server_ping(sat_maintain, request): +@pytest.mark.usefixtures('start_satellite_services') +def test_health_check_server_ping(sat_maintain): """Verify health check server-ping :id: ecdc5bfb-2adf-49f6-948d-995dae34bcd3 @@ -185,10 +186,6 @@ def test_health_check_server_ping(sat_maintain, request): assert result.status == 0 assert 'FAIL' in result.stdout - @request.addfinalizer - def _finalize(): - assert sat_maintain.cli.Service.start().status == 0 - @pytest.mark.include_capsule def test_negative_health_check_upstream_repository(sat_maintain, request): @@ -225,7 +222,6 @@ def _finalize(): sat_maintain.execute('dnf clean all') -@pytest.mark.include_capsule def test_positive_health_check_available_space(sat_maintain): """Verify available-space check @@ -548,8 +544,7 @@ def test_positive_health_check_env_proxy(sat_maintain): assert 'FAIL' not in result.stdout -@pytest.mark.stubbed -def test_positive_health_check_foreman_proxy_verify_dhcp_config_syntax(): +def test_positive_health_check_foreman_proxy_verify_dhcp_config_syntax(sat_maintain): """Verify foreman-proxy-verify-dhcp-config-syntax :id: 43ca5cc7-9888-490d-b1ba-f3298e737039 @@ -573,8 +568,52 @@ def test_positive_health_check_foreman_proxy_verify_dhcp_config_syntax(): :CaseImportance: Medium - :CaseAutomation: NotAutomated + :CaseAutomation: Automated """ + # Set dhcp.yml to `:use_provider: dhcp_isc` + sat_maintain.execute( + r"sed -i '/:use_provider: dhcp_infoblox/c\:use_provider: dhcp_isc'" + " /etc/foreman-proxy/settings.d/dhcp.yml" + ) + result = sat_maintain.execute("cat /etc/foreman-proxy/settings.d/dhcp.yml") + assert ':use_provider: dhcp_isc' in result.stdout + # Run health list and check and verify nothing comes back + result = sat_maintain.cli.Health.list() + assert 'foreman-proxy-verify-dhcp-config-syntax' not in result.stdout + result = sat_maintain.cli.Health.check( + options={'label': 'foreman-proxy-verify-dhcp-config-syntax'} + ) + assert ( + 'No scenario matching label' and 'foreman-proxy-verify-dhcp-config-syntax' in result.stdout + ) + # Enable DHCP + installer = sat_maintain.install( + InstallerCommand('enable-foreman-proxy-plugin-dhcp-remote-isc', 'foreman-proxy-dhcp true') + ) + assert 'Success!' in installer.stdout + # Run health list and check and verify check is made + result = sat_maintain.cli.Health.list() + assert 'foreman-proxy-verify-dhcp-config-syntax' in result.stdout + result = sat_maintain.cli.Health.check( + options={'label': 'foreman-proxy-verify-dhcp-config-syntax'} + ) + assert 'OK' in result.stdout + # Set dhcp.yml `:use_provider: dhcp_infoblox` + sat_maintain.execute( + r"sed -i '/:use_provider: dhcp_isc/c\:use_provider: dhcp_infoblox'" + " /etc/foreman-proxy/settings.d/dhcp.yml" + ) + result = sat_maintain.execute("cat /etc/foreman-proxy/settings.d/dhcp.yml") + assert ':use_provider: dhcp_infoblox' in result.stdout + # Run health list and check and verify nothing comes back + result = sat_maintain.cli.Health.list() + assert 'foreman-proxy-verify-dhcp-config-syntax' not in result.stdout + result = sat_maintain.cli.Health.check( + options={'label': 'foreman-proxy-verify-dhcp-config-syntax'} + ) + assert ( + 'No scenario matching label' and 'foreman-proxy-verify-dhcp-config-syntax' in result.stdout + ) def test_positive_remove_job_file(sat_maintain): diff --git a/tests/foreman/maintain/test_maintenance_mode.py b/tests/foreman/maintain/test_maintenance_mode.py index 8f24e62281a..f72ac4468d0 100644 --- a/tests/foreman/maintain/test_maintenance_mode.py +++ b/tests/foreman/maintain/test_maintenance_mode.py @@ -21,8 +21,6 @@ from robottelo.config import robottelo_tmp_dir -pytestmark = pytest.mark.destructive - @pytest.mark.e2e @pytest.mark.tier2 diff --git a/tests/foreman/maintain/test_service.py b/tests/foreman/maintain/test_service.py index 510c0d0a017..99bb6074ae5 100644 --- a/tests/foreman/maintain/test_service.py +++ b/tests/foreman/maintain/test_service.py @@ -16,17 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.constants import HAMMER_CONFIG -from robottelo.constants import MAINTAIN_HAMMER_YML -from robottelo.constants import SATELLITE_ANSWER_FILE +from robottelo.constants import ( + HAMMER_CONFIG, + MAINTAIN_HAMMER_YML, + SATELLITE_ANSWER_FILE, +) from robottelo.hosts import Satellite -pytestmark = pytest.mark.destructive - SATELLITE_SERVICES = [ "dynflow-sidekiq@.service", "foreman-proxy.service", @@ -94,6 +94,7 @@ def test_positive_service_list(sat_maintain): @pytest.mark.include_capsule +@pytest.mark.usefixtures('start_satellite_services') def test_positive_service_stop_start(sat_maintain): """Start/Stop services using satellite-maintain service subcommand @@ -123,7 +124,10 @@ def test_positive_service_stop_start(sat_maintain): assert result.status == 0 +@pytest.mark.stream +@pytest.mark.upgrade @pytest.mark.include_capsule +@pytest.mark.usefixtures('start_satellite_services') def test_positive_service_stop_restart(sat_maintain): """Disable services using satellite-maintain service @@ -156,6 +160,7 @@ def test_positive_service_stop_restart(sat_maintain): @pytest.mark.include_capsule +@pytest.mark.usefixtures('start_satellite_services') def test_positive_service_enable_disable(sat_maintain): """Enable/Disable services using satellite-maintain service subcommand @@ -180,7 +185,8 @@ def test_positive_service_enable_disable(sat_maintain): assert result.status == 0 -def test_positive_foreman_service(request, sat_maintain): +@pytest.mark.usefixtures('start_satellite_services') +def test_positive_foreman_service(sat_maintain): """Validate httpd service should work as expected even stopping of the foreman service :id: 08a29ea2-2e49-11eb-a22b-d46d6dd3b5b2 @@ -201,10 +207,7 @@ def test_positive_foreman_service(request, sat_maintain): result = sat_maintain.cli.Health.check(options={'assumeyes': True}) assert result.status == 0 assert 'foreman' in result.stdout - - @request.addfinalizer - def _finalize(): - assert sat_maintain.cli.Service.start(options={'only': 'foreman'}).status == 0 + assert sat_maintain.cli.Service.start(options={'only': 'foreman'}).status == 0 @pytest.mark.include_capsule @@ -216,11 +219,11 @@ def test_positive_status_clocale(sat_maintain): :parametrized: yes :steps: - 1. Run LC_ALL=C satellite-maintain service stop + 1. Run LC_ALL=C.UTF-8 satellite-maintain service status :expectedresults: service status works with C locale """ - assert sat_maintain.cli.Service.status(env_var='LC_ALL=C').status == 0 + assert sat_maintain.cli.Service.status(env_var='LC_ALL=C.UTF-8').status == 0 def test_positive_service_restart_without_hammer_config(missing_hammer_config, sat_maintain): diff --git a/tests/foreman/maintain/test_upgrade.py b/tests/foreman/maintain/test_upgrade.py index dd27db6577e..c9b6044f44c 100644 --- a/tests/foreman/maintain/test_upgrade.py +++ b/tests/foreman/maintain/test_upgrade.py @@ -16,13 +16,10 @@ :Upstream: No """ -import re - import pytest from robottelo.config import settings - -pytestmark = pytest.mark.destructive +from robottelo.constants import SATELLITE_VERSION def last_y_stream_version(release): @@ -67,15 +64,15 @@ def test_positive_satellite_maintain_upgrade_list(sat_maintain): result = sat_maintain.cli.Upgrade.list_versions() assert result.status == 0 assert 'FAIL' not in result.stdout - # If on stream, check there is no version listed - if sat_maintain.is_stream: - assert not bool(re.search(r'\d', result.stdout)) - else: - for ver in versions: - assert ver in result.stdout + for ver in versions: + assert ver in result.stdout @pytest.mark.include_capsule +@pytest.mark.skipif( + (settings.server.version.release == 'stream'), + reason='Upgrade path is not available for stream yet', +) def test_positive_repositories_validate(sat_maintain): """Test repositories-validate pre-upgrade check is skipped when system is subscribed using custom activationkey. @@ -116,6 +113,10 @@ def test_positive_repositories_validate(sat_maintain): ids=['default', 'medium'], indirect=True, ) +@pytest.mark.skipif( + (settings.server.version.release == 'stream'), + reason='Upgrade path is not available for stream yet', +) def test_negative_pre_upgrade_tuning_profile_check(request, custom_host): """Negative test that verifies a satellite with less than tuning profile hardware requirements fails on pre-upgrade check. @@ -134,7 +135,9 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host): # Register to CDN for RHEL8 repos, download and enable last y stream's ohsnap repos, # and enable the satellite module and install it on the host custom_host.register_to_cdn() - last_y_stream = last_y_stream_version(settings.server.version.release) + last_y_stream = last_y_stream_version( + SATELLITE_VERSION if sat_version == 'stream' else sat_version + ) custom_host.download_repofile(product='satellite', release=last_y_stream) custom_host.execute('dnf -y module enable satellite:el8 && dnf -y install satellite') # Install without system checks to get around installer checks @@ -143,7 +146,9 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host): timeout='30m', ) # Get current Satellite version's repofile - custom_host.download_repofile(product='satellite', release=sat_version) + custom_host.download_repofile( + product='satellite', release=sat_version, snap=settings.server.version.snap + ) # Run satellite-maintain to have it self update to the newest version, # however, this will not actually execute the command after updating custom_host.execute('satellite-maintain upgrade list-versions') diff --git a/tests/foreman/sys/test_fam.py b/tests/foreman/sys/test_fam.py index 7a41ffba451..aeab1f2cc4c 100644 --- a/tests/foreman/sys/test_fam.py +++ b/tests/foreman/sys/test_fam.py @@ -18,9 +18,7 @@ """ import pytest -from robottelo.constants import FAM_MODULE_PATH -from robottelo.constants import FOREMAN_ANSIBLE_MODULES -from robottelo.constants import RH_SAT_ROLES +from robottelo.constants import FAM_MODULE_PATH, FOREMAN_ANSIBLE_MODULES, RH_SAT_ROLES @pytest.fixture diff --git a/tests/foreman/sys/test_katello_certs_check.py b/tests/foreman/sys/test_katello_certs_check.py index 073f7b22fb1..f058328e2e4 100644 --- a/tests/foreman/sys/test_katello_certs_check.py +++ b/tests/foreman/sys/test_katello_certs_check.py @@ -43,7 +43,11 @@ def test_positive_install_sat_with_katello_certs(certs_data, sat_ready_rhel): :CaseAutomation: Automated """ - sat_ready_rhel.download_repofile(product='satellite', release=settings.server.version.release) + sat_ready_rhel.download_repofile( + product='satellite', + release=settings.server.version.release, + snap=settings.server.version.snap, + ) sat_ready_rhel.register_to_cdn() sat_ready_rhel.execute('dnf -y update') result = sat_ready_rhel.execute( diff --git a/tests/foreman/sys/test_pulp3_filesystem.py b/tests/foreman/sys/test_pulp3_filesystem.py index ab24ca52e17..1e868cd691f 100644 --- a/tests/foreman/sys/test_pulp3_filesystem.py +++ b/tests/foreman/sys/test_pulp3_filesystem.py @@ -16,8 +16,8 @@ :Upstream: No """ -import json from datetime import datetime +import json import pytest diff --git a/tests/foreman/ui/test_activationkey.py b/tests/foreman/ui/test_activationkey.py index 0474fbcdd18..2f50eca2d10 100644 --- a/tests/foreman/ui/test_activationkey.py +++ b/tests/foreman/ui/test_activationkey.py @@ -18,18 +18,17 @@ """ import random -import pytest from airgun.session import Session from broker import Broker from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo import constants from robottelo.cli.factory import setup_org_for_a_custom_repo from robottelo.config import settings from robottelo.hosts import ContentHost -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_data_list +from robottelo.utils.datafactory import parametrized, valid_data_list @pytest.mark.e2e diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index 866ad4da049..378552b5dc5 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -16,13 +16,12 @@ :Upstream: No """ +from fauxfactory import gen_string import pytest import yaml -from fauxfactory import gen_string from robottelo import constants -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings +from robottelo.config import robottelo_tmp_dir, settings def test_positive_create_and_delete_variable(target_sat): diff --git a/tests/foreman/ui/test_architecture.py b/tests/foreman/ui/test_architecture.py index ac7067449ba..bafaa89f78f 100644 --- a/tests/foreman/ui/test_architecture.py +++ b/tests/foreman/ui/test_architecture.py @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_audit.py b/tests/foreman/ui/test_audit.py index ecb7c87d7ce..ca506d21292 100644 --- a/tests/foreman/ui/test_audit.py +++ b/tests/foreman/ui/test_audit.py @@ -14,9 +14,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.constants import ENVIRONMENT diff --git a/tests/foreman/ui/test_bookmarks.py b/tests/foreman/ui/test_bookmarks.py index f33483a0c42..180a0bf205e 100644 --- a/tests/foreman/ui/test_bookmarks.py +++ b/tests/foreman/ui/test_bookmarks.py @@ -16,11 +16,11 @@ :Upstream: No """ -import pytest from airgun.exceptions import NoSuchElementException from airgun.session import Session from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import user_nailgun_config from robottelo.constants import BOOKMARK_ENTITIES @@ -42,7 +42,7 @@ def ui_entity(module_org, module_location, request): # Skip the entities, which can't be tested ATM (not implemented in # airgun or have open BZs) skip = entity.get('skip_for_ui') - if isinstance(skip, (tuple, list)): + if isinstance(skip, tuple | list): open_issues = {issue for issue in skip if is_open(issue)} pytest.skip(f'There is/are an open issue(s) {open_issues} with entity {entity_name}') # entities with 1 organization and location diff --git a/tests/foreman/ui/test_branding.py b/tests/foreman/ui/test_branding.py index e6d481ca3f3..3067614e02a 100644 --- a/tests/foreman/ui/test_branding.py +++ b/tests/foreman/ui/test_branding.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from airgun.session import Session +import pytest @pytest.mark.e2e diff --git a/tests/foreman/ui/test_computeprofiles.py b/tests/foreman/ui/test_computeprofiles.py index efa011af4a8..5aea38df2cf 100644 --- a/tests/foreman/ui/test_computeprofiles.py +++ b/tests/foreman/ui/test_computeprofiles.py @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_computeresource.py b/tests/foreman/ui/test_computeresource.py index 151143e2edc..000f95951f8 100644 --- a/tests/foreman/ui/test_computeresource.py +++ b/tests/foreman/ui/test_computeresource.py @@ -16,18 +16,14 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from wait_for import wait_for -from robottelo.config import setting_is_set -from robottelo.config import settings -from robottelo.constants import COMPUTE_PROFILE_LARGE -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import FOREMAN_PROVIDERS +from robottelo.config import setting_is_set, settings +from robottelo.constants import COMPUTE_PROFILE_LARGE, DEFAULT_LOC, FOREMAN_PROVIDERS from robottelo.utils.datafactory import gen_string - # TODO mark this on the module with a lambda for skip condition # so that this is executed during the session at run loop, instead of at module import if not setting_is_set('rhev'): diff --git a/tests/foreman/ui/test_computeresource_azurerm.py b/tests/foreman/ui/test_computeresource_azurerm.py index ed3c6770b57..aab0bdf6c53 100644 --- a/tests/foreman/ui/test_computeresource_azurerm.py +++ b/tests/foreman/ui/test_computeresource_azurerm.py @@ -16,14 +16,16 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.constants import AZURERM_FILE_URI -from robottelo.constants import AZURERM_PLATFORM_DEFAULT -from robottelo.constants import AZURERM_VM_SIZE_DEFAULT -from robottelo.constants import COMPUTE_PROFILE_SMALL +from robottelo.constants import ( + AZURERM_FILE_URI, + AZURERM_PLATFORM_DEFAULT, + AZURERM_VM_SIZE_DEFAULT, + COMPUTE_PROFILE_SMALL, +) pytestmark = [pytest.mark.skip_if_not_set('azurerm')] diff --git a/tests/foreman/ui/test_computeresource_ec2.py b/tests/foreman/ui/test_computeresource_ec2.py index a232e65125c..94c50f69547 100644 --- a/tests/foreman/ui/test_computeresource_ec2.py +++ b/tests/foreman/ui/test_computeresource_ec2.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import AWS_EC2_FLAVOR_T2_MICRO -from robottelo.constants import COMPUTE_PROFILE_LARGE -from robottelo.constants import EC2_REGION_CA_CENTRAL_1 -from robottelo.constants import FOREMAN_PROVIDERS +from robottelo.constants import ( + AWS_EC2_FLAVOR_T2_MICRO, + COMPUTE_PROFILE_LARGE, + EC2_REGION_CA_CENTRAL_1, + FOREMAN_PROVIDERS, +) pytestmark = [pytest.mark.skip_if_not_set('ec2')] diff --git a/tests/foreman/ui/test_computeresource_gce.py b/tests/foreman/ui/test_computeresource_gce.py index 9d4ae1e1d99..c4618bfb608 100644 --- a/tests/foreman/ui/test_computeresource_gce.py +++ b/tests/foreman/ui/test_computeresource_gce.py @@ -19,16 +19,18 @@ import json import random -import pytest from fauxfactory import gen_string +import pytest from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import COMPUTE_PROFILE_SMALL -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import GCE_EXTERNAL_IP_DEFAULT -from robottelo.constants import GCE_MACHINE_TYPE_DEFAULT -from robottelo.constants import GCE_NETWORK_DEFAULT +from robottelo.constants import ( + COMPUTE_PROFILE_SMALL, + FOREMAN_PROVIDERS, + GCE_EXTERNAL_IP_DEFAULT, + GCE_MACHINE_TYPE_DEFAULT, + GCE_NETWORK_DEFAULT, +) @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_computeresource_libvirt.py b/tests/foreman/ui/test_computeresource_libvirt.py index 53815d45ec7..1cb250d2346 100644 --- a/tests/foreman/ui/test_computeresource_libvirt.py +++ b/tests/foreman/ui/test_computeresource_libvirt.py @@ -18,13 +18,16 @@ """ from random import choice -import pytest from fauxfactory import gen_string +import pytest +from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import COMPUTE_PROFILE_SMALL -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import LIBVIRT_RESOURCE_URL +from robottelo.constants import ( + COMPUTE_PROFILE_SMALL, + FOREMAN_PROVIDERS, + LIBVIRT_RESOURCE_URL, +) pytestmark = [pytest.mark.skip_if_not_set('libvirt')] @@ -118,3 +121,87 @@ def test_positive_end_to_end(session, module_target_sat, module_org, module_loca assert cr_profile_values['provider_content']['memory'] == '8192 MB' session.computeresource.delete(new_cr_name) assert not session.computeresource.search(new_cr_name) + + +@pytest.mark.on_premises_provisioning +@pytest.mark.tier4 +@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) +def test_positive_provision_end_to_end( + request, + session, + setting_update, + module_sca_manifest_org, + module_location, + provisioning_hostgroup, + module_libvirt_provisioning_sat, +): + """Provision Host on libvirt compute resource, and delete it afterwards + + :id: 2678f95f-0c0e-4b46-a3c1-3f9a954d3bde + + :expectedresults: Host is provisioned successfully + + :CaseLevel: System + + :customerscenario: true + + :BZ: 1243223 + + :parametrized: yes + """ + sat = module_libvirt_provisioning_sat.sat + hostname = gen_string('alpha').lower() + cr = sat.api.LibvirtComputeResource( + provider=FOREMAN_PROVIDERS['libvirt'], + url=LIBVIRT_URL, + display_type='VNC', + location=[module_location], + organization=[module_sca_manifest_org], + ).create() + with session: + session.host.create( + { + 'host.name': hostname, + 'host.organization': module_sca_manifest_org.name, + 'host.location': module_location.name, + 'host.hostgroup': provisioning_hostgroup.name, + 'host.inherit_deploy_option': False, + 'host.deploy': f'{cr.name} (Libvirt)', + 'provider_content.virtual_machine.memory': '6144', + 'interfaces.interface.network_type': 'Physical (Bridge)', + 'interfaces.interface.network': f'br-{settings.provisioning.vlan_id}', + 'additional_information.comment': 'Libvirt provision using valid data', + } + ) + name = f'{hostname}.{module_libvirt_provisioning_sat.domain.name}' + assert session.host.search(name)[0]['Name'] == name + + # teardown + @request.addfinalizer + def _finalize(): + host = sat.api.Host().search(query={'search': f'name="{name}"'}) + if host: + host[0].delete() + + # Check on Libvirt, if VM exists + result = sat.execute( + f'su foreman -s /bin/bash -c "virsh -c {LIBVIRT_URL} list --state-running"' + ) + assert hostname in result.stdout + # Wait for provisioning to complete and report status back to Satellite + wait_for( + lambda: session.host.get_details(name)['properties']['properties_table']['Build'] + != 'Pending installation clear', + timeout=1800, + delay=30, + fail_func=session.browser.refresh, + silent_failure=True, + handle_exception=True, + ) + assert ( + session.host.get_details(name)['properties']['properties_table']['Build'] + == 'Installed clear' + ) + session.host.delete(name) + assert not sat.api.Host().search(query={'search': f'name="{name}"'}) diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index 5502ed6292e..dfe4ca1abe7 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -16,22 +16,21 @@ :Upstream: No """ -from math import floor -from math import log10 +from math import floor, log10 from random import choice -import pytest from nailgun import entities -from wait_for import TimedOutError -from wait_for import wait_for -from wrapanapi.systems.virtualcenter import vim -from wrapanapi.systems.virtualcenter import VMWareSystem +import pytest +from wait_for import TimedOutError, wait_for +from wrapanapi.systems.virtualcenter import VMWareSystem, vim from robottelo.config import settings -from robottelo.constants import COMPUTE_PROFILE_LARGE -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import VMWARE_CONSTANTS +from robottelo.constants import ( + COMPUTE_PROFILE_LARGE, + DEFAULT_LOC, + FOREMAN_PROVIDERS, + VMWARE_CONSTANTS, +) from robottelo.utils.datafactory import gen_string pytestmark = [pytest.mark.skip_if_not_set('vmware')] diff --git a/tests/foreman/ui/test_config_group.py b/tests/foreman/ui/test_config_group.py index db2b6eba171..ada7fc5b8c4 100644 --- a/tests/foreman/ui/test_config_group.py +++ b/tests/foreman/ui/test_config_group.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest @pytest.fixture(scope='module') diff --git a/tests/foreman/ui/test_containerimagetag.py b/tests/foreman/ui/test_containerimagetag.py index dc3dba99bcd..681cb1e877d 100644 --- a/tests/foreman/ui/test_containerimagetag.py +++ b/tests/foreman/ui/test_containerimagetag.py @@ -16,13 +16,15 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import ENVIRONMENT -from robottelo.constants import REPO_TYPE +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + ENVIRONMENT, + REPO_TYPE, +) @pytest.fixture(scope="module") diff --git a/tests/foreman/ui/test_contentcredentials.py b/tests/foreman/ui/test_contentcredentials.py index 36d1575c796..d53d84618f6 100644 --- a/tests/foreman/ui/test_contentcredentials.py +++ b/tests/foreman/ui/test_contentcredentials.py @@ -19,8 +19,7 @@ import pytest from robottelo.config import settings -from robottelo.constants import CONTENT_CREDENTIALS_TYPES -from robottelo.constants import DataFile +from robottelo.constants import CONTENT_CREDENTIALS_TYPES, DataFile from robottelo.utils.datafactory import gen_string empty_message = "You currently don't have any Products associated with this Content Credential." diff --git a/tests/foreman/ui/test_contenthost.py b/tests/foreman/ui/test_contenthost.py index d2bd6ded4d3..1db98df1d70 100644 --- a/tests/foreman/ui/test_contenthost.py +++ b/tests/foreman/ui/test_contenthost.py @@ -16,34 +16,31 @@ :Upstream: No """ +from datetime import datetime, timedelta import re -from datetime import datetime -from datetime import timedelta from urllib.parse import urlparse -import pytest from airgun.session import Session -from fauxfactory import gen_integer -from fauxfactory import gen_string +from fauxfactory import gen_integer, gen_string from nailgun import entities +import pytest -from robottelo.cli.factory import CLIFactoryError -from robottelo.cli.factory import make_fake_host -from robottelo.cli.factory import make_virt_who_config -from robottelo.config import setting_is_set -from robottelo.config import settings -from robottelo.constants import DEFAULT_SYSPURPOSE_ATTRIBUTES -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_GROUP -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_GROUP_NAME -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_1_ERRATA_ID -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE_NAME -from robottelo.constants import VDC_SUBSCRIPTION_NAME -from robottelo.constants import VIRT_WHO_HYPERVISOR_TYPES +from robottelo.cli.factory import CLIFactoryError, make_fake_host, make_virt_who_config +from robottelo.config import setting_is_set, settings +from robottelo.constants import ( + DEFAULT_SYSPURPOSE_ATTRIBUTES, + FAKE_0_CUSTOM_PACKAGE, + FAKE_0_CUSTOM_PACKAGE_GROUP, + FAKE_0_CUSTOM_PACKAGE_GROUP_NAME, + FAKE_0_CUSTOM_PACKAGE_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE_NAME, + FAKE_1_ERRATA_ID, + FAKE_2_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE_NAME, + VDC_SUBSCRIPTION_NAME, + VIRT_WHO_HYPERVISOR_TYPES, +) from robottelo.utils.issue_handlers import is_open from robottelo.utils.virtwho import create_fake_hypervisor_content @@ -78,6 +75,7 @@ def vm(module_repos_collection_with_manifest, rhel7_contenthost, target_sat): """Virtual machine registered in satellite""" module_repos_collection_with_manifest.setup_virtual_machine(rhel7_contenthost) rhel7_contenthost.add_rex_key(target_sat) + rhel7_contenthost.run(r'subscription-manager repos --enable \*') yield rhel7_contenthost diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index 350bceef27a..c2910802508 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -16,8 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest + @pytest.mark.tier2 @@ -71,3 +72,5 @@ def test_no_blank_page_on_language_switch(session, target_sat, module_org): with target_sat.ui_session(user=user.login, password=user_password) as session: session.user.update(user.login, {'user.language': 'Français'}) assert session.contentview_new.check_if_blank_in_french() + + \ No newline at end of file diff --git a/tests/foreman/ui/test_contentview_old.py b/tests/foreman/ui/test_contentview_old.py index 3c2da24d365..8320cb59bd0 100644 --- a/tests/foreman/ui/test_contentview_old.py +++ b/tests/foreman/ui/test_contentview_old.py @@ -23,8 +23,7 @@ from random import randint import pytest -from airgun.exceptions import InvalidElementStateException -from airgun.exceptions import NoSuchElementException +from airgun.exceptions import InvalidElementStateException, NoSuchElementException from airgun.session import Session from nailgun import entities from nailgun.entity_mixins import call_entity_method_with_timeout @@ -34,24 +33,26 @@ from robottelo import constants from robottelo.cli.contentview import ContentView from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import DEFAULT_ARCHITECTURE -from robottelo.constants import DEFAULT_CV -from robottelo.constants import DEFAULT_PTABLE -from robottelo.constants import ENVIRONMENT -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_9_YUM_SECURITY_ERRATUM_COUNT -from robottelo.constants import FILTER_CONTENT_TYPE -from robottelo.constants import FILTER_ERRATA_TYPE -from robottelo.constants import FILTER_TYPE -from robottelo.constants import PERMISSIONS -from robottelo.constants import PRDS -from robottelo.constants import REPO_TYPE -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + DEFAULT_ARCHITECTURE, + DEFAULT_CV, + DEFAULT_PTABLE, + ENVIRONMENT, + FAKE_0_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE, + FAKE_9_YUM_SECURITY_ERRATUM_COUNT, + FILTER_CONTENT_TYPE, + FILTER_ERRATA_TYPE, + FILTER_TYPE, + PERMISSIONS, + PRDS, + REPO_TYPE, + REPOS, + REPOSET, +) from robottelo.utils.datafactory import gen_string VERSION = 'Version 1.0' diff --git a/tests/foreman/ui/test_dashboard.py b/tests/foreman/ui/test_dashboard.py index 439f80c48e7..80b7ce16732 100644 --- a/tests/foreman/ui/test_dashboard.py +++ b/tests/foreman/ui/test_dashboard.py @@ -16,10 +16,10 @@ :Upstream: No """ -import pytest from airgun.session import Session from nailgun import entities from nailgun.entity_mixins import TaskFailedError +import pytest from robottelo.config import settings from robottelo.constants import FAKE_7_CUSTOM_PACKAGE diff --git a/tests/foreman/ui/test_discoveredhost.py b/tests/foreman/ui/test_discoveredhost.py index f694e6a86a2..ce3ea4d506e 100644 --- a/tests/foreman/ui/test_discoveredhost.py +++ b/tests/foreman/ui/test_discoveredhost.py @@ -14,10 +14,9 @@ :Upstream: No """ -import pytest -from fauxfactory import gen_ipaddr -from fauxfactory import gen_string +from fauxfactory import gen_ipaddr, gen_string from nailgun import entities +import pytest from robottelo.utils import ssh diff --git a/tests/foreman/ui/test_discoveryrule.py b/tests/foreman/ui/test_discoveryrule.py index 6efd92c5c17..e529578efca 100644 --- a/tests/foreman/ui/test_discoveryrule.py +++ b/tests/foreman/ui/test_discoveryrule.py @@ -16,11 +16,9 @@ :Upstream: No """ -import pytest from airgun.session import Session -from fauxfactory import gen_integer -from fauxfactory import gen_ipaddr -from fauxfactory import gen_string +from fauxfactory import gen_integer, gen_ipaddr, gen_string +import pytest @pytest.fixture diff --git a/tests/foreman/ui/test_domain.py b/tests/foreman/ui/test_domain.py index 48e297f591a..c082bef7d83 100644 --- a/tests/foreman/ui/test_domain.py +++ b/tests/foreman/ui/test_domain.py @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.utils.datafactory import valid_domain_names diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index 36e86537e0c..fb0c703530b 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -16,34 +16,35 @@ :Upstream: No """ -import pytest from airgun.session import Session from broker import Broker from fauxfactory import gen_string from manifester import Manifester from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import FAKE_10_YUM_BUGFIX_ERRATUM -from robottelo.constants import FAKE_10_YUM_BUGFIX_ERRATUM_COUNT -from robottelo.constants import FAKE_11_YUM_ENHANCEMENT_ERRATUM -from robottelo.constants import FAKE_11_YUM_ENHANCEMENT_ERRATUM_COUNT -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_3_YUM_OUTDATED_PACKAGES -from robottelo.constants import FAKE_4_CUSTOM_PACKAGE -from robottelo.constants import FAKE_5_CUSTOM_PACKAGE -from robottelo.constants import FAKE_9_YUM_OUTDATED_PACKAGES -from robottelo.constants import FAKE_9_YUM_SECURITY_ERRATUM -from robottelo.constants import FAKE_9_YUM_SECURITY_ERRATUM_COUNT -from robottelo.constants import PRDS -from robottelo.constants import REAL_0_RH_PACKAGE -from robottelo.constants import REAL_4_ERRATA_CVES -from robottelo.constants import REAL_4_ERRATA_ID +from robottelo.constants import ( + DEFAULT_LOC, + FAKE_1_CUSTOM_PACKAGE, + FAKE_2_CUSTOM_PACKAGE, + FAKE_3_YUM_OUTDATED_PACKAGES, + FAKE_4_CUSTOM_PACKAGE, + FAKE_5_CUSTOM_PACKAGE, + FAKE_9_YUM_OUTDATED_PACKAGES, + FAKE_9_YUM_SECURITY_ERRATUM, + FAKE_9_YUM_SECURITY_ERRATUM_COUNT, + FAKE_10_YUM_BUGFIX_ERRATUM, + FAKE_10_YUM_BUGFIX_ERRATUM_COUNT, + FAKE_11_YUM_ENHANCEMENT_ERRATUM, + FAKE_11_YUM_ENHANCEMENT_ERRATUM_COUNT, + PRDS, + REAL_0_RH_PACKAGE, + REAL_4_ERRATA_CVES, + REAL_4_ERRATA_ID, +) from robottelo.hosts import ContentHost - CUSTOM_REPO_URL = settings.repos.yum_9.url CUSTOM_REPO_ERRATA_ID = settings.repos.yum_9.errata[0] diff --git a/tests/foreman/ui/test_hardwaremodel.py b/tests/foreman/ui/test_hardwaremodel.py index 5d7d8d2f02a..4ec42851ab7 100644 --- a/tests/foreman/ui/test_hardwaremodel.py +++ b/tests/foreman/ui/test_hardwaremodel.py @@ -14,9 +14,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest @pytest.mark.e2e diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 803abbd7778..1d3b734e2ea 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -18,33 +18,33 @@ """ import copy import csv +from datetime import datetime import os import re -from datetime import datetime -import pytest -import yaml -from airgun.exceptions import DisabledWidgetError -from airgun.exceptions import NoSuchElementException +from airgun.exceptions import DisabledWidgetError, NoSuchElementException from airgun.session import Session +import pytest from wait_for import wait_for +import yaml from robottelo import constants from robottelo.config import settings -from robottelo.constants import ANY_CONTEXT -from robottelo.constants import DEFAULT_CV -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import ENVIRONMENT -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_7_CUSTOM_PACKAGE -from robottelo.constants import FAKE_8_CUSTOM_PACKAGE -from robottelo.constants import FAKE_8_CUSTOM_PACKAGE_NAME -from robottelo.constants import FOREMAN_PROVIDERS -from robottelo.constants import OSCAP_PERIOD -from robottelo.constants import OSCAP_WEEKDAY -from robottelo.constants import PERMISSIONS -from robottelo.constants import REPO_TYPE +from robottelo.constants import ( + ANY_CONTEXT, + DEFAULT_CV, + DEFAULT_LOC, + DEFAULT_SUBSCRIPTION_NAME, + ENVIRONMENT, + FAKE_1_CUSTOM_PACKAGE, + FAKE_7_CUSTOM_PACKAGE, + FAKE_8_CUSTOM_PACKAGE, + FAKE_8_CUSTOM_PACKAGE_NAME, + OSCAP_PERIOD, + OSCAP_WEEKDAY, + PERMISSIONS, + REPO_TYPE, +) from robottelo.utils.datafactory import gen_string from robottelo.utils.issue_handlers import is_open @@ -97,134 +97,6 @@ def module_global_params(module_target_sat): global_parameter.delete() -@pytest.fixture(scope='module') -def module_libvirt_resource(module_org, smart_proxy_location, module_target_sat): - # Search if Libvirt compute-resource already exists - # If so, just update its relevant fields otherwise, - # Create new compute-resource with 'libvirt' provider. - resource_url = f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system' - comp_res = [ - res - for res in module_target_sat.api.LibvirtComputeResource().search() - if res.provider == FOREMAN_PROVIDERS['libvirt'] and res.url == resource_url - ] - if len(comp_res) > 0: - computeresource = module_target_sat.api.LibvirtComputeResource(id=comp_res[0].id).read() - computeresource.location.append(smart_proxy_location) - computeresource.organization.append(module_org) - computeresource = computeresource.update(['location', 'organization']) - else: - # Create Libvirt compute-resource - computeresource = module_target_sat.api.LibvirtComputeResource( - provider=FOREMAN_PROVIDERS['libvirt'], - url=resource_url, - set_console_password=False, - display_type='VNC', - location=[smart_proxy_location], - organization=[module_org], - ).create() - return f'{computeresource.name} (Libvirt)' - - -@pytest.fixture(scope='module') -def module_libvirt_domain(module_org, smart_proxy_location, default_domain): - default_domain.location.append(smart_proxy_location) - default_domain.organization.append(module_org) - default_domain.update(['location', 'organization']) - return default_domain - - -@pytest.fixture(scope='module') -def module_libvirt_subnet( - module_org, smart_proxy_location, module_libvirt_domain, default_smart_proxy, module_target_sat -): - # Search if subnet is defined with given network. - # If so, just update its relevant fields otherwise, - # Create new subnet - network = settings.vlan_networking.subnet - subnet = module_target_sat.api.Subnet().search(query={'search': f'network={network}'}) - if len(subnet) > 0: - subnet = subnet[0].read() - subnet.domain.append(module_libvirt_domain) - subnet.location.append(smart_proxy_location) - subnet.organization.append(module_org) - subnet.dns = default_smart_proxy - subnet.dhcp = default_smart_proxy - subnet.ipam = 'DHCP' - subnet.tftp = default_smart_proxy - subnet.discovery = default_smart_proxy - subnet = subnet.update( - ['domain', 'discovery', 'dhcp', 'dns', 'ipam', 'location', 'organization', 'tftp'] - ) - else: - # Create new subnet - subnet = module_target_sat.api.Subnet( - network=network, - mask=settings.vlan_networking.netmask, - location=[smart_proxy_location], - organization=[module_org], - domain=[module_libvirt_domain], - ipam='DHCP', - dns=default_smart_proxy, - dhcp=default_smart_proxy, - tftp=default_smart_proxy, - discovery=default_smart_proxy, - ).create() - return subnet - - -@pytest.fixture(scope='module') -def module_libvirt_media(module_org, smart_proxy_location, os_path, default_os, module_target_sat): - media = module_target_sat.api.Media().search(query={'search': f'path="{os_path}"'}) - if len(media) > 0: - # Media with this path already exist, make sure it is correct - media = media[0].read() - media.organization.append(module_org) - media.location.append(smart_proxy_location) - media.operatingsystem.append(default_os) - media.os_family = 'Redhat' - media = media.update(['organization', 'location', 'operatingsystem', 'os_family']) - else: - # Create new media - media = module_target_sat.api.Media( - organization=[module_org], - location=[smart_proxy_location], - operatingsystem=[default_os], - path_=os_path, - os_family='Redhat', - ).create() - return media - - -@pytest.fixture(scope='module') -def module_libvirt_hostgroup( - module_org, - smart_proxy_location, - default_partition_table, - default_architecture, - default_os, - module_libvirt_media, - module_libvirt_subnet, - default_smart_proxy, - module_libvirt_domain, - module_lce, - module_cv_repo, - module_target_sat, -): - return module_target_sat.api.HostGroup( - architecture=default_architecture, - domain=module_libvirt_domain, - subnet=module_libvirt_subnet, - lifecycle_environment=module_lce, - content_view=module_cv_repo, - location=[smart_proxy_location], - operatingsystem=default_os, - organization=[module_org], - ptable=default_partition_table, - medium=module_libvirt_media, - ).create() - - @pytest.fixture(scope='module') def module_activation_key(module_entitlement_manifest_org, module_target_sat): """Create activation key using default CV and library environment.""" @@ -1779,114 +1651,6 @@ def test_positive_bulk_delete_host(session, smart_proxy_location, target_sat, fu assert not values['table'] -@pytest.mark.on_premises_provisioning -@pytest.mark.tier4 -def test_positive_provision_end_to_end( - session, - module_org, - smart_proxy_location, - module_libvirt_domain, - module_libvirt_hostgroup, - module_libvirt_resource, - target_sat, -): - """Provision Host on libvirt compute resource - - :id: 2678f95f-0c0e-4b46-a3c1-3f9a954d3bde - - :expectedresults: Host is provisioned successfully - - :CaseLevel: System - """ - hostname = gen_string('alpha').lower() - root_pwd = gen_string('alpha', 15) - with session: - session.host.create( - { - 'host.name': hostname, - 'host.organization': module_org.name, - 'host.location': smart_proxy_location.name, - 'host.hostgroup': module_libvirt_hostgroup.name, - 'host.inherit_deploy_option': False, - 'host.deploy': module_libvirt_resource, - 'provider_content.virtual_machine.memory': '2 GB', - 'operating_system.root_password': root_pwd, - 'interfaces.interface.network_type': 'Physical (Bridge)', - 'interfaces.interface.network': settings.vlan_networking.bridge, - 'additional_information.comment': 'Libvirt provision using valid data', - } - ) - name = f'{hostname}.{module_libvirt_domain.name}' - assert session.host.search(name)[0]['Name'] == name - wait_for( - lambda: session.host.get_details(name)['properties']['properties_table']['Build'] - != 'Pending installation', - timeout=1800, - delay=30, - fail_func=session.browser.refresh, - silent_failure=True, - handle_exception=True, - ) - target_sat.api.Host( - id=target_sat.api.Host().search(query={'search': f'name={name}'})[0].id - ).delete() - assert ( - session.host.get_details(name)['properties']['properties_table']['Build'] == 'Installed' - ) - - -@pytest.mark.on_premises_provisioning -@pytest.mark.run_in_one_thread -@pytest.mark.tier4 -@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) -def test_positive_delete_libvirt( - session, - module_org, - smart_proxy_location, - module_libvirt_domain, - module_libvirt_hostgroup, - module_libvirt_resource, - setting_update, - target_sat, -): - """Create a new Host on libvirt compute resource and delete it - afterwards - - :id: 6a9175e7-bb96-4de3-bc45-ba6c10dd14a4 - - :customerscenario: true - - :expectedresults: Proper warning message is displayed on delete attempt - and host deleted successfully afterwards - - :BZ: 1243223 - - :CaseLevel: System - """ - hostname = gen_string('alpha').lower() - root_pwd = gen_string('alpha', 15) - with session: - session.host.create( - { - 'host.name': hostname, - 'host.organization': module_org.name, - 'host.location': smart_proxy_location.name, - 'host.hostgroup': module_libvirt_hostgroup.name, - 'host.inherit_deploy_option': False, - 'host.deploy': module_libvirt_resource, - 'provider_content.virtual_machine.memory': '1 GB', - 'operating_system.root_password': root_pwd, - 'interfaces.interface.network_type': 'Physical (Bridge)', - 'interfaces.interface.network': settings.vlan_networking.bridge, - 'additional_information.comment': 'Delete host that provisioned on Libvirt', - } - ) - name = f'{hostname}.{module_libvirt_domain.name}' - assert session.host.search(name)[0]['Name'] == name - session.host.delete(name) - assert not target_sat.api.Host().search(query={'search': f'name="{hostname}"'}) - - # ------------------------------ NEW HOST UI DETAILS ---------------------------- @pytest.mark.tier4 def test_positive_read_details_page_from_new_ui(session, host_ui_options): diff --git a/tests/foreman/ui/test_hostcollection.py b/tests/foreman/ui/test_hostcollection.py index 689a93afae4..2c60125c293 100644 --- a/tests/foreman/ui/test_hostcollection.py +++ b/tests/foreman/ui/test_hostcollection.py @@ -18,9 +18,9 @@ """ import time -import pytest from broker import Broker from manifester import Manifester +import pytest from robottelo import constants from robottelo.config import settings diff --git a/tests/foreman/ui/test_hostgroup.py b/tests/foreman/ui/test_hostgroup.py index 39878c78c94..c8a1d23a897 100644 --- a/tests/foreman/ui/test_hostgroup.py +++ b/tests/foreman/ui/test_hostgroup.py @@ -16,13 +16,12 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT +from robottelo.constants import DEFAULT_CV, ENVIRONMENT @pytest.mark.e2e diff --git a/tests/foreman/ui/test_http_proxy.py b/tests/foreman/ui/test_http_proxy.py index cddc7cd1e42..2f48559cac2 100644 --- a/tests/foreman/ui/test_http_proxy.py +++ b/tests/foreman/ui/test_http_proxy.py @@ -16,14 +16,11 @@ :Upstream: No """ +from fauxfactory import gen_integer, gen_string, gen_url import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string -from fauxfactory import gen_url from robottelo.config import settings -from robottelo.constants import DOCKER_REPO_UPSTREAM_NAME -from robottelo.constants import REPO_TYPE +from robottelo.constants import DOCKER_REPO_UPSTREAM_NAME, REPO_TYPE @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_jobinvocation.py b/tests/foreman/ui/test_jobinvocation.py index 2dbf8f0cf4a..62ab4ed5ef4 100644 --- a/tests/foreman/ui/test_jobinvocation.py +++ b/tests/foreman/ui/test_jobinvocation.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from inflection import camelize +import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_jobtemplate.py b/tests/foreman/ui/test_jobtemplate.py index 1041878f753..798400aa976 100644 --- a/tests/foreman/ui/test_jobtemplate.py +++ b/tests/foreman/ui/test_jobtemplate.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest @pytest.mark.e2e diff --git a/tests/foreman/ui/test_ldap_authentication.py b/tests/foreman/ui/test_ldap_authentication.py index 01ac2987fe4..e1983767e77 100644 --- a/tests/foreman/ui/test_ldap_authentication.py +++ b/tests/foreman/ui/test_ldap_authentication.py @@ -18,21 +18,17 @@ """ import os -import pyotp -import pytest from airgun.session import Session from fauxfactory import gen_url from nailgun import entities from navmazing import NavigationTriesExceeded +import pyotp +import pytest from robottelo.config import settings -from robottelo.constants import ANY_CONTEXT -from robottelo.constants import CERT_PATH -from robottelo.constants import LDAP_ATTR -from robottelo.constants import PERMISSIONS +from robottelo.constants import ANY_CONTEXT, CERT_PATH, LDAP_ATTR, PERMISSIONS from robottelo.utils.datafactory import gen_string - pytestmark = [pytest.mark.run_in_one_thread] EXTERNAL_GROUP_NAME = 'foobargroup' diff --git a/tests/foreman/ui/test_lifecycleenvironment.py b/tests/foreman/ui/test_lifecycleenvironment.py index 396662708c8..5ff44751f6e 100644 --- a/tests/foreman/ui/test_lifecycleenvironment.py +++ b/tests/foreman/ui/test_lifecycleenvironment.py @@ -16,18 +16,20 @@ :Upstream: No """ -import pytest from airgun.session import Session from navmazing import NavigationTriesExceeded +import pytest from robottelo.config import settings -from robottelo.constants import ENVIRONMENT -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_2_CUSTOM_PACKAGE -from robottelo.constants import FAKE_3_CUSTOM_PACKAGE_NAME +from robottelo.constants import ( + ENVIRONMENT, + FAKE_0_CUSTOM_PACKAGE, + FAKE_0_CUSTOM_PACKAGE_NAME, + FAKE_1_CUSTOM_PACKAGE, + FAKE_1_CUSTOM_PACKAGE_NAME, + FAKE_2_CUSTOM_PACKAGE, + FAKE_3_CUSTOM_PACKAGE_NAME, +) from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_location.py b/tests/foreman/ui/test_location.py index 06b51bf2341..b86484ff392 100644 --- a/tests/foreman/ui/test_location.py +++ b/tests/foreman/ui/test_location.py @@ -16,15 +16,12 @@ :Upstream: No """ -import pytest -from fauxfactory import gen_ipaddr -from fauxfactory import gen_string +from fauxfactory import gen_ipaddr, gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import ANY_CONTEXT -from robottelo.constants import INSTALL_MEDIUM_URL -from robottelo.constants import LIBVIRT_RESOURCE_URL +from robottelo.constants import ANY_CONTEXT, INSTALL_MEDIUM_URL, LIBVIRT_RESOURCE_URL @pytest.mark.e2e diff --git a/tests/foreman/ui/test_media.py b/tests/foreman/ui/test_media.py index 8d944c250bb..db78fe4b414 100644 --- a/tests/foreman/ui/test_media.py +++ b/tests/foreman/ui/test_media.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.constants import INSTALL_MEDIUM_URL diff --git a/tests/foreman/ui/test_modulestreams.py b/tests/foreman/ui/test_modulestreams.py index 1bf848a7721..23461437f48 100644 --- a/tests/foreman/ui/test_modulestreams.py +++ b/tests/foreman/ui/test_modulestreams.py @@ -16,9 +16,9 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings diff --git a/tests/foreman/ui/test_organization.py b/tests/foreman/ui/test_organization.py index 278c26cda11..460e2ab38a7 100644 --- a/tests/foreman/ui/test_organization.py +++ b/tests/foreman/ui/test_organization.py @@ -16,14 +16,12 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import DEFAULT_ORG -from robottelo.constants import INSTALL_MEDIUM_URL -from robottelo.constants import LIBVIRT_RESOURCE_URL +from robottelo.constants import DEFAULT_ORG, INSTALL_MEDIUM_URL, LIBVIRT_RESOURCE_URL from robottelo.logging import logger CUSTOM_REPO_ERRATA_ID = settings.repos.yum_0.errata[0] @@ -116,7 +114,12 @@ def test_positive_end_to_end(session): ) assert session.organization.search(new_name) org_values = session.organization.read(new_name, widget_names=widget_list) - assert not session.organization.delete(new_name) + with pytest.raises(AssertionError) as context: + assert not session.organization.delete(new_name) + assert ( + 'The current organization cannot be deleted. Please switch to a ' + 'different organization before deleting.' in str(context.value) + ) assert user.login in org_values['users']['resources']['assigned'] assert media.name in org_values['media']['resources']['assigned'] assert template.name in org_values['provisioning_templates']['resources']['assigned'] diff --git a/tests/foreman/ui/test_oscapcontent.py b/tests/foreman/ui/test_oscapcontent.py index 6a86a8ce9e1..21e6367de0f 100644 --- a/tests/foreman/ui/test_oscapcontent.py +++ b/tests/foreman/ui/test_oscapcontent.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -20,8 +20,7 @@ import pytest -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings +from robottelo.config import robottelo_tmp_dir, settings from robottelo.constants import DataFile from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_oscappolicy.py b/tests/foreman/ui/test_oscappolicy.py index e0d47e152a3..37196d8e2cf 100644 --- a/tests/foreman/ui/test_oscappolicy.py +++ b/tests/foreman/ui/test_oscappolicy.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from robottelo.constants import OSCAP_PROFILE from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_oscaptailoringfile.py b/tests/foreman/ui/test_oscaptailoringfile.py index 007f0b44557..011cb9bff00 100644 --- a/tests/foreman/ui/test_oscaptailoringfile.py +++ b/tests/foreman/ui/test_oscaptailoringfile.py @@ -8,7 +8,7 @@ :CaseComponent: SCAPPlugin -:Team: Rocket +:Team: Endeavour :TestType: Functional @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from nailgun import entities +import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_package.py b/tests/foreman/ui/test_package.py index c5896e9ca24..257e571dc76 100644 --- a/tests/foreman/ui/test_package.py +++ b/tests/foreman/ui/test_package.py @@ -16,13 +16,12 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import RPM_TO_UPLOAD +from robottelo.constants import RPM_TO_UPLOAD, DataFile @pytest.fixture(scope='module') diff --git a/tests/foreman/ui/test_partitiontable.py b/tests/foreman/ui/test_partitiontable.py index 2b3e2099b15..393a2ca634f 100644 --- a/tests/foreman/ui/test_partitiontable.py +++ b/tests/foreman/ui/test_partitiontable.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.constants import DataFile diff --git a/tests/foreman/ui/test_product.py b/tests/foreman/ui/test_product.py index 2abb16fea74..a70623620f1 100644 --- a/tests/foreman/ui/test_product.py +++ b/tests/foreman/ui/test_product.py @@ -18,18 +18,18 @@ """ from datetime import timedelta -import pytest from fauxfactory import gen_choice from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import REPO_TYPE -from robottelo.constants import SYNC_INTERVAL -from robottelo.utils.datafactory import gen_string -from robottelo.utils.datafactory import parametrized -from robottelo.utils.datafactory import valid_cron_expressions -from robottelo.utils.datafactory import valid_data_list +from robottelo.constants import REPO_TYPE, SYNC_INTERVAL, DataFile +from robottelo.utils.datafactory import ( + gen_string, + parametrized, + valid_cron_expressions, + valid_data_list, +) @pytest.fixture(scope='module') diff --git a/tests/foreman/ui/test_puppetclass.py b/tests/foreman/ui/test_puppetclass.py index c8f08292249..5c5fdb98d78 100644 --- a/tests/foreman/ui/test_puppetclass.py +++ b/tests/foreman/ui/test_puppetclass.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_puppetenvironment.py b/tests/foreman/ui/test_puppetenvironment.py index 729eb7b190b..6d11797d1fb 100644 --- a/tests/foreman/ui/test_puppetenvironment.py +++ b/tests/foreman/ui/test_puppetenvironment.py @@ -18,8 +18,7 @@ """ import pytest -from robottelo.constants import DEFAULT_CV -from robottelo.constants import ENVIRONMENT +from robottelo.constants import DEFAULT_CV, ENVIRONMENT from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_reporttemplates.py b/tests/foreman/ui/test_reporttemplates.py index f8eed10e58f..1de38478844 100644 --- a/tests/foreman/ui/test_reporttemplates.py +++ b/tests/foreman/ui/test_reporttemplates.py @@ -19,23 +19,22 @@ import csv import json import os -from pathlib import Path -from pathlib import PurePath +from pathlib import Path, PurePath -import pytest -import yaml from lxml import etree from nailgun import entities +import pytest +import yaml -from robottelo.config import robottelo_tmp_dir -from robottelo.config import settings -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_1_CUSTOM_PACKAGE -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.ui.utils import create_fake_host +from robottelo.config import robottelo_tmp_dir, settings +from robottelo.constants import ( + DEFAULT_SUBSCRIPTION_NAME, + FAKE_0_CUSTOM_PACKAGE_NAME, + FAKE_1_CUSTOM_PACKAGE, + PRDS, + REPOS, + REPOSET, +) from robottelo.utils.datafactory import gen_string @@ -238,7 +237,7 @@ def test_positive_end_to_end(session, module_org, module_location): @pytest.mark.upgrade @pytest.mark.tier2 -def test_positive_generate_registered_hosts_report(session, module_org, module_location): +def test_positive_generate_registered_hosts_report(target_sat, module_org, module_location): """Use provided Host - Registered Content Hosts report for testing :id: b44d4cd8-a78e-47cf-9993-0bb871ac2c96 @@ -252,17 +251,22 @@ def test_positive_generate_registered_hosts_report(session, module_org, module_l """ # generate Host Status report os_name = 'comma,' + gen_string('alpha') - os = entities.OperatingSystem(name=os_name).create() + os = target_sat.api.OperatingSystem(name=os_name).create() host_cnt = 3 host_templates = [ - entities.Host(organization=module_org, location=module_location, operatingsystem=os) + target_sat.api.Host(organization=module_org, location=module_location, operatingsystem=os) for i in range(host_cnt) ] for host_template in host_templates: host_template.create_missing() - with session: + with target_sat.ui_session() as session: + session.organization.select(module_org.name) + session.location.select(module_location.name) # create multiple hosts to test filtering - host_names = [create_fake_host(session, host_template) for host_template in host_templates] + host_names = [ + target_sat.ui_factory(session).create_fake_host(host_template) + for host_template in host_templates + ] host_name = host_names[1] # pick some that is not first and is not last file_path = session.reporttemplate.generate( 'Host - Registered Content Hosts', values={'hosts_filter': host_name} diff --git a/tests/foreman/ui/test_repository.py b/tests/foreman/ui/test_repository.py index 37468fa4189..63b7df93577 100644 --- a/tests/foreman/ui/test_repository.py +++ b/tests/foreman/ui/test_repository.py @@ -16,29 +16,31 @@ :Upstream: No """ -from datetime import datetime -from datetime import timedelta -from random import randint -from random import shuffle +from datetime import datetime, timedelta +from random import randint, shuffle -import pytest from airgun.session import Session from nailgun import entities from navmazing import NavigationTriesExceeded +import pytest from robottelo import constants from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import DataFile -from robottelo.constants import DOWNLOAD_POLICIES -from robottelo.constants import INVALID_URL -from robottelo.constants import PRDS -from robottelo.constants import REPO_TYPE -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants.repos import ANSIBLE_GALAXY -from robottelo.constants.repos import CUSTOM_3RD_PARTY_REPO -from robottelo.constants.repos import CUSTOM_RPM_SHA +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + DOWNLOAD_POLICIES, + INVALID_URL, + PRDS, + REPO_TYPE, + REPOS, + REPOSET, + DataFile, +) +from robottelo.constants.repos import ( + ANSIBLE_GALAXY, + CUSTOM_3RD_PARTY_REPO, + CUSTOM_RPM_SHA, +) from robottelo.hosts import get_sat_version from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_rhc.py b/tests/foreman/ui/test_rhc.py index dfcf3890810..6fa17a18589 100644 --- a/tests/foreman/ui/test_rhc.py +++ b/tests/foreman/ui/test_rhc.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from wait_for import wait_for from robottelo import constants diff --git a/tests/foreman/ui/test_rhcloud_insights.py b/tests/foreman/ui/test_rhcloud_insights.py index a57488414e3..6ba96238d21 100644 --- a/tests/foreman/ui/test_rhcloud_insights.py +++ b/tests/foreman/ui/test_rhcloud_insights.py @@ -22,9 +22,7 @@ from wait_for import wait_for from robottelo.config import settings -from robottelo.constants import DEFAULT_LOC -from robottelo.constants import DNF_RECOMMENDATION -from robottelo.constants import OPENSSH_RECOMMENDATION +from robottelo.constants import DEFAULT_LOC, DNF_RECOMMENDATION, OPENSSH_RECOMMENDATION def create_insights_vulnerability(insights_vm): @@ -64,7 +62,7 @@ def test_rhcloud_insights_e2e( :CaseImportance: Critical - :BZ: 1965901, 1962048 + :BZ: 1965901, 1962048, 1976754 :customerscenario: true @@ -189,29 +187,6 @@ def test_recommendation_sync_for_satellite(): """ -@pytest.mark.stubbed -def test_allow_auto_insights_sync_setting(): - """Test "allow_auto_insights_sync" setting. - - :id: ddc4ed5b-43c0-4121-bf2c-b8e040e45379 - - :Steps: - 1. Register few satellite content host with insights. - 2. Enable "allow_auto_insights_sync" setting. - 3. Wait for "InsightsScheduledSync" task to run. - - :expectedresults: - 1. Satellite has "Inventory scheduled sync" recurring logic, which syncs - inventory status automatically if "Automatic inventory upload" setting is enabled. - - :CaseImportance: Medium - - :BZ: 1865879 - - :CaseAutomation: ManualOnly - """ - - @pytest.mark.stubbed def test_host_sorting_based_on_recommendation_count(): """Verify that hosts can be sorted and filtered based on insights @@ -300,29 +275,28 @@ def test_host_details_page( handle_exception=True, ) # Verify Insights status of host. - result = session.host.host_status(rhel_insights_vm.hostname) - assert 'Insights: Reporting' in result - assert 'Inventory: Successfully uploaded to your RH cloud inventory' in result - result = session.host.search(rhel_insights_vm.hostname)[0] + result = session.host_new.get_host_statuses(rhel_insights_vm.hostname) + assert result['Insights']['Status'] == 'Reporting' + assert result['Inventory']['Status'] == 'Successfully uploaded to your RH cloud inventory' + result = session.host_new.search(rhel_insights_vm.hostname)[0] assert result['Name'] == rhel_insights_vm.hostname assert int(result['Recommendations']) > 0 - values = session.host.get_details(rhel_insights_vm.hostname) - # Note: Reading host properties adds 'clear' to original value. - assert ( - values['properties']['properties_table']['Inventory'] - == 'Successfully uploaded to your RH cloud inventory clear' - ) + values = session.host_new.get_host_statuses(rhel_insights_vm.hostname) + assert values['Inventory']['Status'] == 'Successfully uploaded to your RH cloud inventory' # Read the recommendations listed in Insights tab present on host details page - insights_recommendations = session.host_new.insights_tab(rhel_insights_vm.hostname) + insights_recommendations = session.host_new.get_insights(rhel_insights_vm.hostname)[ + 'recommendations_table' + ] for recommendation in insights_recommendations: - if recommendation['name'] == DNF_RECOMMENDATION: - assert recommendation['label'] == 'Moderate' - assert DNF_RECOMMENDATION in recommendation['text'] + if recommendation['Recommendation'] == DNF_RECOMMENDATION: + assert recommendation['Total risk'] == 'Moderate' + assert DNF_RECOMMENDATION in recommendation['Recommendation'] assert len(insights_recommendations) == int(result['Recommendations']) # Test Recommendation button present on host details page - recommendations = session.host.read_insights_recommendations(rhel_insights_vm.hostname) + recommendations = session.host_new.get_insights(rhel_insights_vm.hostname)[ + 'recommendations_table' + ] assert len(recommendations), 'No recommendations were found' - assert recommendations[0]['Hostname'] == rhel_insights_vm.hostname assert int(result['Recommendations']) == len(recommendations) # Delete host rhel_insights_vm.nailgun_host.delete() @@ -379,7 +353,7 @@ def test_insights_registration_with_capsule( session.organization.select(org_name=org.name) session.location.select(loc_name=DEFAULT_LOC) # Generate host registration command - cmd = session.host.get_register_command( + cmd = session.host_new.get_register_command( { 'general.operating_system': default_os.title, 'general.orgnization': org.name, @@ -394,8 +368,8 @@ def test_insights_registration_with_capsule( rhel_contenthost.execute(cmd) assert rhel_contenthost.subscribed assert rhel_contenthost.execute('insights-client --test-connection').status == 0 - values = session.host.get_details(rhel_contenthost.hostname) - assert values['properties']['properties_table']['Insights'] == 'Reporting clear' + values = session.host_new.get_host_statuses(rhel_contenthost.hostname) + assert values['Insights']['Status'] == 'Reporting' # Clean insights status result = module_target_sat.run( f'foreman-rake rh_cloud_insights:clean_statuses SEARCH="{rhel_contenthost.hostname}"' @@ -405,13 +379,12 @@ def test_insights_registration_with_capsule( # Workaround for not reading old data. session.browser.refresh() # Verify that Insights status is cleared. - values = session.host.get_details(rhel_contenthost.hostname) - with pytest.raises(KeyError): - values['properties']['properties_table']['Insights'] + values = session.host_new.get_host_statuses(rhel_contenthost.hostname) + assert values['Insights']['Status'] == 'N/A' result = rhel_contenthost.run('insights-client') assert result.status == 0 # Workaround for not reading old data. session.browser.refresh() # Verify that Insights status again. - values = session.host.get_details(rhel_contenthost.hostname) - assert values['properties']['properties_table']['Insights'] == 'Reporting clear' + values = session.host_new.get_host_statuses(rhel_contenthost.hostname) + assert values['Insights']['Status'] == 'Reporting' diff --git a/tests/foreman/ui/test_rhcloud_inventory.py b/tests/foreman/ui/test_rhcloud_inventory.py index 32ad7f9d030..743ef8925db 100644 --- a/tests/foreman/ui/test_rhcloud_inventory.py +++ b/tests/foreman/ui/test_rhcloud_inventory.py @@ -16,16 +16,17 @@ :Upstream: No """ -from datetime import datetime -from datetime import timedelta +from datetime import datetime, timedelta import pytest from wait_for import wait_for from robottelo.constants import DEFAULT_LOC -from robottelo.utils.io import get_local_file_data -from robottelo.utils.io import get_remote_report_checksum -from robottelo.utils.io import get_report_data +from robottelo.utils.io import ( + get_local_file_data, + get_remote_report_checksum, + get_report_data, +) def common_assertion(report_path, inventory_data, org, satellite): @@ -78,7 +79,7 @@ def test_rhcloud_inventory_e2e( 5. JSON files inside report can be parsed 6. metadata.json lists all and only slice JSON files in tar 7. Host counts in metadata matches host counts in slices - 8. Assert Hostnames, IP addresses, and installed packages are present in report. + 8. Assert Hostnames, IP addresses, and installed packages are present in the report. :CaseImportance: Critical @@ -91,6 +92,7 @@ def test_rhcloud_inventory_e2e( session.location.select(loc_name=DEFAULT_LOC) timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') session.cloudinventory.generate_report(org.name) + # wait_for_tasks report generation task to finish. wait_for( lambda: module_target_sat.api.ForemanTask() .search( @@ -108,12 +110,15 @@ def test_rhcloud_inventory_e2e( ) report_path = session.cloudinventory.download_report(org.name) inventory_data = session.cloudinventory.read(org.name) - + # Verify that generated archive is valid. common_assertion(report_path, inventory_data, org, module_target_sat) + # Get report data for assertion json_data = get_report_data(report_path) + # Verify that hostnames are present in the report. hostnames = [host['fqdn'] for host in json_data['hosts']] assert virtual_host.hostname in hostnames assert baremetal_host.hostname in hostnames + # Verify that ip_addresses are present report. ip_addresses = [ host['system_profile']['network_interfaces'][0]['ipv4_addresses'][0] for host in json_data['hosts'] @@ -123,6 +128,7 @@ def test_rhcloud_inventory_e2e( assert baremetal_host.ip_addr in ip_addresses assert virtual_host.ip_addr in ipv4_addresses assert baremetal_host.ip_addr in ipv4_addresses + # Verify that packages are included in report all_host_profiles = [host['system_profile'] for host in json_data['hosts']] for host_profiles in all_host_profiles: assert 'installed_packages' in host_profiles @@ -131,29 +137,45 @@ def test_rhcloud_inventory_e2e( @pytest.mark.run_in_one_thread @pytest.mark.tier3 -def test_obfuscate_host_names( +def test_rh_cloud_inventory_settings( module_target_sat, inventory_settings, rhcloud_manifest_org, rhcloud_registered_hosts, ): - """Test whether `Obfuscate host names` setting works as expected. + """Test whether `Obfuscate host names`, `Obfuscate host ipv4 addresses` + and `Exclude Packages` setting works as expected. :id: 3c3a36b6-6566-446b-b803-3f8f9aab2511 + :customerscenario: true + :Steps: 1. Prepare machine and upload its data to Insights. 2. Go to Configure > Inventory upload > enable “Obfuscate host names” setting. - 3. Generate report after enabling the setting. - 4. Check if host names are obfuscated in generated reports. - 5. Disable previous setting. - 6. Go to Administer > Settings > RH Cloud and enable "Obfuscate host names" setting. - 7. Generate report after enabling the setting. - 8. Check if host names are obfuscated in generated reports. + 3. Go to Configure > Inventory upload > enable “Obfuscate host ipv4 addresses” setting. + 4. Go to Configure > Inventory upload > enable “Exclude Packages” setting. + 5. Generate report after enabling the settings. + 6. Check if host names are obfuscated in generated reports. + 7. Check if hosts ipv4 addresses are obfuscated in generated reports. + 8. Check if packages are excluded from generated reports. + 9. Disable previous setting. + 10. Go to Administer > Settings > RH Cloud and enable "Obfuscate host names" setting. + 11. Go to Administer > Settings > RH Cloud and enable "Obfuscate IPs" setting. + 12. Go to Administer > Settings > RH Cloud and enable + "Don't upload installed packages" setting. + 13. Generate report after enabling the setting. + 14. Check if host names are obfuscated in generated reports. + 15. Check if hosts ipv4 addresses are obfuscated in generated reports. + 16. Check if packages are excluded from generated reports. :expectedresults: 1. Obfuscated host names in reports generated. + 2. Obfuscated host ipv4 addresses in generated reports. + 3. Packages are excluded from reports generated. + + :BZ: 1852594, 1889690, 1852594 :CaseAutomation: Automated """ @@ -162,8 +184,10 @@ def test_obfuscate_host_names( with module_target_sat.ui_session() as session: session.organization.select(org_name=org.name) session.location.select(loc_name=DEFAULT_LOC) - # Enable obfuscate_hostnames setting on inventory page. + # Enable settings on inventory page. session.cloudinventory.update({'obfuscate_hostnames': True}) + session.cloudinventory.update({'obfuscate_ips': True}) + session.cloudinventory.update({'exclude_packages': True}) timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') session.cloudinventory.generate_report(org.name) # wait_for_tasks report generation task to finish. @@ -184,125 +208,19 @@ def test_obfuscate_host_names( ) report_path = session.cloudinventory.download_report(org.name) inventory_data = session.cloudinventory.read(org.name) - - # Assert that obfuscate_hostnames is enabled. + # Verify settings are enabled. assert inventory_data['obfuscate_hostnames'] is True - # Assert that generated archive is valid. + assert inventory_data['obfuscate_ips'] is True + assert inventory_data['exclude_packages'] is True + # Verify that generated archive is valid. common_assertion(report_path, inventory_data, org, module_target_sat) # Get report data for assertion json_data = get_report_data(report_path) + # Verify that hostnames are obfuscated from the report. hostnames = [host['fqdn'] for host in json_data['hosts']] assert virtual_host.hostname not in hostnames assert baremetal_host.hostname not in hostnames - # Assert that host ip_addresses are present in the report. - ipv4_addresses = [host['ip_addresses'][0] for host in json_data['hosts']] - assert virtual_host.ip_addr in ipv4_addresses - assert baremetal_host.ip_addr in ipv4_addresses - # Disable obfuscate_hostnames setting on inventory page. - session.cloudinventory.update({'obfuscate_hostnames': False}) - - # Enable obfuscate_hostnames setting. - module_target_sat.update_setting('obfuscate_inventory_hostnames', True) - timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') - session.cloudinventory.generate_report(org.name) - # wait_for_tasks report generation task to finish. - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search( - query={ - 'search': f'label = ForemanInventoryUpload::Async::GenerateReportJob ' - f'and started_at >= "{timestamp}"' - } - )[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - report_path = session.cloudinventory.download_report(org.name) - inventory_data = session.cloudinventory.read(org.name) - - assert inventory_data['obfuscate_hostnames'] is True - json_data = get_report_data(report_path) - hostnames = [host['fqdn'] for host in json_data['hosts']] - assert virtual_host.hostname not in hostnames - assert baremetal_host.hostname not in hostnames - ipv4_addresses = [host['ip_addresses'][0] for host in json_data['hosts']] - assert virtual_host.ip_addr in ipv4_addresses - assert baremetal_host.ip_addr in ipv4_addresses - - -@pytest.mark.run_in_one_thread -@pytest.mark.tier3 -def test_obfuscate_host_ipv4_addresses( - module_target_sat, - inventory_settings, - rhcloud_manifest_org, - rhcloud_registered_hosts, -): - """Test whether `Obfuscate host ipv4 addresses` setting works as expected. - - :id: c0fc4ee9-a6a1-42c0-83f0-0f131ca9ab41 - - :customerscenario: true - - :Steps: - - 1. Prepare machine and upload its data to Insights. - 2. Go to Configure > Inventory upload > enable “Obfuscate host ipv4 addresses” setting. - 3. Generate report after enabling the setting. - 4. Check if hosts ipv4 addresses are obfuscated in generated reports. - 5. Disable previous setting. - 6. Go to Administer > Settings > RH Cloud and enable "Obfuscate IPs" setting. - 7. Generate report after enabling the setting. - 8. Check if hosts ipv4 addresses are obfuscated in generated reports. - - :expectedresults: - 1. Obfuscated host ipv4 addresses in generated reports. - - :BZ: 1852594, 1889690 - - :CaseAutomation: Automated - """ - org = rhcloud_manifest_org - virtual_host, baremetal_host = rhcloud_registered_hosts - with module_target_sat.ui_session() as session: - session.organization.select(org_name=org.name) - session.location.select(loc_name=DEFAULT_LOC) - # Enable obfuscate_ips setting on inventory page. - session.cloudinventory.update({'obfuscate_ips': True}) - timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') - session.cloudinventory.generate_report(org.name) - # wait_for_tasks report generation task to finish. - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search( - query={ - 'search': f'label = ForemanInventoryUpload::Async::GenerateReportJob ' - f'and started_at >= "{timestamp}"' - } - )[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - report_path = session.cloudinventory.download_report(org.name) - inventory_data = session.cloudinventory.read(org.name) - # Assert that obfuscate_ips is enabled. - assert inventory_data['obfuscate_ips'] is True - # Assert that generated archive is valid. - common_assertion(report_path, inventory_data, org, module_target_sat) - # Get report data for assertion - json_data = get_report_data(report_path) - hostnames = [host['fqdn'] for host in json_data['hosts']] - assert virtual_host.hostname in hostnames - assert baremetal_host.hostname in hostnames - # Assert that ip_addresses are obfuscated from report. + # Verify that ip_addresses are obfuscated from the report. ip_addresses = [ host['system_profile']['network_interfaces'][0]['ipv4_addresses'][0] for host in json_data['hosts'] @@ -312,11 +230,18 @@ def test_obfuscate_host_ipv4_addresses( assert baremetal_host.ip_addr not in ip_addresses assert virtual_host.ip_addr not in ipv4_addresses assert baremetal_host.ip_addr not in ipv4_addresses - # Disable obfuscate_ips setting on inventory page. + # Verify that packages are excluded from report + all_host_profiles = [host['system_profile'] for host in json_data['hosts']] + for host_profiles in all_host_profiles: + assert 'installed_packages' not in host_profiles + # Disable settings on inventory page. + session.cloudinventory.update({'obfuscate_hostnames': False}) session.cloudinventory.update({'obfuscate_ips': False}) - - # Enable obfuscate_inventory_ips setting. + session.cloudinventory.update({'exclude_packages': False}) + # Enable settings, the one on the main settings page. + module_target_sat.update_setting('obfuscate_inventory_hostnames', True) module_target_sat.update_setting('obfuscate_inventory_ips', True) + module_target_sat.update_setting('exclude_installed_packages', True) timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') session.cloudinventory.generate_report(org.name) # wait_for_tasks report generation task to finish. @@ -337,13 +262,17 @@ def test_obfuscate_host_ipv4_addresses( ) report_path = session.cloudinventory.download_report(org.name) inventory_data = session.cloudinventory.read(org.name) - + # Verify settings are enabled. + assert inventory_data['obfuscate_hostnames'] is True assert inventory_data['obfuscate_ips'] is True + assert inventory_data['exclude_packages'] is True # Get report data for assertion json_data = get_report_data(report_path) + # Verify that hostnames are obfuscated from the report. hostnames = [host['fqdn'] for host in json_data['hosts']] - assert virtual_host.hostname in hostnames - assert baremetal_host.hostname in hostnames + assert virtual_host.hostname not in hostnames + assert baremetal_host.hostname not in hostnames + # Verify that ip_addresses are obfuscated from the report. ip_addresses = [ host['system_profile']['network_interfaces'][0]['ipv4_addresses'][0] for host in json_data['hosts'] @@ -353,109 +282,7 @@ def test_obfuscate_host_ipv4_addresses( assert baremetal_host.ip_addr not in ip_addresses assert virtual_host.ip_addr not in ipv4_addresses assert baremetal_host.ip_addr not in ipv4_addresses - - -@pytest.mark.run_in_one_thread -@pytest.mark.tier3 -def test_exclude_packages_setting( - module_target_sat, - inventory_settings, - rhcloud_manifest_org, - rhcloud_registered_hosts, -): - """Test whether `Exclude Packages` setting works as expected. - - :id: 646093fa-fdd6-4f70-82aa-725e31fa3f12 - - :customerscenario: true - - :Steps: - - 1. Prepare machine and upload its data to Insights - 2. Go to Configure > Inventory upload > enable “Exclude Packages” setting. - 3. Generate report after enabling the setting. - 4. Check if packages are excluded from generated reports. - 5. Disable previous setting. - 6. Go to Administer > Settings > RH Cloud and enable - "Don't upload installed packages" setting. - 7. Generate report after enabling the setting. - 8. Check if packages are excluded from generated reports. - - :expectedresults: - 1. Packages are excluded from reports generated. - - :BZ: 1852594 - - :CaseAutomation: Automated - """ - org = rhcloud_manifest_org - virtual_host, baremetal_host = rhcloud_registered_hosts - with module_target_sat.ui_session() as session: - session.organization.select(org_name=org.name) - session.location.select(loc_name=DEFAULT_LOC) - # Enable exclude_packages setting on inventory page. - session.cloudinventory.update({'exclude_packages': True}) - timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') - session.cloudinventory.generate_report(org.name) - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search( - query={ - 'search': f'label = ForemanInventoryUpload::Async::GenerateReportJob ' - f'and started_at >= "{timestamp}"' - } - )[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - report_path = session.cloudinventory.download_report(org.name) - inventory_data = session.cloudinventory.read(org.name) - assert inventory_data['exclude_packages'] is True - # Disable exclude_packages setting on inventory page. - session.cloudinventory.update({'exclude_packages': False}) - # Assert that generated archive is valid. - common_assertion(report_path, inventory_data, org, module_target_sat) - # Get report data for assertion - json_data = get_report_data(report_path) - # Assert that right hosts are present in report. - hostnames = [host['fqdn'] for host in json_data['hosts']] - assert virtual_host.hostname in hostnames - assert baremetal_host.hostname in hostnames - # Assert that packages are excluded from report - all_host_profiles = [host['system_profile'] for host in json_data['hosts']] - for host_profiles in all_host_profiles: - assert 'installed_packages' not in host_profiles - - # Enable exclude_installed_packages setting. - module_target_sat.update_setting('exclude_installed_packages', True) - timestamp = (datetime.utcnow() - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M') - session.cloudinventory.generate_report(org.name) - wait_for( - lambda: module_target_sat.api.ForemanTask() - .search( - query={ - 'search': f'label = ForemanInventoryUpload::Async::GenerateReportJob ' - f'and started_at >= "{timestamp}"' - } - )[0] - .result - == 'success', - timeout=400, - delay=15, - silent_failure=True, - handle_exception=True, - ) - report_path = session.cloudinventory.download_report(org.name) - inventory_data = session.cloudinventory.read(org.name) - assert inventory_data['exclude_packages'] is True - json_data = get_report_data(report_path) - hostnames = [host['fqdn'] for host in json_data['hosts']] - assert virtual_host.hostname in hostnames - assert baremetal_host.hostname in hostnames + # Verify that packages are excluded from report all_host_profiles = [host['system_profile'] for host in json_data['hosts']] for host_profiles in all_host_profiles: assert 'installed_packages' not in host_profiles @@ -529,54 +356,3 @@ def test_rhcloud_inventory_without_manifest(session, module_org, target_sat): f'Skipping organization {module_org.name}, no candlepin certificate defined.' in inventory_data['uploading']['terminal'] ) - - -@pytest.mark.stubbed -def test_automatic_inventory_upload_enabled_setting(): - """Test "Automatic inventory upload" setting. - - :id: e84790c6-1700-46c4-9bf8-d8f1e63a7f1f - - :Steps: - 1. Register satellite content host with insights. - 2. Sync inventory status. - 3. Wait for "Inventory scheduled sync" task to execute. - (Change wait time to 1 minute for testing.) - 4. Check whether the satellite shows successful inventory upload for the host. - 5. Disable "Automatic inventory upload" setting. - 6. Unregister host from insights OR Delete host from cloud. - 7. Wait for "Inventory scheduled sync" task to execute. - - :expectedresults: - 1. When "Automatic inventory upload" setting is disabled then - "Inventory scheduled sync" task doesn't sync the inventory status. - - :CaseImportance: Medium - - :BZ: 1965239 - - :CaseAutomation: ManualOnly - """ - - -@pytest.mark.stubbed -def test_automatic_inventory_upload_disabled_setting(): - """Test "Automatic inventory upload" setting. - - :id: 2c830833-3f92-497c-bbb9-f485a1d8eb47 - - :Steps: - 1. Register few hosts with satellite. - 2. Enable "Automatic inventory upload" setting. - 3. Wait for "Inventory scheduled sync" recurring logic to run. - - :expectedresults: - 1. Satellite has "Inventory scheduled sync" recurring logic, which syncs - inventory status automatically if "Automatic inventory upload" setting is enabled. - - :CaseImportance: Medium - - :BZ: 1962695 - - :CaseAutomation: ManualOnly - """ diff --git a/tests/foreman/ui/test_role.py b/tests/foreman/ui/test_role.py index c3418a43588..86b93fd7baa 100644 --- a/tests/foreman/ui/test_role.py +++ b/tests/foreman/ui/test_role.py @@ -18,13 +18,12 @@ """ import random -import pytest from airgun.session import Session from nailgun import entities from navmazing import NavigationTriesExceeded +import pytest -from robottelo.constants import PERMISSIONS_UI -from robottelo.constants import ROLES +from robottelo.constants import PERMISSIONS_UI, ROLES from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_settings.py b/tests/foreman/ui/test_settings.py index de752f1c449..ade4cd9afbe 100644 --- a/tests/foreman/ui/test_settings.py +++ b/tests/foreman/ui/test_settings.py @@ -18,15 +18,14 @@ """ import math -import pytest from airgun.session import Session from fauxfactory import gen_url from nailgun import entities +import pytest from robottelo.cli.user import User from robottelo.config import settings -from robottelo.utils.datafactory import filtered_datapoint -from robottelo.utils.datafactory import gen_string +from robottelo.utils.datafactory import filtered_datapoint, gen_string @filtered_datapoint diff --git a/tests/foreman/ui/test_smartclassparameter.py b/tests/foreman/ui/test_smartclassparameter.py index 9a27ce4f0ef..98c3ba430c3 100644 --- a/tests/foreman/ui/test_smartclassparameter.py +++ b/tests/foreman/ui/test_smartclassparameter.py @@ -16,8 +16,7 @@ :Upstream: No """ -from random import choice -from random import uniform +from random import choice, uniform import pytest import yaml diff --git a/tests/foreman/ui/test_subnet.py b/tests/foreman/ui/test_subnet.py index 814ea6bae10..f188820d4ba 100644 --- a/tests/foreman/ui/test_subnet.py +++ b/tests/foreman/ui/test_subnet.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_ipaddr +import pytest from robottelo.utils.datafactory import gen_string diff --git a/tests/foreman/ui/test_subscription.py b/tests/foreman/ui/test_subscription.py index a56c5796f87..674b91d7401 100644 --- a/tests/foreman/ui/test_subscription.py +++ b/tests/foreman/ui/test_subscription.py @@ -16,22 +16,24 @@ :Upstream: No """ -import time from tempfile import mkstemp +import time -import pytest from airgun.session import Session from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.cli.factory import make_virt_who_config from robottelo.config import settings -from robottelo.constants import DEFAULT_SUBSCRIPTION_NAME -from robottelo.constants import PRDS -from robottelo.constants import REPOS -from robottelo.constants import REPOSET -from robottelo.constants import VDC_SUBSCRIPTION_NAME -from robottelo.constants import VIRT_WHO_HYPERVISOR_TYPES +from robottelo.constants import ( + DEFAULT_SUBSCRIPTION_NAME, + PRDS, + REPOS, + REPOSET, + VDC_SUBSCRIPTION_NAME, + VIRT_WHO_HYPERVISOR_TYPES, +) from robottelo.utils.manifest import clone pytestmark = [pytest.mark.run_in_one_thread, pytest.mark.skip_if_not_set('fake_manifest')] diff --git a/tests/foreman/ui/test_sync.py b/tests/foreman/ui/test_sync.py index ae5e0cc58bc..30ccce8c95f 100644 --- a/tests/foreman/ui/test_sync.py +++ b/tests/foreman/ui/test_sync.py @@ -16,17 +16,19 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string from nailgun import entities +import pytest from robottelo.config import settings -from robottelo.constants import CONTAINER_REGISTRY_HUB -from robottelo.constants import CONTAINER_UPSTREAM_NAME -from robottelo.constants import PRDS -from robottelo.constants import REPO_TYPE -from robottelo.constants import REPOS -from robottelo.constants import REPOSET +from robottelo.constants import ( + CONTAINER_REGISTRY_HUB, + CONTAINER_UPSTREAM_NAME, + PRDS, + REPO_TYPE, + REPOS, + REPOSET, +) from robottelo.constants.repos import FEDORA_OSTREE_REPO diff --git a/tests/foreman/ui/test_syncplan.py b/tests/foreman/ui/test_syncplan.py index 0632af2a034..10e1221cb06 100644 --- a/tests/foreman/ui/test_syncplan.py +++ b/tests/foreman/ui/test_syncplan.py @@ -16,17 +16,15 @@ :Upstream: No """ +from datetime import datetime, timedelta import time -from datetime import datetime -from datetime import timedelta -import pytest from fauxfactory import gen_choice from nailgun import entities +import pytest from robottelo.constants import SYNC_INTERVAL -from robottelo.utils.datafactory import gen_string -from robottelo.utils.datafactory import valid_cron_expressions +from robottelo.utils.datafactory import gen_string, valid_cron_expressions def validate_repo_content(repo, content_types, after_sync=True): @@ -54,7 +52,7 @@ def validate_repo_content(repo, content_types, after_sync=True): @pytest.mark.tier2 -def test_positive_end_to_end(session, module_org): +def test_positive_end_to_end(session, module_org, target_sat): """Perform end to end scenario for sync plan component :id: 39c140a6-ca65-4b6a-a640-4a023a2f0f12 @@ -99,7 +97,8 @@ def test_positive_end_to_end(session, module_org): assert syncplan_values['details']['description'] == new_description # Create and add two products to sync plan for _ in range(2): - product = entities.Product(organization=module_org).create() + product = target_sat.api.Product(organization=module_org).create() + target_sat.api.Repository(product=product).create() session.syncplan.add_product(plan_name, product.name) # Remove a product and assert syncplan still searchable session.syncplan.remove_product(plan_name, product.name) diff --git a/tests/foreman/ui/test_templatesync.py b/tests/foreman/ui/test_templatesync.py index cb91a50df4e..cfbea828a95 100644 --- a/tests/foreman/ui/test_templatesync.py +++ b/tests/foreman/ui/test_templatesync.py @@ -14,14 +14,13 @@ :Upstream: No """ -import pytest -import requests from fauxfactory import gen_string from nailgun import entities +import pytest +import requests from robottelo.config import settings -from robottelo.constants import FOREMAN_TEMPLATE_IMPORT_URL -from robottelo.constants import FOREMAN_TEMPLATE_ROOT_DIR +from robottelo.constants import FOREMAN_TEMPLATE_IMPORT_URL, FOREMAN_TEMPLATE_ROOT_DIR @pytest.fixture(scope='module') diff --git a/tests/foreman/ui/test_user.py b/tests/foreman/ui/test_user.py index d0847a9d0d6..892024ffc8d 100644 --- a/tests/foreman/ui/test_user.py +++ b/tests/foreman/ui/test_user.py @@ -18,14 +18,11 @@ """ import random -import pytest from airgun.session import Session -from fauxfactory import gen_email -from fauxfactory import gen_string +from fauxfactory import gen_email, gen_string +import pytest -from robottelo.constants import DEFAULT_ORG -from robottelo.constants import PERMISSIONS -from robottelo.constants import ROLES +from robottelo.constants import DEFAULT_ORG, PERMISSIONS, ROLES @pytest.mark.e2e diff --git a/tests/foreman/ui/test_usergroup.py b/tests/foreman/ui/test_usergroup.py index f899d4fc099..f5e2eaa9a96 100644 --- a/tests/foreman/ui/test_usergroup.py +++ b/tests/foreman/ui/test_usergroup.py @@ -16,10 +16,9 @@ :Upstream: No """ -import pytest -from fauxfactory import gen_string -from fauxfactory import gen_utf8 +from fauxfactory import gen_string, gen_utf8 from nailgun import entities +import pytest @pytest.mark.tier2 diff --git a/tests/foreman/ui/test_webhook.py b/tests/foreman/ui/test_webhook.py index 32cebf1a4b2..f3df30aef78 100644 --- a/tests/foreman/ui/test_webhook.py +++ b/tests/foreman/ui/test_webhook.py @@ -16,9 +16,8 @@ :Upstream: No """ +from fauxfactory import gen_string, gen_url import pytest -from fauxfactory import gen_string -from fauxfactory import gen_url @pytest.mark.tier1 diff --git a/tests/foreman/virtwho/api/test_esx.py b/tests/foreman/virtwho/api/test_esx.py index 069eefc969a..32a0b69e374 100644 --- a/tests/foreman/virtwho/api/test_esx.py +++ b/tests/foreman/virtwho/api/test_esx.py @@ -16,19 +16,21 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import create_http_proxy -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_guest_info +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + create_http_proxy, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + get_guest_info, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_esx_sca.py b/tests/foreman/virtwho/api/test_esx_sca.py index 2388d0e924e..cd9cc3d3140 100644 --- a/tests/foreman/virtwho/api/test_esx_sca.py +++ b/tests/foreman/virtwho/api/test_esx_sca.py @@ -14,18 +14,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import create_http_proxy -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + create_http_proxy, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_hyperv.py b/tests/foreman/virtwho/api/test_hyperv.py index 084975d00a3..ec7c37ae6e7 100644 --- a/tests/foreman/virtwho/api/test_hyperv.py +++ b/tests/foreman/virtwho/api/test_hyperv.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_hyperv_sca.py b/tests/foreman/virtwho/api/test_hyperv_sca.py index 5788ab68e13..67f18934c8d 100644 --- a/tests/foreman/virtwho/api/test_hyperv_sca.py +++ b/tests/foreman/virtwho/api/test_hyperv_sca.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_kubevirt.py b/tests/foreman/virtwho/api/test_kubevirt.py index 0ff6ade433d..e2fbe884f9a 100644 --- a/tests/foreman/virtwho/api/test_kubevirt.py +++ b/tests/foreman/virtwho/api/test_kubevirt.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_guest_info +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + get_guest_info, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_kubevirt_sca.py b/tests/foreman/virtwho/api/test_kubevirt_sca.py index 3dfbd125ebf..f64b719e9c4 100644 --- a/tests/foreman/virtwho/api/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/api/test_kubevirt_sca.py @@ -14,15 +14,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_libvirt.py b/tests/foreman/virtwho/api/test_libvirt.py index b1f105938e5..eb0806e5753 100644 --- a/tests/foreman/virtwho/api/test_libvirt.py +++ b/tests/foreman/virtwho/api/test_libvirt.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_libvirt_sca.py b/tests/foreman/virtwho/api/test_libvirt_sca.py index afebdf01eb9..bead5b8e95f 100644 --- a/tests/foreman/virtwho/api/test_libvirt_sca.py +++ b/tests/foreman/virtwho/api/test_libvirt_sca.py @@ -14,15 +14,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_nutanix.py b/tests/foreman/virtwho/api/test_nutanix.py index 147c6246d1e..5e4d4c51f34 100644 --- a/tests/foreman/virtwho/api/test_nutanix.py +++ b/tests/foreman/virtwho/api/test_nutanix.py @@ -16,18 +16,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import check_message_in_rhsm_log -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_guest_info -from robottelo.utils.virtwho import get_hypervisor_ahv_mapping +from robottelo.utils.virtwho import ( + check_message_in_rhsm_log, + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + get_guest_info, + get_hypervisor_ahv_mapping, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/api/test_nutanix_sca.py b/tests/foreman/virtwho/api/test_nutanix_sca.py index b57b0eefb8c..05287279231 100644 --- a/tests/foreman/virtwho/api/test_nutanix_sca.py +++ b/tests/foreman/virtwho/api/test_nutanix_sca.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_esx.py b/tests/foreman/virtwho/cli/test_esx.py index 613f69acf0f..fe2b1827bf6 100644 --- a/tests/foreman/virtwho/cli/test_esx.py +++ b/tests/foreman/virtwho/cli/test_esx.py @@ -18,22 +18,24 @@ """ import re +from fauxfactory import gen_string import pytest import requests -from fauxfactory import gen_string from robottelo.cli.user import User from robottelo.config import settings -from robottelo.utils.virtwho import create_http_proxy -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import hypervisor_json_create -from robottelo.utils.virtwho import virtwho_package_locked +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + create_http_proxy, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + hypervisor_json_create, + virtwho_package_locked, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_esx_sca.py b/tests/foreman/virtwho/cli/test_esx_sca.py index c82520b30fc..df15cce8105 100644 --- a/tests/foreman/virtwho/cli/test_esx_sca.py +++ b/tests/foreman/virtwho/cli/test_esx_sca.py @@ -16,22 +16,24 @@ """ import re +from fauxfactory import gen_string import pytest import requests -from fauxfactory import gen_string from robottelo.cli.user import User from robottelo.config import settings -from robottelo.utils.virtwho import create_http_proxy -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import hypervisor_json_create -from robottelo.utils.virtwho import virtwho_package_locked +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + create_http_proxy, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + hypervisor_json_create, + virtwho_package_locked, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_hyperv.py b/tests/foreman/virtwho/cli/test_hyperv.py index 6ccb39c6bd2..1fa31db9f00 100644 --- a/tests/foreman/virtwho/cli/test_hyperv.py +++ b/tests/foreman/virtwho/cli/test_hyperv.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_hyperv_sca.py b/tests/foreman/virtwho/cli/test_hyperv_sca.py index 715ec1eafa1..e3909489e21 100644 --- a/tests/foreman/virtwho/cli/test_hyperv_sca.py +++ b/tests/foreman/virtwho/cli/test_hyperv_sca.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_kubevirt.py b/tests/foreman/virtwho/cli/test_kubevirt.py index 32d1a75416b..c6d38de60dd 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt.py +++ b/tests/foreman/virtwho/cli/test_kubevirt.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_kubevirt_sca.py b/tests/foreman/virtwho/cli/test_kubevirt_sca.py index 4c86aa21f51..99e4335c9f6 100644 --- a/tests/foreman/virtwho/cli/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/cli/test_kubevirt_sca.py @@ -14,15 +14,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_libvirt.py b/tests/foreman/virtwho/cli/test_libvirt.py index 59508ba74a7..1f5b034b473 100644 --- a/tests/foreman/virtwho/cli/test_libvirt.py +++ b/tests/foreman/virtwho/cli/test_libvirt.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_libvirt_sca.py b/tests/foreman/virtwho/cli/test_libvirt_sca.py index 02550772ca6..b29ffaf667f 100644 --- a/tests/foreman/virtwho/cli/test_libvirt_sca.py +++ b/tests/foreman/virtwho/cli/test_libvirt_sca.py @@ -14,15 +14,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_nutanix.py b/tests/foreman/virtwho/cli/test_nutanix.py index 10599c55c00..9b9437d0386 100644 --- a/tests/foreman/virtwho/cli/test_nutanix.py +++ b/tests/foreman/virtwho/cli/test_nutanix.py @@ -16,17 +16,19 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import check_message_in_rhsm_log -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_hypervisor_ahv_mapping +from robottelo.utils.virtwho import ( + check_message_in_rhsm_log, + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, + get_hypervisor_ahv_mapping, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/cli/test_nutanix_sca.py b/tests/foreman/virtwho/cli/test_nutanix_sca.py index b18a82cd670..59ba58f6f60 100644 --- a/tests/foreman/virtwho/cli/test_nutanix_sca.py +++ b/tests/foreman/virtwho/cli/test_nutanix_sca.py @@ -16,15 +16,17 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/conftest.py b/tests/foreman/virtwho/conftest.py index 81709b551ae..0bd09647bf6 100644 --- a/tests/foreman/virtwho/conftest.py +++ b/tests/foreman/virtwho/conftest.py @@ -1,6 +1,6 @@ -import pytest from airgun.session import Session from fauxfactory import gen_string +import pytest from requests.exceptions import HTTPError from robottelo.logging import logger diff --git a/tests/foreman/virtwho/ui/test_esx.py b/tests/foreman/virtwho/ui/test_esx.py index c88897294d4..f38590b8ddf 100644 --- a/tests/foreman/virtwho/ui/test_esx.py +++ b/tests/foreman/virtwho/ui/test_esx.py @@ -18,27 +18,29 @@ """ from datetime import datetime -import pytest from airgun.session import Session from fauxfactory import gen_string +import pytest from robottelo.config import settings from robottelo.utils.datafactory import valid_emails_list -from robottelo.utils.virtwho import add_configure_option -from robottelo.utils.virtwho import create_http_proxy -from robottelo.utils.virtwho import delete_configure_option -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_guest_info -from robottelo.utils.virtwho import get_virtwho_status -from robottelo.utils.virtwho import restart_virtwho_service -from robottelo.utils.virtwho import update_configure_option +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + add_configure_option, + create_http_proxy, + delete_configure_option, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, + get_guest_info, + get_virtwho_status, + restart_virtwho_service, + update_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_esx_sca.py b/tests/foreman/virtwho/ui/test_esx_sca.py index d662bf0b807..6abda09c6e4 100644 --- a/tests/foreman/virtwho/ui/test_esx_sca.py +++ b/tests/foreman/virtwho/ui/test_esx_sca.py @@ -16,26 +16,28 @@ """ from datetime import datetime -import pytest from airgun.session import Session from fauxfactory import gen_string +import pytest from robottelo.config import settings from robottelo.utils.datafactory import valid_emails_list -from robottelo.utils.virtwho import add_configure_option -from robottelo.utils.virtwho import delete_configure_option -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_command_check -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import ETC_VIRTWHO_CONFIG -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_guest_info -from robottelo.utils.virtwho import get_virtwho_status -from robottelo.utils.virtwho import restart_virtwho_service -from robottelo.utils.virtwho import update_configure_option +from robottelo.utils.virtwho import ( + ETC_VIRTWHO_CONFIG, + add_configure_option, + delete_configure_option, + deploy_configure_by_command, + deploy_configure_by_command_check, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, + get_guest_info, + get_virtwho_status, + restart_virtwho_service, + update_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_hyperv.py b/tests/foreman/virtwho/ui/test_hyperv.py index e6dafffd15a..56c2bbdb476 100644 --- a/tests/foreman/virtwho/ui/test_hyperv.py +++ b/tests/foreman/virtwho/ui/test_hyperv.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_hyperv_sca.py b/tests/foreman/virtwho/ui/test_hyperv_sca.py index 140142bb419..d58d2c15ebd 100644 --- a/tests/foreman/virtwho/ui/test_hyperv_sca.py +++ b/tests/foreman/virtwho/ui/test_hyperv_sca.py @@ -14,16 +14,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_kubevirt.py b/tests/foreman/virtwho/ui/test_kubevirt.py index 20c5e6170e3..289e4f385f1 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt.py +++ b/tests/foreman/virtwho/ui/test_kubevirt.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_kubevirt_sca.py b/tests/foreman/virtwho/ui/test_kubevirt_sca.py index 569c5f7caca..c4b893947e7 100644 --- a/tests/foreman/virtwho/ui/test_kubevirt_sca.py +++ b/tests/foreman/virtwho/ui/test_kubevirt_sca.py @@ -14,16 +14,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_libvirt.py b/tests/foreman/virtwho/ui/test_libvirt.py index cd90836beb4..6c6b37fdc30 100644 --- a/tests/foreman/virtwho/ui/test_libvirt.py +++ b/tests/foreman/virtwho/ui/test_libvirt.py @@ -16,16 +16,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_libvirt_sca.py b/tests/foreman/virtwho/ui/test_libvirt_sca.py index 56c156a8380..415ff38a37b 100644 --- a/tests/foreman/virtwho/ui/test_libvirt_sca.py +++ b/tests/foreman/virtwho/ui/test_libvirt_sca.py @@ -14,16 +14,18 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_nutanix.py b/tests/foreman/virtwho/ui/test_nutanix.py index db04c6b6eea..d2a77961918 100644 --- a/tests/foreman/virtwho/ui/test_nutanix.py +++ b/tests/foreman/virtwho/ui/test_nutanix.py @@ -16,18 +16,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import check_message_in_rhsm_log -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_hypervisor_ahv_mapping +from robottelo.utils.virtwho import ( + check_message_in_rhsm_log, + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, + get_hypervisor_ahv_mapping, +) @pytest.fixture() diff --git a/tests/foreman/virtwho/ui/test_nutanix_sca.py b/tests/foreman/virtwho/ui/test_nutanix_sca.py index 7dd104a38ec..3b53d038d71 100644 --- a/tests/foreman/virtwho/ui/test_nutanix_sca.py +++ b/tests/foreman/virtwho/ui/test_nutanix_sca.py @@ -14,18 +14,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.config import settings -from robottelo.utils.virtwho import check_message_in_rhsm_log -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import deploy_configure_by_script -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_id -from robottelo.utils.virtwho import get_configure_option -from robottelo.utils.virtwho import get_hypervisor_ahv_mapping +from robottelo.utils.virtwho import ( + check_message_in_rhsm_log, + deploy_configure_by_command, + deploy_configure_by_script, + get_configure_command, + get_configure_file, + get_configure_id, + get_configure_option, + get_hypervisor_ahv_mapping, +) @pytest.fixture() diff --git a/tests/robottelo/conftest.py b/tests/robottelo/conftest.py index c093c969d12..df6419a4f24 100644 --- a/tests/robottelo/conftest.py +++ b/tests/robottelo/conftest.py @@ -3,8 +3,8 @@ from pathlib import Path from tempfile import NamedTemporaryFile -import pytest from fauxfactory import gen_string +import pytest @pytest.fixture(scope='session', autouse=True) diff --git a/tests/robottelo/test_cli.py b/tests/robottelo/test_cli.py index 5c2ad05baa4..78b0f6f0cf8 100644 --- a/tests/robottelo/test_cli.py +++ b/tests/robottelo/test_cli.py @@ -1,14 +1,16 @@ -import unittest from functools import partial +import unittest from unittest import mock import pytest -from robottelo.cli.base import Base -from robottelo.cli.base import CLIBaseError -from robottelo.cli.base import CLIDataBaseError -from robottelo.cli.base import CLIError -from robottelo.cli.base import CLIReturnCodeError +from robottelo.cli.base import ( + Base, + CLIBaseError, + CLIDataBaseError, + CLIError, + CLIReturnCodeError, +) class CLIClass(Base): diff --git a/tests/robottelo/test_datafactory.py b/tests/robottelo/test_datafactory.py index 7d5a6c12b7e..04e081a9b39 100644 --- a/tests/robottelo/test_datafactory.py +++ b/tests/robottelo/test_datafactory.py @@ -127,7 +127,7 @@ def test_return_type(self): ): assert isinstance(item, str) for item in datafactory.invalid_id_list(): - if not (isinstance(item, (str, int)) or item is None): + if not (isinstance(item, str | int) or item is None): pytest.fail('Unexpected data type') diff --git a/tests/robottelo/test_dependencies.py b/tests/robottelo/test_dependencies.py index 71dbee35466..185f0866737 100644 --- a/tests/robottelo/test_dependencies.py +++ b/tests/robottelo/test_dependencies.py @@ -3,10 +3,8 @@ def test_cryptography(): from cryptography.hazmat.backends import default_backend - from cryptography.hazmat.primitives import hashes - from cryptography.hazmat.primitives import serialization - from cryptography.hazmat.primitives.asymmetric import padding - from cryptography.hazmat.primitives.asymmetric import rsa + from cryptography.hazmat.primitives import hashes, serialization + from cryptography.hazmat.primitives.asymmetric import padding, rsa fake_key = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() @@ -111,9 +109,7 @@ def test_requests(): def test_tenacity(): - from tenacity import retry - from tenacity import stop_after_attempt - from tenacity import wait_fixed + from tenacity import retry, stop_after_attempt, wait_fixed @retry(stop=stop_after_attempt(3), wait=wait_fixed(1)) def test(): diff --git a/tests/robottelo/test_func_locker.py b/tests/robottelo/test_func_locker.py index e59f8b913e8..ed010e56076 100644 --- a/tests/robottelo/test_func_locker.py +++ b/tests/robottelo/test_func_locker.py @@ -1,8 +1,8 @@ import multiprocessing import os +from pathlib import Path import tempfile import time -from pathlib import Path import pytest diff --git a/tests/robottelo/test_func_shared.py b/tests/robottelo/test_func_shared.py index 871a4a01298..8ab9fb2f06d 100644 --- a/tests/robottelo/test_func_shared.py +++ b/tests/robottelo/test_func_shared.py @@ -2,19 +2,22 @@ import os import time +from fauxfactory import gen_integer, gen_string import pytest -from fauxfactory import gen_integer -from fauxfactory import gen_string - -from robottelo.utils.decorators.func_shared.file_storage import get_temp_dir -from robottelo.utils.decorators.func_shared.file_storage import TEMP_FUNC_SHARED_DIR -from robottelo.utils.decorators.func_shared.file_storage import TEMP_ROOT_DIR -from robottelo.utils.decorators.func_shared.shared import _NAMESPACE_SCOPE_KEY_TYPE -from robottelo.utils.decorators.func_shared.shared import _set_configured -from robottelo.utils.decorators.func_shared.shared import enable_shared_function -from robottelo.utils.decorators.func_shared.shared import set_default_scope -from robottelo.utils.decorators.func_shared.shared import shared -from robottelo.utils.decorators.func_shared.shared import SharedFunctionException + +from robottelo.utils.decorators.func_shared.file_storage import ( + TEMP_FUNC_SHARED_DIR, + TEMP_ROOT_DIR, + get_temp_dir, +) +from robottelo.utils.decorators.func_shared.shared import ( + _NAMESPACE_SCOPE_KEY_TYPE, + SharedFunctionException, + _set_configured, + enable_shared_function, + set_default_scope, + shared, +) DEFAULT_POOL_SIZE = 8 SIMPLE_TIMEOUT_VALUE = 3 diff --git a/tests/robottelo/test_helpers.py b/tests/robottelo/test_helpers.py index 8fa11e58836..0b39bb54b9e 100644 --- a/tests/robottelo/test_helpers.py +++ b/tests/robottelo/test_helpers.py @@ -1,8 +1,7 @@ """Tests for module ``robottelo.helpers``.""" import pytest -from robottelo.utils import slugify_component -from robottelo.utils import validate_ssh_pub_key +from robottelo.utils import slugify_component, validate_ssh_pub_key class FakeSSHResult: diff --git a/tests/robottelo/test_issue_handlers.py b/tests/robottelo/test_issue_handlers.py index bcdf0e58fba..090e031b6f7 100644 --- a/tests/robottelo/test_issue_handlers.py +++ b/tests/robottelo/test_issue_handlers.py @@ -1,18 +1,14 @@ +from collections import defaultdict import os import subprocess import sys -from collections import defaultdict -import pytest from packaging.version import Version +import pytest from pytest_plugins.issue_handlers import DEFAULT_BZ_CACHE_FILE -from robottelo.constants import CLOSED_STATUSES -from robottelo.constants import OPEN_STATUSES -from robottelo.constants import WONTFIX_RESOLUTIONS -from robottelo.utils.issue_handlers import add_workaround -from robottelo.utils.issue_handlers import is_open -from robottelo.utils.issue_handlers import should_deselect +from robottelo.constants import CLOSED_STATUSES, OPEN_STATUSES, WONTFIX_RESOLUTIONS +from robottelo.utils.issue_handlers import add_workaround, is_open, should_deselect class TestBugzillaIssueHandler: diff --git a/tests/upgrades/conftest.py b/tests/upgrades/conftest.py index 46473b916aa..d75929cb7b4 100644 --- a/tests/upgrades/conftest.py +++ b/tests/upgrades/conftest.py @@ -86,8 +86,8 @@ def test_capsule_post_upgrade_skipped(pre_upgrade_data): import json import os -import pytest from box import Box +import pytest from robottelo.logging import logger from robottelo.utils.decorators.func_locker import lock_function @@ -249,7 +249,7 @@ def test_something_post_upgrade(pre_upgrade_data): dependant_on_functions = [] for marker in request.node.iter_markers(POST_UPGRADE_MARK): depend_on = marker.kwargs.get('depend_on') - if isinstance(depend_on, (list, tuple)): + if isinstance(depend_on, list | tuple): dependant_on_functions.extend(depend_on) elif depend_on is not None: dependant_on_functions.append(depend_on) @@ -403,7 +403,7 @@ def pytest_collection_modifyitems(items, config): dependant_on_functions = [] for marker in item.iter_markers(POST_UPGRADE_MARK): depend_on = marker.kwargs.get('depend_on') - if isinstance(depend_on, (list, tuple)): + if isinstance(depend_on, list | tuple): dependant_on_functions.extend(depend_on) elif depend_on is not None: dependant_on_functions.append(depend_on) diff --git a/tests/upgrades/test_capsule.py b/tests/upgrades/test_capsule.py index fb6fc994ca4..19f8ad87b9e 100644 --- a/tests/upgrades/test_capsule.py +++ b/tests/upgrades/test_capsule.py @@ -8,7 +8,7 @@ :CaseComponent: Capsule -:Team: Endeavour +:Team: Platform :TestType: Functional diff --git a/tests/upgrades/test_client.py b/tests/upgrades/test_client.py index ed2069af5e3..8877550a29f 100644 --- a/tests/upgrades/test_client.py +++ b/tests/upgrades/test_client.py @@ -21,8 +21,7 @@ """ import pytest -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_4_CUSTOM_PACKAGE_NAME +from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME, FAKE_4_CUSTOM_PACKAGE_NAME from robottelo.hosts import ContentHost diff --git a/tests/upgrades/test_contentview.py b/tests/upgrades/test_contentview.py index 68e1b5918b0..2f50ee5db3d 100644 --- a/tests/upgrades/test_contentview.py +++ b/tests/upgrades/test_contentview.py @@ -16,12 +16,11 @@ :Upstream: No """ -import pytest from fauxfactory import gen_alpha +import pytest from robottelo.config import settings -from robottelo.constants import DataFile -from robottelo.constants import RPM_TO_UPLOAD +from robottelo.constants import RPM_TO_UPLOAD, DataFile class TestContentView: diff --git a/tests/upgrades/test_host.py b/tests/upgrades/test_host.py index a3a50fa334f..72a4465eea9 100644 --- a/tests/upgrades/test_host.py +++ b/tests/upgrades/test_host.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest class TestScenarioPositiveGCEHostComputeResource: diff --git a/tests/upgrades/test_hostgroup.py b/tests/upgrades/test_hostgroup.py index dc6c4d8d91b..c09de90e186 100644 --- a/tests/upgrades/test_hostgroup.py +++ b/tests/upgrades/test_hostgroup.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest class TestHostgroup: diff --git a/tests/upgrades/test_performance_tuning.py b/tests/upgrades/test_performance_tuning.py index ba5f79d1b8b..16033bbd521 100644 --- a/tests/upgrades/test_performance_tuning.py +++ b/tests/upgrades/test_performance_tuning.py @@ -31,7 +31,7 @@ class TestScenarioPerformanceTuning: Test Steps:: 1. Before satellite upgrade. - - Apply the medium tune size using satellite-installer. + - Apply non-default tuning size using satellite-installer. - Check the tuning status and their set tuning parameters after applying the new size. 2. Upgrade the satellite. 3. Verify the following points. @@ -49,17 +49,17 @@ class TestScenarioPerformanceTuning: @pytest.mark.pre_upgrade def test_pre_performance_tuning_apply(self, target_sat): - """In preupgrade scenario we apply the medium tuning size. + """In preupgrade scenario we apply non-default tuning size. :id: preupgrade-83404326-20b7-11ea-a370-48f17f1fc2e1 :steps: 1. collect the custom_hira.yaml file before upgrade. - 2. Update the tuning size to medium. + 2. Update the tuning size to non-default. 3. Check the updated tuning size. 4. If something gets wrong with updated tune size then restore the default tune size. - :expectedresults: Medium tuning parameter should be applied. + :expectedresults: Non-default tuning parameter should be applied. """ try: @@ -67,12 +67,12 @@ def test_pre_performance_tuning_apply(self, target_sat): local_path="custom-hiera-before-upgrade.yaml", remote_path="/etc/foreman-installer/custom-hiera.yaml", ) - installer_obj = InstallerCommand(tuning='medium') + installer_obj = InstallerCommand(tuning='development') command_output = target_sat.execute(installer_obj.get_command(), timeout='30m') assert 'Success!' in command_output.stdout installer_obj = InstallerCommand(help='tuning') command_output = target_sat.execute(installer_obj.get_command()) - assert 'default: "medium"' in command_output.stdout + assert 'default: "development"' in command_output.stdout except Exception as exp: logger.critical(exp) @@ -92,17 +92,17 @@ def test_post_performance_tuning_apply(self, target_sat): :steps: 1. Check the tuning size. 2. Compare the custom-hiera.yaml file. - 3. Change the tuning size from medium to default. + 3. Change the tuning size from non-default to default. :expectedresults: - 1. medium tune parameter should be unchanged after upgrade. + 1. non-default tuning parameter should be set after upgrade. 2. custom-hiera.yaml file should be unchanged after upgrade. 3. tuning parameter update should work after upgrade. """ installer_obj = InstallerCommand(help='tuning') command_output = target_sat.execute(installer_obj.get_command(), timeout='30m') - assert 'default: "medium"' in command_output.stdout + assert 'default: "development"' in command_output.stdout target_sat.get( local_path="custom-hiera-after-upgrade.yaml", remote_path="/etc/foreman-installer/custom-hiera.yaml", diff --git a/tests/upgrades/test_repository.py b/tests/upgrades/test_repository.py index a2f5188669c..2119fa57816 100644 --- a/tests/upgrades/test_repository.py +++ b/tests/upgrades/test_repository.py @@ -19,8 +19,7 @@ import pytest from robottelo.config import settings -from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME -from robottelo.constants import FAKE_4_CUSTOM_PACKAGE_NAME +from robottelo.constants import FAKE_0_CUSTOM_PACKAGE_NAME, FAKE_4_CUSTOM_PACKAGE_NAME from robottelo.hosts import ContentHost UPSTREAM_USERNAME = 'rTtest123' diff --git a/tests/upgrades/test_satellite_maintain.py b/tests/upgrades/test_satellite_maintain.py index fe7a3bb10af..81af10fdf1b 100644 --- a/tests/upgrades/test_satellite_maintain.py +++ b/tests/upgrades/test_satellite_maintain.py @@ -1,4 +1,4 @@ -"""Test for Satellite-maintain related Upgrade Scenario's +"""satellite-maintain Upgrade Scenarios :Requirement: UpgradedSatellite @@ -16,12 +16,13 @@ :Upstream: No """ +import re + import pytest class TestSatelliteMaintain: - """The test class contains pre-upgrade and post-upgrade scenarios to test - satellite-maintain utility + """Pre-upgrade and post-upgrade scenarios to test satellite-maintain utility. Test Steps: 1. Before Satellite upgrade, Perform test for "satellite-maintain upgrade list-versions" @@ -32,74 +33,19 @@ class TestSatelliteMaintain: @staticmethod def satellite_upgradable_version_list(sat_obj): - """ - This function is used to collect the details of satellite version and upgradable - version list. - - :return: satellite_version, upgradeable_version, major_version_change - """ - - cmd = "rpm -q satellite > /dev/null && rpm -q satellite --queryformat=%{VERSION}" - # leaving this section as-is for now but this could be refactored to use sat_obj.version - satellite_version = sat_obj.execute(cmd) - if satellite_version.status == 0: - satellite_version = satellite_version.stdout - else: - return [], [], None, None - satellite_maintain_version = sat_obj.execute( - "satellite-maintain upgrade list-versions --disable-self-upgrade" - ) - upgradeable_version = [ - version for version in satellite_maintain_version.stdout if version != '' - ] - version_change = 0 - for version in upgradeable_version: - version_change += int(version.split('.')[0]) - if version_change % 2 == 0: - major_version_change = False - y_version = '' - else: - major_version_change = True - y_version = list(set(satellite_maintain_version) - set(satellite_version))[0].split( - '.' - )[-1] - - return satellite_version, upgradeable_version, major_version_change, y_version + """Obtain upgradable version list by satellite-maintain. - @staticmethod - def version_details( - satellite_version, major_version_change, y_version, upgrade_stage="pre-upgrade" - ): - """ - This function is used to update the details of zstream upgrade and - next version upgrade - :param str satellite_version: satellite version would be like 6.5.0, 6.6.0, 6.7.0 - :param bool major_version_change: For major version upgrade like 6.8 to 7.0, 7.0 - to 8.0 etc, then major_version_change would be True. - :param str y_version: y_version change depends on major_version_change - :param str upgrade_stage: upgrade stage would be pre or post. - :return: zstream_version, next_version + :return: upgradeable_versions """ - - major_version = satellite_version.split('.')[0:1] - if major_version_change: - major_version = [int(major_version[0]) + 1].append(y_version) - else: - y_version = int(satellite_version.split('.')[0:2][-1]) - zstream_version = '' - if upgrade_stage == "pre-upgrade": - major_version.append(str(y_version + 1)) - zstream_version = ".".join(satellite_version.split('.')[0:2]) + ".z" - else: - major_version.append(str(y_version)) - major_version.append("z") - next_version = ".".join(major_version) - return zstream_version, next_version + cmd = 'satellite-maintain upgrade list-versions --disable-self-upgrade' + list_versions = sat_obj.execute(cmd).stdout + regex = re.compile(r'^\d+\.\d+') + upgradeable_versions = [version for version in list_versions if regex.match(version)] + return upgradeable_versions @pytest.mark.pre_upgrade def test_pre_satellite_maintain_upgrade_list_versions(self, target_sat): - """Pre-upgrade sceanrio that tests list of satellite version - which satellite can be upgraded. + """Test list of satellite target versions before upgrade. :id: preupgrade-fc2c54b2-2663-11ea-b47c-48f17f1fc2e1 @@ -107,29 +53,15 @@ def test_pre_satellite_maintain_upgrade_list_versions(self, target_sat): 1. Run satellite-maintain upgrade list-versions :expectedresults: Versions should be current z-stream. - """ - ( - satellite_version, - upgradable_version, - major_version_change, - y_version, - ) = self.satellite_upgradable_version_list(target_sat) - if satellite_version: - # In future If satellite-maintain packages update add before - # pre-upgrade test case execution then next version kind of - # stuff check we can add it here. - zstream_version, next_version = self.version_details( - satellite_version[0], major_version_change, y_version - ) - else: - zstream_version = -1 - assert zstream_version in upgradable_version + zstream = '.'.join(target_sat.version.split('.')[0:2]) + '.z' + upgradable_versions = self.satellite_upgradable_version_list(target_sat) + # only possible target should be appropriate zstream + assert set(upgradable_versions) - {zstream} == set() @pytest.mark.post_upgrade def test_post_satellite_maintain_upgrade_list_versions(self, target_sat): - """Post-upgrade sceanrio that tests list of satellite version - which satellite can be upgraded. + """Test list of satellite target versions after upgrade. :id: postupgrade-0bce689c-2664-11ea-b47c-48f17f1fc2e1 @@ -137,18 +69,8 @@ def test_post_satellite_maintain_upgrade_list_versions(self, target_sat): 1. Run satellite-maintain upgrade list-versions. :expectedresults: Versions should be next z-stream. - """ - ( - satellite_version, - upgradable_version, - major_version_change, - y_version, - ) = self.satellite_upgradable_version_list(target_sat) - if satellite_version: - zstream_version, next_version = self.version_details( - satellite_version[0], major_version_change, y_version, upgrade_stage="post-upgrade" - ) - else: - next_version = -1 - assert next_version in upgradable_version + zstream = '.'.join(target_sat.version.split('.')[0:2]) + '.z' + upgradable_versions = self.satellite_upgradable_version_list(target_sat) + # only possible target should be appropriate zstream + assert set(upgradable_versions) - {zstream} == set() diff --git a/tests/upgrades/test_subscription.py b/tests/upgrades/test_subscription.py index f94e27692f6..9515af048e3 100644 --- a/tests/upgrades/test_subscription.py +++ b/tests/upgrades/test_subscription.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from manifester import Manifester +import pytest from robottelo import constants from robottelo.config import settings diff --git a/tests/upgrades/test_syncplan.py b/tests/upgrades/test_syncplan.py index b4310a0a871..63fdb7ee164 100644 --- a/tests/upgrades/test_syncplan.py +++ b/tests/upgrades/test_syncplan.py @@ -16,8 +16,8 @@ :Upstream: No """ -import pytest from fauxfactory import gen_choice +import pytest from robottelo.constants import SYNC_INTERVAL from robottelo.utils.datafactory import valid_cron_expressions diff --git a/tests/upgrades/test_usergroup.py b/tests/upgrades/test_usergroup.py index c18b8904aea..838a074c363 100644 --- a/tests/upgrades/test_usergroup.py +++ b/tests/upgrades/test_usergroup.py @@ -16,11 +16,10 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest -from robottelo.constants import LDAP_ATTR -from robottelo.constants import LDAP_SERVER_TYPE +from robottelo.constants import LDAP_ATTR, LDAP_SERVER_TYPE class TestUserGroupMembership: diff --git a/tests/upgrades/test_virtwho.py b/tests/upgrades/test_virtwho.py index 4b2c30b2934..826e4e1b059 100644 --- a/tests/upgrades/test_virtwho.py +++ b/tests/upgrades/test_virtwho.py @@ -16,18 +16,20 @@ :Upstream: No """ -import pytest from fauxfactory import gen_string +import pytest from robottelo.cli.host import Host from robottelo.cli.subscription import Subscription from robottelo.cli.virt_who_config import VirtWhoConfig from robottelo.config import settings from robottelo.utils.issue_handlers import is_open -from robottelo.utils.virtwho import deploy_configure_by_command -from robottelo.utils.virtwho import get_configure_command -from robottelo.utils.virtwho import get_configure_file -from robottelo.utils.virtwho import get_configure_option +from robottelo.utils.virtwho import ( + deploy_configure_by_command, + get_configure_command, + get_configure_file, + get_configure_option, +) @pytest.fixture