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

[6.15.z] Add json response to entity creation error message #1137

Conversation

Satellite-QE
Copy link
Contributor

Cherrypick of PR: #1119

Description of changes

Add json response to entity creation error message

  • Makes the error message information more detailed and informative
  • Possibility to write more precise assertions

There are some robottelo tests that would greatly benefit from more precise assertions on error messages, i.e.
tests/foreman/api/test_repository.py::TestRepository::test_negative_update_checksum_with_on_demand_policy (or other tests in this module)
I doubt that the supposed error message should be:

RuntimeError: The repository's publication is missing. Please run a 'complete sync' on MPvytWJ.","errors":["Task c7fa616b-2f71-4476-b581-1cae65a9eafd: RuntimeError: The repository's publication is missing. Please run a 'complete sync' on MPvytWJ."]}
Upstream API documentation, plugin, or feature links

None

Functional demonstration

Example:

before:

requests.exceptions.HTTPError: ('422 Client Error: Unprocessable Content for url: https://robottelo...')

after

requests.exceptions.HTTPError: ('422 Client Error: Unprocessable Content for url: https://...', {'displayMessage': 'Validation failed: When "Upstream URL" is set, "Releases/Distributions" must also be set!', 'errors': {'base': ['When "Upstream URL" is set, "Releases/Distributions" must also be set!']}}
Additional Information

None

* Makes the error message information more detailed and informative
* Possibility to write more precise assertions

Signed-off-by: dosas <dosas@users.noreply.github.com>
(cherry picked from commit 95b3ce1)
@Satellite-QE Satellite-QE added 6.15.z Auto_Cherry_Picked GHA has automatically cherrypicked this PR No-CherryPick PR doesnt need CherryPick to previous branches labels Apr 17, 2024
@Satellite-QE
Copy link
Contributor Author

trigger: test-robottelo
pytest: -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py

@Satellite-QE
Copy link
Contributor Author

PRT Result

Build Number: 26
Build Status: UNSTABLE
PRT Comment: pytest -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py --external-logging
Test Result : ==== 1 failed, 1 passed, 163 deselected, 195 warnings in 689.38s (0:11:29) =====

@dosas
Copy link
Collaborator

dosas commented Apr 25, 2024

@omkarkhatavkar I cannot see the cause of the error. Could you maybe paste the stacktrace?

@dosas
Copy link
Collaborator

dosas commented May 15, 2024

@omkarkhatavkar let me know if I can help you to get this PR fixed.

@omkarkhatavkar
Copy link
Contributor

trigger: test-robottelo
pytest: -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py

@Satellite-QE
Copy link
Contributor Author

PRT Result

Build Number: 30
Build Status: UNSTABLE
PRT Comment: pytest -k test_negative_update_checksum_with_on_demand_policy tests/foreman/api/test_repository.py --external-logging
Test Result : ==== 1 failed, 1 passed, 163 deselected, 193 warnings in 667.88s (0:11:07) =====

@omkarkhatavkar
Copy link
Contributor

@dosas here is the stack

repo = robottelo.hosts.DecClass(ansible_collection_auth_url=None, ansible_collection_auth_token=None, ansible_collection_requ...stream_username=None, verify_ssl_on_sync=True, http_proxy_policy='global_default_http_proxy', http_proxy_id=None, id=1)

    @pytest.mark.tier1
    @pytest.mark.parametrize(
        'repo_options',
        **datafactory.parametrized(
            {
                checksum_type: {'checksum_type': checksum_type, 'download_policy': 'immediate'}
                for checksum_type in ('sha1', 'sha256')
            }
        ),
        indirect=True,
    )
    def test_negative_update_checksum_with_on_demand_policy(self, repo):
        """Attempt to update the download policy to on_demand on a repository with checksum type.
    
        :id: 5bfaef4f-de66-42a0-8419-b86d00ffde6f
    
        :parametrized: yes
    
        :expectedresults: A repository is not updated and error is raised.
    
        :CaseImportance: Critical
        """
        repo.download_policy = 'on_demand'
>       with pytest.raises(HTTPError):
E       Failed: DID NOT RAISE <class 'requests.exceptions.HTTPError'>

tests/foreman/api/test_repository.py:576: Failed

@dosas
Copy link
Collaborator

dosas commented May 15, 2024

@dosas here is the stack

repo = robottelo.hosts.DecClass(ansible_collection_auth_url=None, ansible_collection_auth_token=None, ansible_collection_requ...stream_username=None, verify_ssl_on_sync=True, http_proxy_policy='global_default_http_proxy', http_proxy_id=None, id=1)

    @pytest.mark.tier1
    @pytest.mark.parametrize(
        'repo_options',
        **datafactory.parametrized(
            {
                checksum_type: {'checksum_type': checksum_type, 'download_policy': 'immediate'}
                for checksum_type in ('sha1', 'sha256')
            }
        ),
        indirect=True,
    )
    def test_negative_update_checksum_with_on_demand_policy(self, repo):
        """Attempt to update the download policy to on_demand on a repository with checksum type.
    
        :id: 5bfaef4f-de66-42a0-8419-b86d00ffde6f
    
        :parametrized: yes
    
        :expectedresults: A repository is not updated and error is raised.
    
        :CaseImportance: Critical
        """
        repo.download_policy = 'on_demand'
>       with pytest.raises(HTTPError):
E       Failed: DID NOT RAISE <class 'requests.exceptions.HTTPError'>

tests/foreman/api/test_repository.py:576: Failed

Thank you.

  • Does this test fail for all parametrizations (sha1, sha256)?
  • Are we sure that this test is stable? I wonder why it did succeed for the master branch merge.

I do not exactly know what this katello code does but there was a change in this section 2 years ago that was just recently fixed in robottelo

I doubt that this error is caused by the change since the error raised is still the same.

@omkarkhatavkar
Copy link
Contributor

It looks like not related to this PR change.

@omkarkhatavkar omkarkhatavkar merged commit 72e1c66 into 6.15.z May 15, 2024
22 of 23 checks passed
@omkarkhatavkar omkarkhatavkar deleted the cherry-pick-6.15.z-95b3ce10125cfbc8d9a6d8a8e2b38a5007dd1b16 branch May 15, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.15.z Auto_Cherry_Picked GHA has automatically cherrypicked this PR No-CherryPick PR doesnt need CherryPick to previous branches PRT-Failed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants