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

Fix host owner checking and test name typo #15143

Closed
wants to merge 1 commit into from

Conversation

tpapaioa
Copy link
Contributor

@tpapaioa tpapaioa commented May 22, 2024

Not needed. Fixed by SatelliteQE/nailgun#1153

Problem Statement

There are a couple API test failures related to host owner checking, like the following from PRT job 7043:

14:46:30      @pytest.mark.tier2
14:46:30      def test_positive_create_and_update_with_user(
14:46:30          module_org, module_location, module_user, module_target_sat
14:46:30      ):
14:46:30          """Create and update host with user specified
14:46:30      
14:46:30          :id: 72e20f8f-17dc-4e38-8ac1-d08df8758f56
14:46:30      
14:46:30          :expectedresults: A host is created and updated with expected user assigned
14:46:30          """
14:46:30          host = module_target_sat.api.Host(
14:46:30              owner=module_user, owner_type='User', organization=module_org, location=module_location
14:46:30          ).create()
14:46:30  >       assert host.owner.read() == module_user
14:46:30  E       AssertionError: assert nailgun.entities.User(admin=False, auth_source=nailgun.entities.AuthSourceLDAP(id=1), auth_source_name='Internal', def..., login='AYpQhUAYUeu', mail='hAzyluvC@example.com', organization=[nailgun.entities.Organization(id=13)], role=[], id=5) == robottelo.hosts.DecClass(admin=False, auth_source=nailgun.entities.AuthSourceLDAP(id=1), auth_source_name='Internal', ..., login='AYpQhUAYUeu', mail='hAzyluvC@example.com', organization=[nailgun.entities.Organization(id=13)], role=[], id=5)
14:46:30  E        +  where nailgun.entities.User(admin=False, auth_source=nailgun.entities.AuthSourceLDAP(id=1), auth_source_name='Internal', def..., login='AYpQhUAYUeu', mail='hAzyluvC@example.com', organization=[nailgun.entities.Organization(id=13)], role=[], id=5) = <bound method User.read of nailgun.entities.User(id=5)>()
14:46:30  E        +    where <bound method User.read of nailgun.entities.User(id=5)> = nailgun.entities.User(id=5).read
14:46:30  E        +      where nailgun.entities.User(id=5) = nailgun.entities.Host(all_parameters=[{'priority': 0, 'created_at': '2024-02-21 00:29:10 UTC', 'updated_at': '2024-02-...nailgun.entities.Interface(host=nailgun.entities.Host(id=8), id=8)], build_status_label='Installed', owner_type='User').owner
14:46:30  
14:46:30  tests/foreman/api/test_host.py:471: AssertionError
14:46:30  =============================== warnings summary ======

These tests that compare host.owner to a user instance, but the comparison fails because they are instances of different classes:

  • host.owner is a nailgun.entity.User instance
  • module_user and other entities returned from module_target_sat.api.ENTITY_NAME are wrapped in a robottelo.hosts.DecClass instance.

This CLI test also has a typo in the name:
tests/foreman/cli/test_user.py::TestUser::test_positive_create_with_defaut_org

Solution

Update tests to compare host.owner to module_user and similar objects:

  • tests/foreman/api/test_host.py::test_positive_update_owner_type[User]
  • tests/foreman/api/test_host.py::test_positive_update_owner_type[Usergroup]
  • tests/foreman/api/test_host.py::test_positive_create_and_update_with_user

Update test name (defaut -> default):

  • tests/foreman/cli/test_user.py::TestUser::test_positive_create_with_default_org

Related Issues

@tpapaioa tpapaioa added CherryPick PR needs CherryPick to previous branches 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 labels May 22, 2024
@tpapaioa tpapaioa self-assigned this May 22, 2024
@tpapaioa
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_host.py::test_positive_update_owner_type[User] tests/foreman/api/test_host.py::test_positive_update_owner_type[Usergroup] tests/foreman/api/test_host.py::test_positive_create_and_update_with_user tests/foreman/cli/test_user.py::TestUser::test_positive_create_with_default_org

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 7075
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_host.py::test_positive_update_owner_type[User] tests/foreman/api/test_host.py::test_positive_update_owner_type[Usergroup] tests/foreman/api/test_host.py::test_positive_create_and_update_with_user tests/foreman/cli/test_user.py::TestUser::test_positive_create_with_default_org --external-logging
Test Result : ============= 1 failed, 3 passed, 61 warnings in 686.50s (0:11:26) =============

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label May 22, 2024
@tpapaioa tpapaioa closed this May 28, 2024
@tpapaioa tpapaioa deleted the fix_host_owner_read branch May 28, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 CherryPick PR needs CherryPick to previous branches PRT-Failed Indicates that latest PRT run is failed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants