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

Add test case to trigger the reclaim_space task #14397

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

vsedmik
Copy link
Contributor

@vsedmik vsedmik commented Mar 13, 2024

Problem Statement

A test case (and nailgun support) to trigger the Reclaim space task was missing. Also a BZ complained about wrong endpoint being referenced in apidoc.

Solution

This PR adds one.

PRT test Cases example

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py -k 'reclaim_space'
nailgun: 1111

@vsedmik vsedmik added CherryPick PR needs CherryPick to previous branches 6.15.z Introduced in or relating directly to Satellite 6.15 labels Mar 13, 2024
@vsedmik vsedmik self-assigned this Mar 13, 2024
@vsedmik vsedmik requested a review from a team as a code owner March 13, 2024 16:57
@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 13, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py -k 'reclaim_space'
nailgun: 1111

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6061
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py -k reclaim_space --external-logging
Test Result : =========== 1 failed, 21 deselected, 1 warning in 1811.44s (0:30:11) ===========

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Mar 13, 2024
@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 13, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py -k 'content_library_sync or reclaim_space'
nailgun: 1111

@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 13, 2024

"trigger": "test-robottelo"
"pytest": "tests/foreman/api/test_capsulecontent.py -k 'content_library_sync or reclaim_space'"
"nailgun": "1111"

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6065
Build Status: SUCCESS
PRT Comment: pytest /opt/app-root/src/robottelo/tests/foreman -v -m build_sanity --external-logging
Test Result : ======== 11 passed, 6091 deselected, 81 warnings in 1571.33s (0:26:11) =========

@Satellite-QE Satellite-QE added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Mar 13, 2024
@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 13, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space
nailgun: 1111

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6067
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space --external-logging
Test Result : ================= 2 passed, 45 warnings in 1400.86s (0:23:20) ==================

@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 13, 2024

Okay so the first PRT fail was due to reclaim_space run against a blank/unsynced capsule. After some struggle with test collection and PRT job reporting back to GH the final run triggered and reported correctly.

Copy link
Contributor

@damoore044 damoore044 left a comment

Choose a reason for hiding this comment

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

nice work!

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.

co-reviewed with @jameerpathan111.

The intention of the test is good, but I would choose different steps to achieve the same.

tests/foreman/api/test_capsulecontent.py Outdated Show resolved Hide resolved
@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 15, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space
nailgun: 1111

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6080
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space --external-logging
Test Result : ============ 1 failed, 1 passed, 42 warnings in 1483.41s (0:24:43) =============

@Satellite-QE Satellite-QE added PRT-Failed Indicates that latest PRT run is failed for the PR and removed PRT-Passed Indicates that latest PRT run is passed for the PR labels Mar 15, 2024
@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6081
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space --external-logging
Test Result : ============ 1 failed, 1 passed, 41 warnings in 1551.28s (0:25:51) =============

@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 15, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space
nailgun: 1111

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6087
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space --external-logging
Test Result : ================= 2 passed, 40 warnings in 2326.98s (0:38:46) ==================

@Satellite-QE Satellite-QE added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Mar 15, 2024
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.

Nice work, @vsedmik!
There is only one blocking comment - verify_ssl should be parametrized by settings.

robottelo/hosts.py Outdated Show resolved Hide resolved
Comment on lines 1820 to 1831
@property
def apidoc(self):
"""Provide Satellite's apidoc via apypie"""
if not self._apidoc:
self._apidoc = apypie.Api(
uri=self.url,
username=settings.server.admin_username,
password=settings.server.admin_password,
api_version=2,
verify_ssl=False,
).apidoc
return self._apidoc
Copy link
Member

Choose a reason for hiding this comment

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

@JacobCallahan Do you see any benefit in making it a @cached_property instead of the current design?

tests/foreman/api/test_capsulecontent.py Outdated Show resolved Hide resolved
@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 19, 2024

trigger: test-robottelo
pytest: tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space
nailgun: 1111

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 6122
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_uploaded_content_library_sync tests/foreman/api/test_capsulecontent.py::TestCapsuleContentManagement::test_positive_reclaim_space --external-logging
Test Result : ================= 2 passed, 41 warnings in 1445.32s (0:24:05) ==================

), 'Unexpected task triggered'
assert 'success' in task['result'], 'Reclaim task did not succeed'

# Check the apidoc references the correct endpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the test up to this line, I know the apidoc check responds to the bz, but I'm not convinced it really makes sense to check the apidoc for one specific endpoint. I mean, how likely it is that the same problem reappears at the same endpoint? If it re-appears on a different one we won't catch it anyway. Maybe this would warrant a more general discussion about how (and if) we want to tackle apidoc issues like this one. My hunch is that this should be a case for upstream unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. The primary goal was to add some coverage for reclaim_space functionality and the following lines were added just for the case when some reviewer comes and says "but that BZ talks about wrong apidoc, where is it checked".
We can remove it after some generic test for entire apidoc is added? Which would be probably handled by the team owning the API component.

@vsedmik vsedmik requested a review from ogajduse March 19, 2024 19:41
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.

ACK, changes are fine by me. I will leave the merge up to @pondrejk if they get to a conclusion in the philosophical debate about customer case automation.

@lhellebr
Copy link
Contributor

Should this verify some space has actually been reclaimed?

@lhellebr
Copy link
Contributor

Related: #14425

@vsedmik
Copy link
Contributor Author

vsedmik commented Mar 26, 2024

Should this verify some space has actually been reclaimed?

Replied here already #14397 (comment)

I can imagine two scenarios where this is tested

  1. Function-scoped capsule (to avoid interference with other tests). Cons - yet another VM checked out and set up just for this case, unusable for n_minus testing.
  2. Add some "unusual" repo syncing. Cons - here you rely that no one adds a test to sync the same repo with immediate dwl policy in the future, which would break the assertion.

Copy link
Contributor

@pondrejk pondrejk left a comment

Choose a reason for hiding this comment

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

talked to @vsedmik offline, we agreed the best way forward atm is to merge it as is

@pondrejk pondrejk merged commit ac4b0cf into SatelliteQE:master Mar 27, 2024
7 of 8 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 27, 2024
* Add test case to trigger the reclaim_space task

* Use apypie for apidoc parsing

* Address improvement suggestions, rebase

(cherry picked from commit ac4b0cf)
pondrejk pushed a commit that referenced this pull request Mar 27, 2024
Add test case to trigger the reclaim_space task (#14397)

* Add test case to trigger the reclaim_space task

* Use apypie for apidoc parsing

* Address improvement suggestions, rebase

(cherry picked from commit ac4b0cf)

Co-authored-by: vsedmik <[email protected]>
shweta83 pushed a commit to shweta83/robottelo that referenced this pull request Apr 10, 2024
* Add test case to trigger the reclaim_space task

* Use apypie for apidoc parsing

* Address improvement suggestions, rebase
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 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