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 upstream api permission tests #14475

Merged

Conversation

dosas
Copy link
Collaborator

@dosas dosas commented Mar 21, 2024

Problem Statement

API permission tests failing for upstream

Solution

Relevant tests:

tests/foreman/cli/test_role.py
tests/foreman/api/test_role.py
tests/foreman/api/test_permission.py

@dosas dosas requested review from a team as code owners March 21, 2024 14:35
@ogajduse
Copy link
Member

ogajduse commented Apr 2, 2024

@pondrejk @lhellebr @pnovotny Can you please take a look at @dosas's PR? It is touching a module that belongs to your team.

cls.permissions.pop('JobInvocation')
cls.permissions.pop('JobTemplate')
cls.permissions.pop('RemoteExecutionFeature')
cls.permissions.pop('TemplateInvocation')
if 'rubygem-foreman_puppet' not in rpm_packages:
Copy link
Contributor

Choose a reason for hiding this comment

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

There are more rpm conditions than previously. Have tests failed on these in upstream?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since upstream is defined as

# rpm -q satellite-capsule
package satellite-capsule is not installed

yes they failed.

Copy link
Member

Choose a reason for hiding this comment

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

robottelo/robottelo/hosts.py

Lines 1540 to 1547 in 21580fc

@cached_property
def is_upstream(self):
"""Figure out which product distribution is installed on the server.
:return: True if no downstream satellite RPMS are installed
:rtype: bool
"""
return self.execute(f'rpm -q {self.product_rpm_name}').status != 0

What I got from your comment is that the current implementation of is_upstream does not suit you. Is that correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I do not really have an issue with it. It is just more a check for 'not downstream satellite'.
I am not really running the tests on upstream but a different downstream so it kind of helps me I guess.

Copy link
Member

Choose a reason for hiding this comment

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

@dosas is correct here that the missing presence of Satellite rpms isn't the most accurate test of whether we're in an upstream/downstream environment or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lhellebr To answer your original questions: Yes there are more conditions because there are also more permissions that were added.

IMO the definition of is_upstream is out of scope of this PR.

@dosas dosas force-pushed the fix/upstream-api-permission-tests branch from 1c15804 to c770084 Compare April 9, 2024 13:22
* add more checks for installed rpm packages
* speedup by querying rpm -qa ony once
* some tests were not update with this commit
  SatelliteQE@6651dd6#diff-9a55ae74469aa91ad5efb2b9068f73174467cd0c00d45abf7d35f9f2277a7632
@dosas dosas force-pushed the fix/upstream-api-permission-tests branch from c770084 to 6298c51 Compare April 10, 2024 12:12
@dosas dosas requested a review from lhellebr April 10, 2024 12:12
@Gauravtalreja1 Gauravtalreja1 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 Apr 11, 2024
@pondrejk pondrejk added No-CherryPick PR doesnt need CherryPick to previous branches and removed 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 Apr 17, 2024
@pondrejk
Copy link
Contributor

trigger: test-robottelo
pytest: tests/foreman/api/test_permission.py -k test_positive_search

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6545
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_permission.py -k test_positive_search --external-logging
Test Result : ========== 3 passed, 13 deselected, 114 warnings in 812.58s (0:13:32) ==========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Apr 17, 2024
@dosas
Copy link
Collaborator Author

dosas commented Apr 17, 2024

@pondrejk Why did you remove the labels?

@pondrejk
Copy link
Contributor

hi @dosas, I checked out this branch locally and ran some tests from the affected files, all seems well, prt also passes so I'm ok with merging this, thanks for the contribution. I reckoned that downstream branches would not be of interest to you, so I changed the labels. If you need those cherry picks I can put them back

@dosas
Copy link
Collaborator Author

dosas commented Apr 17, 2024

hi @dosas, I checked out this branch locally and ran some tests from the affected files, all seems well, prt also passes so I'm ok with merging this, thanks for the contribution. I reckoned that downstream branches would not be of interest to you, so I changed the labels. If you need those cherry picks I can put them back

I would require 6.15.z please

@pondrejk pondrejk added CherryPick PR needs CherryPick to previous branches 6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing and removed No-CherryPick PR doesnt need CherryPick to previous branches labels Apr 17, 2024
@pondrejk pondrejk merged commit 8476e50 into SatelliteQE:master Apr 17, 2024
22 of 23 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 17, 2024
* add more checks for installed rpm packages
* speedup by querying rpm -qa ony once
* some tests were not update with this commit
  6651dd6#diff-9a55ae74469aa91ad5efb2b9068f73174467cd0c00d45abf7d35f9f2277a7632

(cherry picked from commit 8476e50)
jyejare pushed a commit to jyejare/robottelo that referenced this pull request Oct 19, 2024
* add more checks for installed rpm packages
* speedup by querying rpm -qa ony once
* some tests were not update with this commit
  SatelliteQE@6651dd6#diff-9a55ae74469aa91ad5efb2b9068f73174467cd0c00d45abf7d35f9f2277a7632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.15.z Introduced in or relating directly to Satellite 6.15 AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants