Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternate Content Source UI tests #12649

Merged
merged 7 commits into from
Oct 20, 2023
Merged

Alternate Content Source UI tests #12649

merged 7 commits into from
Oct 20, 2023

Conversation

LadislavVasina1
Copy link
Contributor

@LadislavVasina1 LadislavVasina1 commented Sep 19, 2023

In this PR I have implemented two tests. One end-to-end UI test tests the creation of some ACS types and actions on them and the second one tests the creation of all possible ACS types.

@LadislavVasina1 LadislavVasina1 added UI Issues and PRs involving the UI CherryPick PR needs CherryPick to previous branches Auto_Cherry_Picked Automatically cherrypicked PR using GHA AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing 6.14.z Introduced in or relating directly to Satellite 6.14 labels Sep 19, 2023
@LadislavVasina1 LadislavVasina1 self-assigned this Sep 19, 2023
@LadislavVasina1 LadislavVasina1 requested review from a team as code owners September 19, 2023 07:18
Copy link
Member

@ogajduse ogajduse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM code-wise, but not an ACS expert though.

Copy link
Contributor

@vsedmik vsedmik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, the test just does what I would expect it to do - tests the UI.
Good job @LadislavVasina1 !

8. Test editing urls and subpaths
9. Test editing credentials
10. Test editing products

Copy link
Contributor

@pondrejk pondrejk Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codewise I see no problems but I'm not convinced of this all being in a single test. If there is a bug in creation of just of the types in step 2 we never get to testing other things, with 10 types it is not so improbable.

IIUC the ACSes in edit and rename steps are just selected randomly, and there are special ones created to test deletion anyway.

My suggestion is to have a separate test for step 2 -- check all types can be created.

And then have a separate e2e test for the other steps, just move the deletion part at the very end.

Bonus suggestion: consider what it would take to have ACS configuration for the individual types defined in some structure and then use that to parametrize the tests. For the check all types can be created test it would ensure all types are always tested (currently, if the first one fails others are not visited). For the e2e test, we could pick one or more types for coverage, or a random one perhaps :)

@LadislavVasina1 LadislavVasina1 marked this pull request as draft October 3, 2023 13:03
@LadislavVasina1
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ui/test_acs.py -k 'test_check_all_acs_types_can_be_created or test_acs_positive_end_to_end'

@LadislavVasina1 LadislavVasina1 marked this pull request as ready for review October 10, 2023 08:39
@LadislavVasina1 LadislavVasina1 requested review from pondrejk and a team October 10, 2023 08:39
Copy link
Member

@rplevka rplevka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to re-do the structure of the test, to separate the parametrization logic from the test body:

you define a function to generate the payload data and nice test id strings (I only picked some of the params you use in your tests for the demonstration purposes, you might want to add the missing ones yourself):

def gen_params():
    a = {
        '_common': {
            'use_http_proxies': True,
        },
        'custom': {
            '_common': {
                'custom_type': True,
                'base_url': 'https://test.com/',
                'subpaths': ['test/'],
            },
            'yum': {
                'content_type': 'yum'
            },
            'file': {}
        },
        'simplified': {
            '_common': {
                'simplified_type': True
            },
            'yum': {
                'content_type': 'yum',
                'name': 'simpleYum',
                'description': 'simpleYumDesc',
                'capsules_to_add': class_target_sat.hostname,
                'products_to_add': [constants.REPOS[repo]['product'] for repo in repos_to_enable]
            },
            'file': {
                'content_type': 'file',
                'name': 'simpleFile',
                'description': 'simpleFileDesc',
                'add_all_capsules': True,
                'products_to_add': product_name,
            },
        },
        'rhui': {
            'yum': {
                'rhui_type': True,
                'name': 'rhuiYumNoneAuth',
                'base_url': 'https://test.com/pulp/content',
                'subpaths': ['test/', 'test2/'],
            },
        }
    }
    ids = []
    vals = []
    for acs in a.keys():
        if not acs.startswith('_'):
            for cnt in a[acs]:
                if not cnt.startswith('_'):
                    scenario = a[acs][cnt] | a.get('_common', {}) | a[acs].get('_common', {})   
                    ids.append(f'{acs}_{cnt}')
                    vals.append(scenario)
    return (vals, ids)

and here's how you use it in your test

@pytest.mark.parametrize('scenario, gen_params()[0], ids=gen_params()[1])    # you put a call to the function into the parametrize call like so
def test_param(scenario):
    ....
    session.acs.create_new_acs(**scenario)                 # and you access the function payload per current scenario like so
    pass

This generates the following tests with the following "payload":

$ pytest -vs test_foo.py
==== test session starts ====
...
collected 5 items                                                                                                                  

test_foo.py::test_param[custom_yum] {'content_type': 'yum', 'use_http_proxies': True, 'custom_type': True, 'base_url': 'https://test.com', 'subpaths': ['test/']}
PASSED
test_foo.py::test_param[custom_file] {'use_http_proxies': True, 'custom_type': True, 'base_url': 'https://test.com', 'subpaths': ['test/']}
PASSED
test_foo.py::test_param[simplified_yum] {'content_type': 'yum', 'name': 'simpleYum', 'description': 'simpleYumDesc', 'capsules_to_add': 'placeholder', 'products_to_add': [1, 2, 3], 'use_http_proxies': True, 'simplified_type': True}
PASSED
test_foo.py::test_param[simplified_file] {'content_type': 'file', 'name': 'simpleFile', 'description': 'simpleFileDesc', 'add_all_capsules': True, 'products_to_add': 'placeholder', 'use_http_proxies': True, 'simplified_type': True}
PASSED
test_foo.py::test_param[rhui_yum] {'rhui_type': True, 'name': 'rhuiYumNoneAuth', 'base_url': 'https://test.com/pulp/content', 'subpaths': ['test/', 'test2/'], 'use_http_proxies': True}
PASSED

While at it, you can extend the dictionary with the auth parameter too and break those test cases into smaller, individual ones.

tests/foreman/ui/test_acs.py Outdated Show resolved Hide resolved
@LadislavVasina1
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/ui/test_acs.py

Copy link
Member

@rplevka rplevka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! thanks for addressing my comments. I appreciate it.

@ogajduse ogajduse merged commit af1e9ec into master Oct 20, 2023
5 checks passed
@ogajduse ogajduse deleted the ACS_test_coverage_615 branch October 20, 2023 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.14.z Introduced in or relating directly to Satellite 6.14 Auto_Cherry_Picked Automatically cherrypicked PR using GHA AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches UI Issues and PRs involving the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants